67 lines
1.3 KiB
JavaScript
67 lines
1.3 KiB
JavaScript
import SkillUtil from "../ts/game/skill/core/SkillUtil";
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
bgNode: cc.Node,
|
|
itemIcon: cc.Sprite,
|
|
nameLab: cc.Label,
|
|
infoLab: cc.Label,
|
|
operation: cc.Node,
|
|
},
|
|
|
|
ctor() {
|
|
this.skillid = 0;
|
|
},
|
|
|
|
onLoad() {
|
|
this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan.bind(this));
|
|
this.operation.active = false;
|
|
this.cbfunc = {};
|
|
},
|
|
|
|
loadInfo(skillid, isFaction = false, useInfo = null) {
|
|
let skill = SkillUtil.getSkill(skillid);
|
|
if (skill) {
|
|
this.itemIcon.spriteFrame = SkillUtil.getSkillIcon(skill.icon);
|
|
}
|
|
this.nameLab.string = skill.name;
|
|
this.infoLab.string = skill.getDetail();
|
|
if (!skill.getDetail() || isFaction) {
|
|
this.infoLab.string = skill.effectDesc;
|
|
} else {
|
|
if (useInfo != null) {
|
|
this.infoLab.string = skill.getDetail(useInfo);
|
|
}
|
|
}
|
|
|
|
this.skillid = skillid;
|
|
},
|
|
|
|
showOperation(btncbfuncs, node) {
|
|
if (!!node && node.active)
|
|
return;
|
|
this.operation.active = true;
|
|
this.cbfunc = btncbfuncs;
|
|
},
|
|
|
|
nodeDestroy() {
|
|
this.node.runAction(cc.sequence(cc.fadeOut(0.1), cc.removeSelf()));
|
|
},
|
|
|
|
touchBegan(event) {
|
|
if (this.bgNode.getBoundingBoxToWorld().contains(event.getLocation())) {
|
|
return;
|
|
}
|
|
this.nodeDestroy();
|
|
},
|
|
|
|
operationSkill(e, d) {
|
|
let func = this.cbfunc[d];
|
|
if (func) {
|
|
func();
|
|
}
|
|
},
|
|
});
|