Files
2026-05-23 22:10:14 +08:00

65 lines
1.8 KiB
JavaScript

const GuildBatMod = require("guildbat.mod");
const GuildwarConst = require("guildbat.define");
const GuildMainCmp = require("cmp.guildbat.main");
cc.Class({
extends: cc.Component,
properties: {
posOrder:{
default:null,
type:cc.Node
},
powerNum:{
default:null,
type:cc.Node
},
occupFlag:{//正在攻占的標志
default:null,
type:cc.Node
},
mainCmp:{
default:null,
type:GuildMainCmp
}
},
setData(data){
if(nx.dt.objEmpty(data)){
nx.warn("公會戰據點數據異常");
return;
}
this.data = data;
let cfg = game.configs.guild_war_data.data_position[data.pos];
if(cfg){
this.node.x = cfg.pos_x;
this.node.y = cfg.pos_y;
}
nx.gui.setString(this.posOrder,"",data.pos);
nx.gui.setString(this.powerNum,"",data.power);
nx.gui.setActive(this.occupFlag,"",data.hp == 0);
for(let i=3;i>data.hp;i--){
nx.gui.setActive(this,String(i)+"/star",false);
}
let pos_type = this.mainCmp.getPositionType();
this.pos_type = pos_type;
if(pos_type == GuildwarConst.positions.others){
nx.gui.setActive(this,"other",true);
}else{
nx.gui.setActive(this,"self",true);
}
},
touchPosInfo(){
if(this.data.status == 1){
return nx.tbox("GuildBatAtki");
}
if(GuildBatMod.getInstance().getGuildWarStatus() == 5){
return nx.tbox("GuildBatEnd");
}
if(this.pos_type == GuildwarConst.positions.others){
GuildBatMod.getInstance().requestEnemyPositionData(this.data.pos);
}
}
});