"use strict"; cc._RF.push(module, '5c963X8pMlH742oH3YcyVhF', 'trainingcamp_controller'); // Scripts/mod/pve/trainingcamp/trainingcamp_controller.js "use strict"; // //////////////////////////////////////////////////////////////////// // 这里填写简要说明(必填), // // @author: xhj(必填, 创建模块的人员) // @editor: xhj(必填, 后续维护以及修改的人员) // @description: // 新手训练营 //
Create: 2019-11-06 // //////////////////////////////////////////////////////////////////// var BridgeController = require("bridge.controller"); var TrainingcampModel = require("trainingcamp_model"); var TrainingcampEvent = require("trainingcamp_event"); var TrainingcampController = cc.Class({ "extends": BridgeController, ctor: function ctor() { this.model = new TrainingcampModel(this); this.is_open_all_finish_partner = false; }, getModel: function getModel() { return this.model; }, registerEvents: function registerEvents() { //新获得伙伴弹窗 // 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 registerProtocals() { 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 reqBaseFromServer(_cb) { var _this = this; var cfgs = ["training_camp_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.SendProtocal(27600, {}, _cb); }); }, // 请求完成情况 send27600: function send27600() { var protocal = {}; this.SendProtocal(27600, protocal); }, // 完成情况 handle27600: function handle27600(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 // } var 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 send27601(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 handle27601(data) { if (data) { nx.tbox(data.msg); if (data.flag == 1) { nx.bridge.closePanel("WndTrainingCampMore"); } } }, // 请求进入 send27602: function send27602(id) { this.model.setSelectId(id); var protocal = {}; protocal.id = id; this.reqId = id; this.SendProtocal(27602, protocal); }, // 请求进入 handle27602: function handle27602(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 send27603(id) { var protocal = {}; protocal.id = id; this.SendProtocal(27603, protocal); }, // 点击阵法图标 handle27603: function handle27603() {}, // 请求 領取獎勵 send27604: function send27604(_id) { var protocal = {}; protocal.id = _id; this.SendProtocal(27604, protocal); }, handle27604: function handle27604(_data) { var data = { flag: _data.flag, id: _data.id }; gcore.GlobalEvent.fire(TrainingcampEvent.Update_Trainingcamp_Data_Event, data); }, //训练选择界面 openTrainingcampWindow: function openTrainingcampWindow(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 getTrainingcampRoot() { if (this.TrainingcampWindow) { return this.TrainingcampWindow.root_wnd; } }, //提示信息界面 openTrainingcampTipsWindow: function openTrainingcampTipsWindow(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 openTrainingcampMainWindow(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 openTrainingcampAllfinishTipsWindow(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 __delete() { if (this.model != null) { this.model.DeleteMe(); this.model = null; } } }); cc._RF.pop();