"use strict"; cc._RF.push(module, '2c1e7feMMhAvpohtfoZsaA6', 'startower_controller'); // Scripts/mod/startower/startower_controller.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 星命塔 //
Create: 2019-02-27 11:03:16 // -------------------------------------------------------------------- var MainuiController = require("mainui_controller"); var BattleEvent = require("battle_event"); var BattleController = require("battle_controller"); var BattleConst = require("battle_const"); var StartowerEvent = require("startower_event"); var LevupgradeController = require("levupgrade_controller"); var StartowerController = cc.Class({ "extends": BaseController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var StartowerModel = require("startower_model"); this.model = new StartowerModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() {}, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(11320, this.handle11320); //星命塔信息 this.RegisterProtocal(11321, this.handle11321); //购买挑战次数 this.RegisterProtocal(11322, this.handle11322); //挑战星命塔 this.RegisterProtocal(11323, this.handle11323); //推送星命塔结算 this.RegisterProtocal(11324, this.handle11324); //扫荡星命塔 this.RegisterProtocal(11325, this.handle11325); //请求星命塔通关录像 this.RegisterProtocal(11326, this.handle11326); //推送星命塔有解锁 this.RegisterProtocal(11333, this.handle11333); //分享通关录像 this.RegisterProtocal(11327, this.handle11327); // 星命塔排行榜 this.RegisterProtocal(11328, this.handle11328); //通关奖励 this.RegisterProtocal(11329, this.handle11329); }, checkIsOpen: function checkIsOpen(show_desc) { var open_config = Config.star_tower_data.data_tower_const.open_floor; if (open_config == null) return false; var is_open = MainuiController.getInstance().checkIsOpenByActivate(open_config.val); if (is_open == false && show_desc == true) { message(open_config.desc); } return is_open; }, //打开主界面 openMainView: function openMainView(bool) { if (!bool) { if (this.main_view) { this.main_view.close(); this.main_view = null; } } else { if (!this.checkIsOpen(true)) return; if (!this.main_view) { this.main_view = Utils.createClass("star_tower_window_window", this); } if (this.main_view && this.main_view.isOpen() == false) { this.main_view.open(); } } }, //打开挑战主界面 openStarTowerMainView: function openStarTowerMainView(bool, data) { if (bool) { if (!this.star_tower_window) { this.star_tower_window = Utils.createClass("star_tower_main_window", this); } if (this.star_tower_window && this.star_tower_window.isOpen() == false) { this.star_tower_window.open(data); } } else { if (this.star_tower_window) { this.star_tower_window.close(); this.star_tower_window = null; } } }, //打开奖励总览 openAwardWindow: function openAwardWindow(bool) { if (bool) { if (!this.award_window) { this.award_window = Utils.createClass("star_tower_award_window", this); } if (this.award_window && this.award_window.isOpen() == false) { this.award_window.open(); } } else { if (this.award_window) { this.award_window.close(); this.award_window = null; } } }, //打开录像界面 openVideoWindow: function openVideoWindow(bool, data, tower) { if (bool) { if (!this.video_window) { this.video_window = Utils.createClass("star_tower_video_window", this); } if (this.video_window && this.video_window.isOpen() == false) { this.video_window.open([data, tower]); } } else { if (this.video_window) { this.video_window.close(); this.video_window = null; } } }, //星命塔结算 getResultWindow: function getResultWindow() { return this.result_window; }, //打开结算界面 openResultWindow: function openResultWindow(bool, data) { if (bool == true) { // -- 不能直接出剧情或者引导 LevupgradeController.getInstance().waitForOpenLevUpgrade(true); if (!this.result_window) { this.result_window = Utils.createClass("star_tower_result_window", this); } if (this.result_window && this.result_window.isOpen() == false) { this.result_window.open(data, BattleConst.Fight_Type.StarTower); } } else { if (this.result_window) { this.result_window.close(); this.result_window = null; } if (this.is_show_lock == true && this.show_data) {// --this.openGetWindow(true,this.show_data.tower) } else { gcore.GlobalEvent.fire(BattleEvent.CLOSE_RESULT_VIEW); } this.is_show_lock = false; this.show_data = null; } }, //打开结算界面 openGetWindow: function openGetWindow(bool, data) { if (bool == true) { if (!this.get_window) { this.get_window = Utils.createClass("star_tower_get_window", this); } if (this.get_window && this.get_window.isOpen() == false) { this.get_window.open(data); } } else { if (this.get_window) { this.get_window.close(); this.get_window = null; } } }, //请求星命塔数据 sender11320: function sender11320() { this.SendProtocal(11320, {}); }, handle11320: function handle11320(data) { this.model.setStarTowerData(data); }, //购买挑战次数 sender11321: function sender11321() { var protocal = {}; this.SendProtocal(11321, protocal); }, handle11321: function handle11321(data) { message(data.msg); this.model.updateLessCount(data); }, //挑战星命塔 sender11322: function sender11322(tower) { var protocal = {}; protocal.tower = tower; this.SendProtocal(11322, protocal); }, handle11322: function handle11322(data) { message(data.msg); this.openStarTowerMainView(false); }, //推送星命塔结算 handle11323: function handle11323(data) { if (data.result == 1) { BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.StarTower, data); this.model.updateMaxTower(data); this.model.updateLessCount(data); } else { BattleController.getInstance().openFailFinishView(true, BattleConst.Fight_Type.StarTower, data.result, data); } }, //扫荡星命塔 sender11324: function sender11324(tower) { var protocal = {}; protocal.tower = tower; this.SendProtocal(11324, protocal); }, handle11324: function handle11324(data) { message(data.msg); this.model.updateLessCount(data); }, //请求星命塔通关录像 sender11325: function sender11325(tower) { var protocal = {}; protocal.tower = tower; this.SendProtocal(11325, protocal); }, handle11325: function handle11325(data) { message(data.msg); gcore.GlobalEvent.fire(StartowerEvent.Video_Data_Event, data); }, handle11326: function handle11326(data) { this.show_data = data; this.is_show_lock = true; // --self:openGetWindow(true,data.tower) }, //分享通关录像 sender11333: function sender11333(replay_id, channel, tower) { var protocal = {}; protocal.replay_id = replay_id; protocal.channel = channel; protocal.tower = tower; this.SendProtocal(11333, protocal); }, handle11333: function handle11333(data) { message(data.msg); if (data.result == 1) { this.openVideoWindow(false); } }, requestStarTowerRank: function requestStarTowerRank() { this.SendProtocal(11327, {}); }, handle11327: function handle11327(data) { gcore.GlobalEvent.fire(StartowerEvent.Update_Top3_rank, data.rank_lists); }, //领取通关奖励 sender11328: function sender11328(id) { var proto = {}; proto.id = id; this.SendProtocal(11328, proto); }, handle11328: function handle11328(data) { message(data.msg); if (data.result == 1) { gcore.GlobalEvent.fire(StartowerEvent.Update_Reward_Event); } }, handle11329: function handle11329(data) { this.model.setRewardData(data.award_list); gcore.GlobalEvent.fire(StartowerEvent.Update_First_Reward_Msg); }, __delete: function __delete() { if (this.model != null) { this.model.DeleteMe(); this.model = null; } }, getStarTowerRoot: function getStarTowerRoot() { if (this.main_view) return this.main_view.root_wnd; }, getStarTowerChallengeRoot: function getStarTowerChallengeRoot() { if (this.star_tower_window) return this.star_tower_window.root_wnd; } }); module.exports = StartowerController; cc._RF.pop();