// //////////////////////////////////////////////////////////////////// // 这里填写简要说明(必填), // // @author: xhj(必填, 创建模块的人员) // @editor: xhj(必填, 后续维护以及修改的人员) // @description: // 新手训练营 //
Create: 2019-11-06 // //////////////////////////////////////////////////////////////////// const BridgeController = require( "bridge.controller" ); var TrainingcampModel = require("trainingcamp_model"); var TrainingcampEvent = require("trainingcamp_event"); var TrainingcampController = cc.Class({ extends: BridgeController, ctor: function () { this.model = new TrainingcampModel(this); this.is_open_all_finish_partner = false }, getModel:function(){ return this.model }, registerEvents:function(){ //新获得伙伴弹窗 // if( ! this.get_all_finish_tips_event ){ // gcore.GlobalEvent.fire(MainuiEvent.CLOSE_ITEM_VIEW, function(){ // if( this.is_open_all_finish_partner == true ){ // this.openTrainingcampAllfinishTipsWindow(true) // this.is_open_all_finish_partner = false // } // }) // } }, registerProtocals:function(){ this.RegisterProtocal(27600, this.handle27600.bind(this)) // 请求完成情况 this.RegisterProtocal(27601, this.handle27601.bind(this)) // 开始挑战 this.RegisterProtocal(27604, this.handle27604.bind(this)) // 开始挑战 this.RegisterProtocal(27602, this.handle27602.bind(this)) // 请求进入 this.RegisterProtocal(27603, this.handle27603.bind(this)) // 点击阵法图标 }, reqBaseFromServer: function( _cb ){ let cfgs = [ "training_camp_data", ]; this.loadConfigs( cfgs, ( _ret, _data ) =>{ this.SendProtocal(27600, {}, _cb ); } ) }, // 请求完成情况 send27600:function( ){ var protocal = {} this.SendProtocal(27600, protocal) }, // 完成情况 handle27600:function( data ){ if( data ){ // if( this.model.finish_ids.length+1 == data.ids.length && gconfig("training_camp_data","data_info") && gconfig("training_camp_data","data_info").length == data.ids.length){ // this.is_open_all_finish_partner = true // } let len = game.configs.training_camp_data.data_info_length; nx.mTip.openTip( "trainingCamp.show", data.reward_ids.length != len ); nx.mTip.openTip( "trainingCamp.get", data.reward_ids.length != data.ids.length ); this.model.setInfo(data) gcore.GlobalEvent.fire(TrainingcampEvent.Update_Trainingcamp_Data_Event) } }, // 请求开始挑战 send27601:function(id ,formation_type , pos_info){ var protocal = {} protocal.id = id protocal.formation_type = formation_type protocal.pos_info = pos_info this.SendProtocal(27601, protocal) }, // 开始挑战 handle27601:function( data ){ if( data ){ nx.tbox(data.msg) if( data.flag == 1 ){ nx.bridge.closePanel( "WndTrainingCampMore" ); } } }, // 请求进入 send27602:function( id ){ this.model.setSelectId( id ); var protocal = {}; protocal.id = id; this.reqId = id; this.SendProtocal(27602, protocal) }, // 请求进入 handle27602:function( data ){ if( data ){ if( !nx.dt.strEmpty( data.msg ) ){ nx.tbox(data.msg); } if( data.flag == 1 && data.is_first == 1 ){ gcore.GlobalEvent.fire(TrainingcampEvent.Update_Trainingcamp_Tips_Event) } gcore.GlobalEvent.fire(TrainingcampEvent.Is_Show_Formation_Event,{ id:this.reqId, flag : data.flag } ) } }, // 点击阵法图标 send27603:function( id ){ var protocal = {} protocal.id = id this.SendProtocal(27603, protocal) }, // 点击阵法图标 handle27603:function( ){ }, // 请求 領取獎勵 send27604:function( _id ){ var protocal = {}; protocal.id = _id; this.SendProtocal(27604, protocal) }, handle27604:function( _data ){ let data = { flag : _data.flag, id: _data.id } gcore.GlobalEvent.fire( TrainingcampEvent.Update_Trainingcamp_Data_Event, data ); }, //训练选择界面 openTrainingcampWindow:function( status){ if( status == true ){ if( this.TrainingcampWindow == null ){ this.TrainingcampWindow = Utils.createClass("trainingcamp_window"); } this.TrainingcampWindow.open() } else{ if( this.TrainingcampWindow ){ this.TrainingcampWindow.close() this.TrainingcampWindow = null } } }, // 引导需要 getTrainingcampRoot:function( ){ if( this.TrainingcampWindow ){ return this.TrainingcampWindow.root_wnd } }, //提示信息界面 openTrainingcampTipsWindow:function(status,data){ if( status == true ){ if( this.TrainingcampTipsWindow == null ){ this.TrainingcampTipsWindow = Utils.createClass("trainingcamp_tips_window") } this.TrainingcampTipsWindow.open(data) } else{ if( this.TrainingcampTipsWindow ){ this.TrainingcampTipsWindow.close() this.TrainingcampTipsWindow = null } } }, //布阵界面 openTrainingcampMainWindow:function( status,data){ if( status == true ){ if( this.TrainingcampMainWindow == null ){ this.TrainingcampMainWindow = Utils.createClass("trainingcamp_main_window") //this.TrainingcampMainWindow = TrainingcampMainWindow.New() } this.TrainingcampMainWindow.open(data) } else{ if( this.TrainingcampMainWindow ){ this.TrainingcampMainWindow.close() this.TrainingcampMainWindow = null } } }, //完成所有提示界面 openTrainingcampAllfinishTipsWindow:function(status){ if( status == true ){ if( this.TrainingcampAllTipsWindow == null ){ this.TrainingcampAllTipsWindow = Utils.createClass("trainingcamp_allfinish_tips_window") } this.TrainingcampAllTipsWindow.open() } else{ if( this.TrainingcampAllTipsWindow ){ this.TrainingcampAllTipsWindow.close() this.TrainingcampAllTipsWindow = null } } }, __delete: function () { if (this.model != null) { this.model.DeleteMe(); this.model = null; } }, })