// //////////////////////////////////////////////////////////////////// // 這裡填寫簡要說明(必填), // @author. lwc@syg.com(必填, 創建模塊的人員) // @editor. xxx@syg.com(必填, 後續維護以及修改的人員) // @description. // 公會秘境 後端 國輝 策劃 松岳 //
Create. 2019年9月11日 // //////////////////////////////////////////////////////////////////// const BridgeController = require( "bridge.controller" ); var GuildsecretareaEvent = require("guildsecretarea_event"); var BattleController = require("battle_controller"); var GuildController = require("guild_controller"); var BattleConst = require("battle_const"); var GuildsecretareaController = cc.Class({ extends: BridgeController, ctor: function () { }, initConfig: function () { var GuildsecretareaModel = require("guildsecretarea_model") this.model = new GuildsecretareaModel(this) this.model.initConfig() }, getModel: function () { return this.model }, registerEvents: function () { }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { // 配置加载 let cfgs = [ "guild_secret_area_data", ]; this.loadConfigs( cfgs, ( _ret, _data ) => { this.reqData( _cb ); } ); }, reqData( _cb ){ this.sender26800( _cb ); }, registerProtocals: function () { this.RegisterProtocal(26800, this.handle26800.bind(this)) //公會秘境基礎信息 this.RegisterProtocal(26801, this.handle26801.bind(this)) //公會秘境設置Boss this.RegisterProtocal(26802, this.handle26802.bind(this)) //挑戰公會秘境Boss this.RegisterProtocal(26803, this.handle26803.bind(this)) //購買挑戰次數 this.RegisterProtocal(26804, this.handle26804.bind(this)) //領取階段獎勵 this.RegisterProtocal(26805, this.handle26805.bind(this)) //掃蕩公會秘境Boss this.RegisterProtocal(26806, this.handle26806.bind(this)) //獲得秘境Boss排行榜 this.RegisterProtocal(26807, this.handle26807.bind(this)) //討伐開始彈窗 this.RegisterProtocal(26808, this.handle26808.bind(this)) //boss討伐成功或失敗界面 this.RegisterProtocal(26809, this.handle26809.bind(this)) //boss小結算界面 this.RegisterProtocal(26810, this.handle26810.bind(this)) //活躍度刷新 }, //公會秘境基礎信息 sender26800: function ( _cb ) { let protocal = {} this.SendProtocal(26800, protocal, _cb ); }, handle26800: function (data) { this.model.updateSecretareaData(data) gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_MAIN_EVENT, data) }, //公會秘境設置Boss sender26801: function (boss_id) { let protocal = {} protocal.boss_id = boss_id this.SendProtocal(26801, protocal) }, handle26801: function (data) { //message(data.msg) if (data.flag == true) { // gcore.GlobalEvent.fire(GuildsecretareaEvent.TERM_BEGINS_BUY_COUNT_EVENT, data) } }, //挑戰公會秘境Boss sender26802: function (boss_id, formation_type, pos_info, hallows_id) { let protocal = {} protocal.boss_id = boss_id protocal.formation_type = formation_type protocal.pos_info = pos_info protocal.hallows_id = hallows_id this.SendProtocal(26802, protocal) }, handle26802: function (data) { //message(data.msg) }, //購買挑戰次數 sender26803: function (boss_id) { let protocal = {} protocal.boss_id = boss_id this.SendProtocal(26803, protocal) }, handle26803: function (data) { //message(data.msg) if (data.flag == true) { this.model.updateSecretareaBuyCount(data) gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_BUY_COUNT_EVENT, data) } }, //領取階段獎勵 sender26804: function (boss_id, number) { let protocal = {} protocal.boss_id = boss_id protocal.number = number this.SendProtocal(26804, protocal) }, handle26804: function (data) { //message(data.msg) if (data.flag == true) { gcore.GlobalEvent.fire(GuildsecretareaEvent.TERM_BEGINS_RECEIVE_REWARD_EVENT, data) } }, //掃蕩公會秘境Boss sender26805: function (boss_id) { let protocal = {} protocal.boss_id = boss_id this.SendProtocal(26805, protocal) }, handle26805: function (data) { //message(data.msg) if (data.flag == true) { this.sender26800() gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_REFRESH_RANK_EVENT) } }, //獲得秘境Boss排行榜 sender26806: function (boss_id, num) { let protocal = {} protocal.boss_id = boss_id protocal.num = num this.SendProtocal(26806, protocal) }, handle26806: function (data) { this.model.updateBossRankInfo(data) gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_RANK_COUNT_EVENT, data) }, //討伐開始彈窗 sender26807: function () { let protocal = {} this.SendProtocal(26807, protocal) }, handle26807: function (data) { this.model.updateStartCrusadeInfo(data) if (data.flag == 0 && data.end_time != 0) { this.openGuildsecretareaStartCrusadePanel(true) } }, //boss討伐成功或失敗界面 sender26808: function () { let protocal = {} this.SendProtocal(26808, protocal) }, //boss討伐成功或失敗界面(推送的) handle26808: function (data) { this.openGuildsecretareaEndCrusadePanel(true, data.flag, data) }, //boss小結算界面 sender26809: function () { let protocal = {} this.SendProtocal(26809, protocal) }, //boss小結算界面(推送) handle26809: function (data) { this.new_result_data = data; return; this.sender26800() gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_REFRESH_RANK_EVENT) data.item_rewards = data.reward BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildSecretArea, data) }, newResultWin: function(){ if(!this.new_result_data)return; let data = this.new_result_data; this.sender26800() gcore.GlobalEvent.fire(GuildsecretareaEvent.GUILD_SECRET_AREA_REFRESH_RANK_EVENT) data.item_rewards = data.reward BattleController.getInstance().openFinishView(true, BattleConst.Fight_Type.GuildSecretArea, data) this.new_result_data = null; }, //活躍度 sender26810: function () { let protocal = {} this.SendProtocal(26810, protocal) }, //活躍度 handle26810: function (data) { let my_guild_info = GuildController.getInstance().getModel().getMyGuildInfo() if (my_guild_info) { my_guild_info.setGuildAttribute("vitality", data.vitality) } }, //打開公會秘境 openGuildsecretareaMainWindow: function (status, setting) { var RoleController = require("role_controller") if (RoleController.getInstance().getRoleVo().isHasGuild() == false) { //message(Utils.TI18N("您當前未加入任何公會,加入公會後才能參與該玩法!")) return } if (status == true) { if (this.guildsecretarea_main_window == null) { this.guildsecretarea_main_window = Utils.createClass("guildsecretarea_main_window"); } this.guildsecretarea_main_window.open(setting); } else { if (this.guildsecretarea_main_window) { this.guildsecretarea_main_window.close(); this.guildsecretarea_main_window = null; } } }, //打開開始討伐彈窗 openGuildsecretareaStartCrusadePanel: function (status, setting) { if (status == true) { if (this.guildsecretarea_start_crusade_panel == null) { this.guildsecretarea_start_crusade_panel = Utils.createClass("guildsecretarea_start_crusade_panel"); } this.guildsecretarea_start_crusade_panel.open(setting); } else { if (this.guildsecretarea_start_crusade_panel) { this.guildsecretarea_start_crusade_panel.close(); this.guildsecretarea_start_crusade_panel = null; } } }, //打開討伐成功失敗界面 openGuildsecretareaEndCrusadePanel: function (status, result, setting) { if (status == false) { if (this.guildsecretarea_end_crusade_panel != null) { this.guildsecretarea_end_crusade_panel.close() this.guildsecretarea_end_crusade_panel = null } } else { if (this.guildsecretarea_end_crusade_panel == null) { this.guildsecretarea_end_crusade_panel = GuildsecretareaEndCrusadePanel.New(result) } this.guildsecretarea_end_crusade_panel.open(setting) } }, //打開寶物獎勵展示界面 openGuildsecretareaRewardWindow: function (status, boss_id) { if (status == true) { if (this.guildsecretarea_raward_window == null) { this.guildsecretarea_raward_window = Utils.createClass("guildsecretarea_reward_window"); } this.guildsecretarea_raward_window.open(boss_id); } else { if (this.guildsecretarea_raward_window) { this.guildsecretarea_raward_window.close(); this.guildsecretarea_raward_window = null; } } }, __delete: function () { if (this.model != null) { this.model.DeleteMe() this.model = null } } }); module.exports = GuildsecretareaController;