51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
const GuildBatMod = require("guildbat.mod");
|
|
const BridgeWindow = require( "bridge.window" );
|
|
const GuildwarEvent = require("guildwar_event");
|
|
const NxExpand = require("nx.fx.sv.expand");
|
|
cc.Class({
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
boxList:{
|
|
default:null,
|
|
type:NxExpand
|
|
},
|
|
winTxt:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
this.mod = GuildBatMod.getInstance();
|
|
this.bindGEvent(GuildwarEvent.UpdateGuildWarBoxDataEvent,this.initBoxAwards.bind(this));
|
|
this.bindGEvent(GuildwarEvent.UpdateMyAwardBoxEvent,this.updateMyBox.bind(this));
|
|
},
|
|
|
|
initBoxAwards(data){
|
|
if(data.result == 0){//輸
|
|
nx.gui.setString(this.winTxt,"",nx.text.getKey("GuildBatBoxFail"));
|
|
}else{//贏
|
|
nx.gui.setString(this.winTxt,"",nx.text.getKey("GuildBatBoxWin"));
|
|
}
|
|
|
|
this.boxList.rebuild(data.guild_war_box);
|
|
},
|
|
|
|
updateMyBox(){
|
|
let box_data = this.mod.getGuildWarBoxData();
|
|
this.boxList.rebuild(box_data.guild_war_box);
|
|
},
|
|
|
|
onOpenConfigs() {
|
|
//请求宝箱初始化数据
|
|
this.mod.requestAwardBoxData();
|
|
},
|
|
|
|
onPreClosed() {
|
|
this.boxList.rebuild([]);
|
|
},
|
|
});
|