const BridgeWindow = require( "bridge.window" ); const ADVCT = require("adventure_controller"); const ADVCONST = require("adventure_const"); const ADEVT = require("adventure_event"); const ItemLay = require("cmp.common.itemlayout"); const TipsController = require("tips_controller"); cc.Class({ extends: BridgeWindow, properties: { //周回 times:{ default:null, type:cc.Node }, energy:{//體力值 default:null, type:cc.Node }, exps:{//進度 default:null, type:cc.Node }, upHeros:{//up英雄 default:null, type:ItemLay }, upCamps:{//up陣營 default:null, type:cc.Node }, itemCamp:{ default:null, type:cc.Node }, //無盡 lastNum:{//剩餘次數 default:null, type:cc.Node }, curFloor:{ default:null, type:cc.Node }, maxFloor:{ default:null, type:cc.Node }, times2:{ default:null, type:cc.Node }, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.ctrl = ADVCT.getInstance(); this.bindGEvent(ADEVT.Init_Model_Win,this.initBase.bind(this)); this.bindGEvent(ADEVT.UpModel_Up_Cfg,this.initUpCfgs.bind(this)); this.bindGEvent(ADEVT.Buy_Energy,this.updateBuyEnergy.bind(this)); }, updateBuyEnergy(energy){ nx.gui.setString(this.energy,"",energy); }, initBase(data){ this.ctrl.send29509(2);//需要周回模式的up英雄 this.data = data; //周回 nx.gui.setString(this.energy,"",data.energy); nx.gui.setCdTxt(this.times,"",data.end_time - data.start_time); nx.gui.setString(this.exps,"", cc.js.formatStr(nx.text.getKey("AdvenExplore"),data.explore)); //無盡 nx.gui.setString(this.lastNum,"",nx.text.getKey("lab_limitexercise_panel_tip2")+data.times); nx.gui.setString(this.curFloor,"", cc.js.formatStr(nx.text.getKey("AdvenFloors"),data.id)); nx.gui.setString(this.maxFloor,"",data.pass_id); nx.gui.setCdTxt(this.times2,"",data.end_time - data.start_time); }, initUpCfgs(data){ let list = []; for(let i in data.partner_up_list){ let bid = data.partner_up_list[i].bid; let cfg = game.configs.partner_data.data_partner_base[bid]; if(cfg){ list.push(cfg); } } this.upHeros.rebuild(list); nx.bridge.NodeChidrenDestroy(this.upCamps); for(let id in data.camp_list){ let res_path = cc.js.formatStr("coms/images/camps%s",data.camp_list[id].camp_id); let camp = cc.instantiate(this.itemCamp); camp.parent = this.upCamps; camp.active = true; camp.y = 0; nx.gui.setSpriteFrame(camp,"",res_path); } }, start () { }, onOpenConfigs(params) { this.ctrl.send29500(1); // 引导辅助 if( nx.bridge.plot && nx.bridge.plot.isDoing() ) { this.scheduleOnce( () => { this.positionPlotCells(); }, 1 ); } }, onPreClosed() { this.upHeros.rebuild([]); nx.bridge.NodeChidrenDestroy(this.upCamps); }, selectModel(e){ let model_type = Number(e); this.ctrl.setPlayModel(model_type || 1); if(model_type == ADVCONST.PLAY_MODEL.ENDLESS){ //直接进入主界面,再确认是不是需要选英雄 nx.bridge.createPanel("WndAdventureMain",{type:model_type}); }else if(model_type == ADVCONST.PLAY_MODEL.WEEKLY){ //进入英雄上阵专属界面,此功能基于玩家背包英雄数据 if(this.data.explore == 0){//未开始,则可以选择英雄 nx.bridge.createPanel("WndAdventureWeeklyHero",{}); }else{ nx.bridge.createPanel("WndAdventureMain",{type:model_type}); } } this.close(); }, onClickWeeklyAward(){ nx.bridge.createPanel("WndAdventureExploreAward",{}); }, onClickEndlessAward(){ nx.bridge.createPanel("WndAdventureEndlessAward",{}); }, onTouchWeeklyRule(){ let txt = game.configs.adventure_weekly_data.data_explain; TipsController.getInstance().showDetailPanel(txt); }, onTouchEndlessRule(){ let txt = game.configs.adventure_endless_data.data_explain; TipsController.getInstance().showDetailPanel(txt); }, clickAddPower(){ let cfg = game.configs.adventure_weekly_data.data_adventure_const.prize; let buyLimit = game.configs.adventure_weekly_data.data_adventure_const.buy_condition.val; let str = cc.js.formatStr(nx.text.getKey("AdvenBuyEnerg"),cfg.val[0],cfg.val[1],buyLimit[1],buyLimit[0]); nx.mbox(str,["cancel","confirm"],(_key,_box)=>{ _box.close(); if(_key == "confirm"){ this.ctrl.send29513(); } }); }, clickReset(){ // if(this.data.times > 0){ this.ctrl.send29512(); // } }, clickHelp(){ nx.bridge.createPanel( "WndPlotPictures", { id:"adventure" } ); }, // ============================================ // 引导辅助 // ============================================ // 定位副本輔助热区 positionPlotCells: function() { let node = nx.gui.find(this,"main/help"); if( !node ) { return nx.error( "$Dispatch:定位第一个派遣订单失败!" ); } let cell = nx.gui.find( this, "plotCell" ); let btn = node; let pos = btn.convertToWorldSpaceAR( cc.Vec2.ZERO ); cell.position = cell.parent.convertToNodeSpaceAR( pos ); cell.width = btn.width; cell.height = btn.height; }, onTouchFirstHelp: function() { let cell = nx.gui.find( this, "plotCell" ); if( cell ) { this.clickHelp(); } }, // update (dt) {}, });