97 lines
3.2 KiB
JavaScript
97 lines
3.2 KiB
JavaScript
import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
|
|
|
|
let CPubFunction = require('./PubFunction');
|
|
|
|
var ESpeakerPos = {
|
|
Left: 1,
|
|
Right: 2,
|
|
};
|
|
|
|
cc.Class({
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {},
|
|
|
|
|
|
onLoad() {
|
|
},
|
|
|
|
|
|
start() {
|
|
|
|
},
|
|
|
|
Init(vecSpeak, pCallBack) {
|
|
|
|
this.nIndex = 6000;
|
|
this.vecSpeakEvent = [];
|
|
|
|
this.mapFaceFrame = {};
|
|
this.vecCharItem = [];
|
|
this.pCallBack = pCallBack;
|
|
|
|
for (let i = 0; i < vecSpeak.length; i++) {
|
|
this.vecSpeakEvent.push(vecSpeak[i]);
|
|
}
|
|
|
|
this.NextSpeak();
|
|
},
|
|
|
|
ShowTalkText(strText, emPos) {
|
|
cc.find('nodCustomRichText', this.node).width = this.node.width - 307;
|
|
cc.find('nodCustomRichText/view', this.node).getComponent(cc.Widget).updateAlignment()
|
|
cc.find('nodCustomRichText', this.node).setPosition(cc.v2(emPos == ESpeakerPos.Left ? 130 : -100, 0));
|
|
let nodContent = cc.find('nodCustomRichText/view/content', this.node);
|
|
let label = nodContent.getComponent(cc.Label);
|
|
if (label) {
|
|
label.string = strText;
|
|
}
|
|
},
|
|
|
|
onDestroy() {
|
|
|
|
},
|
|
|
|
NextSpeak() {
|
|
if (this.vecSpeakEvent.length <= 0) {
|
|
CPubFunction.FindAndHidenNode(cc.find('Canvas/MainUI'), {
|
|
nX: 0,
|
|
nY: -1000
|
|
});
|
|
|
|
if (this.pCallBack)
|
|
this.pCallBack();
|
|
|
|
return;
|
|
}
|
|
|
|
let stEvent = this.vecSpeakEvent.shift();
|
|
this.ShowTalkText(stEvent.strText, stEvent.emPos);
|
|
this.SetSpeaker(stEvent.nSpeakerID, stEvent.strName, stEvent.emPos);
|
|
},
|
|
|
|
|
|
SetSpeaker(nSpeakerID, strSpeakerName, emSpeakerPos) {
|
|
let pSelf = this;
|
|
cc.find('picName/label', this.node).getComponent(cc.Label).string = strSpeakerName;
|
|
let resid = nSpeakerID;
|
|
if(resid <= 4038){
|
|
cc.find('picName', this.node).setPosition(cc.v2(-120,125));
|
|
cc.find('picName/label', this.node).color = new cc.color(0,255,0,255);
|
|
}else{
|
|
cc.find('picName', this.node).setPosition(cc.v2(120,125));
|
|
cc.find('picName/label', this.node).color = new cc.color(241,227,122,255);
|
|
}
|
|
|
|
if (resid <= 4038||resid==6024||resid==6006||resid==6026||resid==6027||resid==6025||resid==6029||resid==6034||resid==6080||resid==5054||resid==6089||resid==6030||resid==6081||resid==6035||resid==6061||resid==6078||resid==6011||resid==6140||resid==6141||resid==6142) {
|
|
CPubFunction.SetSpineAvatar(cc.find('goSpeaker1', this.node),cc.find('picAvatar', this.node),nSpeakerID,cc.find('goSpeaker', this.node));
|
|
}else{
|
|
CPubFunction.SetDragonBoneAvatar(cc.find('goSpeaker', this.node),cc.find('picAvatar', this.node),nSpeakerID,cc.find('goSpeaker1', this.node));
|
|
}
|
|
//CPubFunction.SetDragonBoneAvatar(cc.find('goSpeaker', this.node),cc.find('picAvatar', this.node),nSpeakerID);
|
|
cc.find('goSpeaker', pSelf.node).setPosition(cc.v2(emSpeakerPos == ESpeakerPos.Left ? -380 : 360, -160));
|
|
cc.find('goSpeaker1', pSelf.node).setPosition(cc.v2(emSpeakerPos == ESpeakerPos.Left ? -380 : 360, -160));
|
|
cc.find('picAvatar', pSelf.node).setPosition(cc.v2(emSpeakerPos == ESpeakerPos.Left ? -380 : 360, 60));
|
|
},
|
|
}); |