134 lines
4.1 KiB
JavaScript
134 lines
4.1 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const RankConstant = require( "rank_constant" );
|
||
|
|
const TipsController = require( "tips_controller" );
|
||
|
|
const ElementController = require("element_controller");
|
||
|
|
const ElementEvent = require("element_event");
|
||
|
|
const ElementItem = require("cmp.element.item");
|
||
|
|
const RoleController = require("role_controller");
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
item_list:{
|
||
|
|
default:[],
|
||
|
|
type:[ElementItem]
|
||
|
|
},
|
||
|
|
count:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
buyCount:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
cdNd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad() {
|
||
|
|
this.ctrl = ElementController.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
|
||
|
|
this.bindGEvent( ElementEvent.Update_Element_Data_Event, this.updateData.bind( this ) );
|
||
|
|
this.bindGEvent( ElementEvent.Update_Element_Count_Event, this.checkBuyCount.bind( this ) );
|
||
|
|
},
|
||
|
|
|
||
|
|
updateData(){
|
||
|
|
if(!this.model.checkIsHaveElementData())return;
|
||
|
|
let ele_data = this.model.getElementData();
|
||
|
|
|
||
|
|
//設置冷卻時間
|
||
|
|
for(let i in ele_data.list){
|
||
|
|
let data = ele_data.list[i];
|
||
|
|
if(data.endtime > 0){
|
||
|
|
nx.gui.setCdTxt(this.cdNd,"",data.endtime);
|
||
|
|
this.model.setRecordOpenType(data.type);
|
||
|
|
|
||
|
|
}
|
||
|
|
for(let j in this.item_list){
|
||
|
|
if(this.item_list[j].type == data.type){
|
||
|
|
this.item_list[j].setData(data);
|
||
|
|
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
start() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs() {
|
||
|
|
//刷新當天基礎數據
|
||
|
|
this.ctrl.sender25000();
|
||
|
|
this.checkBuyCount();
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
checkBuyCount(){
|
||
|
|
let last_count = this.model.getTodayLeftBuyCount();
|
||
|
|
nx.gui.setString(this.buyCount,"",last_count);
|
||
|
|
let challenge_count = this.model.getLeftChallengeCount();
|
||
|
|
let str = cc.js.formatStr("%s/%s",challenge_count,game.configs.element_temple_data.data_const.refresh_number.val);
|
||
|
|
nx.gui.setString(this.count,"",str);
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickBuyCount(){
|
||
|
|
let challenge_count = this.model.getLeftChallengeCount();
|
||
|
|
if(challenge_count >= game.configs.element_temple_data.data_const.refresh_number.val){
|
||
|
|
return nx.tbox("tip_eleChangeNumEnough");
|
||
|
|
}
|
||
|
|
let str = "";
|
||
|
|
if(this.model.getTodayLeftBuyCount() > 0){
|
||
|
|
let normal_buy_count = this.model.getNormalBuyCount()
|
||
|
|
let buy_cfg = game.configs.element_temple_data.data_buy_count[normal_buy_count + 1]
|
||
|
|
let privilege_status = RoleController.getInstance().getModel().checkPrivilegeStatus(4) // 特權激活狀態
|
||
|
|
if (buy_cfg) {
|
||
|
|
str = cc.js.formatStr(nx.text.getKey("lab_guildsecretarea_tips_34"), 3, buy_cfg.cost)
|
||
|
|
}else if (privilege_status) {
|
||
|
|
let buy_count = this.model.getPrivilegeBuyCount()
|
||
|
|
let pri_cost = game.configs.element_temple_data.data_privilege[buy_count+1]
|
||
|
|
if (pri_cost) {
|
||
|
|
str = cc.js.formatStr(nx.text.getKey("lab_guildsecretarea_tips_34"), 3, pri_cost)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.mbox(str,["cancel","confirm"],(_key,_box)=>{
|
||
|
|
_box.close();
|
||
|
|
if(_key == "confirm"){
|
||
|
|
this.ctrl.sender25003();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}else{
|
||
|
|
nx.tbox("tip_eleBuyNumOver");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 规则说明
|
||
|
|
onTouchTip: function() {
|
||
|
|
let TC = TipsController.getInstance();
|
||
|
|
if( TC ) {
|
||
|
|
let txt = game.configs.element_temple_data.data_explain;
|
||
|
|
TC.showDetailPanel( txt );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickRank() {
|
||
|
|
nx.bridge.createPanel( "WndPVERankAward", {
|
||
|
|
type: RankConstant.RankType.element,
|
||
|
|
ops: [ "RankNow", "rank_reward" ],
|
||
|
|
dfg: game.configs.element_temple_data.data_award,
|
||
|
|
show: "RankNow",
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
} );
|