69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
|
import GameModel from "../../ts/core/GameModel";
|
||
|
import { EActType } from "../../ts/game/battle/Battle";
|
||
|
import ItemUtil from "../../ts/core/ItemUtil";
|
||
|
import SKLogger from "../../ts/gear_2.3.4/util/SKLogger";
|
||
|
|
||
|
cc.Class({
|
||
|
extends: cc.Component,
|
||
|
|
||
|
properties: {
|
||
|
NumLabel: cc.Label,
|
||
|
iconSpr: cc.Sprite,
|
||
|
effect:[cc.Node],
|
||
|
},
|
||
|
|
||
|
ctor(){
|
||
|
this.selectCallback = null;
|
||
|
this.itemid = 0;
|
||
|
this.operid = 0;
|
||
|
},
|
||
|
|
||
|
setItemInfo(info) {
|
||
|
let conf=ItemUtil.getItemData(info.itemid);
|
||
|
if(conf==null){
|
||
|
SKLogger.warn(`戰鬥:道具${info.itemid}定義找不到`);
|
||
|
return;
|
||
|
}
|
||
|
let iconFrame = ItemUtil.getItemIcon(conf.icon);
|
||
|
this.iconSpr.spriteFrame = iconFrame;
|
||
|
this.NumLabel.string = info.num;
|
||
|
this.itemid = info.itemid;
|
||
|
this.effect[0].active = info.effect == 'hm';
|
||
|
this.effect[1].active = info.effect == 'h';
|
||
|
this.effect[2].active = info.effect == 'm';
|
||
|
this.effect[3].active = info.effect == 't';
|
||
|
},
|
||
|
|
||
|
onItemClick(e, d){
|
||
|
let stage = cc.find('Canvas/BattleLayer/BattleStage');
|
||
|
if (stage) {
|
||
|
let stageLogic = stage.getComponent('BattleStage');
|
||
|
stageLogic.cleanAllRoleSelectFlag();
|
||
|
stageLogic.btlUIlogic.closeItemPanel();
|
||
|
let itemid = this.itemid;
|
||
|
if(itemid == 40017){
|
||
|
stageLogic.selectTarget(2, (targetid) => {
|
||
|
stageLogic.btlUIlogic.backType = 6;
|
||
|
let params={
|
||
|
action: EActType.ITEM,
|
||
|
actionid: itemid,
|
||
|
targetid: targetid,
|
||
|
onlyid: this.operid
|
||
|
};
|
||
|
GameModel.send('c2s_btl_act',params);
|
||
|
});
|
||
|
}else{
|
||
|
stageLogic.selectTarget(1, (targetid) => {
|
||
|
stageLogic.btlUIlogic.backType = 6;
|
||
|
let params={
|
||
|
action: EActType.ITEM,
|
||
|
actionid: itemid,
|
||
|
targetid: targetid,
|
||
|
onlyid: this.operid
|
||
|
};
|
||
|
GameModel.send('c2s_btl_act',params);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
});
|