"use strict"; cc._RF.push(module, '6f4f8aGlwpALr8z/UOPDqJS', 'planesafk_controller'); // Scripts/mod/pve/planesafk/planesafk_controller.js "use strict"; // // -------------------------------------------------------------------- // // 这里填写简要说明(必填), // // @author: lwc@syg.com(必填, 创建模块的人员) // // @editor: xxx@syg.com(必填, 后续维护以及修改的人员) // // @description: // // 位面改版 参考afk的 后端 国辉 策划 中建 // //
Create: 2020-02-05 //// -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var BattleConst = require("battle_const"); var PlanesafkConst = require("planesafk_const"); var MainuiEvent = require("mainui_event"); var PlanesafkEvent = require("planesafk_event"); var HeroController = require("hero_controller"); var RoleController = require("role_controller"); var BattleController = require("battle_controller"); var HeroEvent = require("hero_event"); var PlanesafkController = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, initConfig: function initConfig() { var PlanesafkModel = require("planesafk_model"); this.model = new PlanesafkModel(this); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() { if (!this.close_item_event) { this.close_item_event = gcore.GlobalEvent.bind(MainuiEvent.CLOSE_ITEM_VIEW, function (data) { if (this.model.getIsShowSearchFinish()) { this.model.setIsShowSearchFinish(false); } }.bind(this)); } }, registerProtocals: function registerProtocals() { this.RegisterProtocal(28600, this.handle28600); //操作指定格子事件 this.RegisterProtocal(28601, this.handle28601); //进入副本 this.RegisterProtocal(28602, this.handle28602); //基础数据信息 this.RegisterProtocal(28603, this.handle28603); //该层格子数据信息 this.RegisterProtocal(28604, this.handle28604); //进入下一层 this.RegisterProtocal(28605, this.handle28605); //获得该层通关奖励 this.RegisterProtocal(28606, this.handle28606); //格子数据更新 this.RegisterProtocal(28607, this.handle28607); //获取对方阵容信息 this.RegisterProtocal(28608, this.handle28608); //战斗结果 this.RegisterProtocal(28609, this.handle28609); //回血事件英雄变换 this.RegisterProtocal(28610, this.handle28610); //计算变阵后总战力 this.RegisterProtocal(28611, this.handle28611); //保存阵法 this.RegisterProtocal(28612, this.handle28612); //请求阵法 this.RegisterProtocal(28613, this.handle28613); //英雄背包 this.RegisterProtocal(28614, this.handle28614); //事件信息返回 this.RegisterProtocal(28615, this.handle28615); //对话Id this.RegisterProtocal(28620, this.handle28620); //buff列表 this.RegisterProtocal(28621, this.handle28621); //商人列表 this.RegisterProtocal(28622, this.handle28622); //英雄租借 this.RegisterProtocal(28623, this.handle28623); //查看英雄信息 this.RegisterProtocal(28624, this.handle28624); //领取奖励更新 this.RegisterProtocal(28625, this.handle28625); //本日已领取奖励 this.RegisterProtocal(28616, this.handle28616); //位面战令基础信息 this.RegisterProtocal(28617, this.handle28617); //一键领取等级礼包 this.RegisterProtocal(28618, this.handle28618); //周期重置红点 this.RegisterProtocal(28619, this.handle28619); //是否要弹窗 this.RegisterProtocal(28626, this.handle28626); //日记要求 }, reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; // 配置加载 var cfgs = ["planes_data", // 位面征战 "planes_war_order_data" // 位面征战战令 ]; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqPlaneData(_cb); }); }, checkIsOpen: function checkIsOpen() { var open_config = game.configs.planes_data.data_const.planes_open_lev; if (open_config == null) return null; var ret = nx.bridge.checkConditions(["lev", open_config.val]); return ret; }, reqPlaneData: function reqPlaneData(_cb) { // 功能解锁检查 var is_open = this.checkIsOpen(); // 锁定中不请求数据 if (nx.dt.objNEmpty(is_open)) { nx.dt.fnInvoke(_cb, true); return; } this.SendProtocal(28602, {}, _cb); this.SendProtocal(28616, {}); }, sender28626: function sender28626() { this.SendProtocal(28626, {}); }, handle28626: function handle28626() { // body }, // 操作指定格子事件 //is_fight 是否进入战斗 sender28600: function sender28600(line, index, action, ext_list, extend, is_fight) { var protocal = {}; protocal.line = line; protocal.index = index; protocal.action = action; protocal.ext_list = ext_list || {}; this.evt_extend = extend; // 额外数据 if (is_fight) { //本次是申请进入战斗的 var delay_time = 0.4; if (this.planesafk_main_window) { var is_hide = this.planesafk_main_window.updateScrollviewByIndex(line, index); if (is_hide) { this.planesafk_main_window.isLockPlanesMapScreen(true); // 解除锁屏 } else { delay_time = 0; } } if (delay_time == 0) { this.SendProtocal(28600, protocal); } else { if (this.planesafk_main_window) { this.planesafk_main_window.isLockPlanesMapScreen(false); // 解除锁屏 } this.SendProtocal(28600, protocal); } } else { this.SendProtocal(28600, protocal); } }, handle28600: function handle28600(data) { // 事件成功,可能需要做一些表现(例如buff图标动画) if (data.code == 1 && this.evt_extend && this.evt_extend.data && this.evt_extend.data.line == data.line && this.evt_extend.data.index == data.index) { if (this.evt_extend.buff_id) { // 选择buff成功,播放飘动动画 gcore.GlobalEvent.fire(PlanesafkEvent.Chose_Buff_Event, this.evt_extend.buff_id); this.openPlanesafkBuffChoseWindow(false); } this.evt_extend = null; } }, // 主动触发格子事件(必须在场景地图内) initiativeTriggerEvtByIndex: function initiativeTriggerEvtByIndex(line, index) { if (!line || line == 0) { return; } if (!index || index == 0) { return; } if (!this.planesafk_main_window) { return; } var evt_vo = this.getMapEvtData(line, index); //暂时只触发buff事件 if (evt_vo && evt_vo.evt_config && evt_vo.evt_config.type == PlanesafkConst.Evt_Type.Buff) { this.onHandlePlanesEvtById(evt_vo.evt_config.type, { line: line, index: index }); } }, //-----------------@ 处理事件 // evt_type:事件类型 index:格子索引 // function PlanesafkController:onHandlePlanesEvtById( evt_type, line, index, is_black ) //data 28603协议返回的单个list数据 //data.evt_config //game.configs.PlanesData.data_evt_info[this.data.evt_id] onHandlePlanesEvtById: function onHandlePlanesEvtById(evt_type, data) { if (!data) { return; } if (evt_type == PlanesafkConst.Evt_Type.Normal) {// 空事件 // 无需处理 } else if (evt_type == PlanesafkConst.Evt_Type.Monster) { // 怪物 this.openPlanesafkMasterWindow(true, data); } else if (evt_type == PlanesafkConst.Evt_Type.Guard) { // 守卫 this.openPlanesafkMasterWindow(true, data); } else if (evt_type == PlanesafkConst.Evt_Type.Recover) { // 英雄恢复(回复泉水) // if (this.model.getAllPlanesHeroData() != null) { //英雄信息回来了才响应事件 var cfg = { btn_str: nx.text.getKey("btn_planesafk_soak"), res_id: "board_img_7", title: nx.text.getKey("lab_planesafk_reply_title") }; var config = gdata("planes_data", "data_const", "cure_desc"); if (config) { cfg.desc_1 = config.desc; } else { cfg.desc_1 = nx.text.getKey("msg_planesafk_soak_tip"); } this.openPlanesafkBoardWindow(true, PlanesafkConst.Recover_Id, data, { board_cfg: cfg }); // } } else if (evt_type == PlanesafkConst.Evt_Type.Revive) { // 英雄恢复(复活祭坛) // if (this.model.getAllPlanesHeroData() != null) { //英雄信息回来了才响应事件 var cfg = { btn_str: nx.text.getKey("btn_planesafk_resurrection"), res_id: "board_img_4", title: nx.text.getKey("lab_planesafk_resurrection_title") }; var config = gdata("planes_data", "data_const", "reborn_desc"); if (config) { cfg.desc_1 = config.desc; } else { cfg.desc_1 = nx.text.getKey("msg_planesafk_resurrection_tip"); //TI18N("可以随机复活一位已阵亡的英雄并回复其
70%
的生命值,若当前无阵亡英雄则回复生命值最低的一位英雄
100%
的生命。") } this.openPlanesafkBoardWindow(true, PlanesafkConst.Revive_Id, data, { board_cfg: cfg }); // } } else if (evt_type == PlanesafkConst.Evt_Type.LeaseHero) { // 租借英雄 this.sender28600(data.line, data.index, 0, {}); } else if (evt_type == PlanesafkConst.Evt_Type.Buff) { // buff列表 this.sender28600(data.line, data.index, 0, {}); } else if (evt_type == PlanesafkConst.Evt_Type.Businessman) { // 商人 this.sender28600(data.line, data.index, 0, {}); } }, // 事件信息返回 对应旧位面的 23108 handle28614: function handle28614(data) { if (data.ext_list && Utils.next(data.ext_list) != null) { var dic_type = {}; for (var k in data.ext_list) { var v = data.ext_list[k]; if (dic_type[v.type] == null) { dic_type[v.type] = {}; } if (v.type == 1) { //buff选择 if (dic_type[v.type].buff_bid_list == null) { dic_type[v.type].buff_bid_list = []; } dic_type[v.type].buff_bid_list.push(v.val1); //需调试 } } for (var _type in dic_type) { if (_type == 1) { //buff选择 var v = dic_type[_type]; this.openPlanesafkBuffChoseWindow(true, v.buff_bid_list, data); } } } }, // if evt_vo.config.type == PlanesConst.Evt_Type.Dialog and dialog_id { // 对话 // var dialog_cfg = game.configs.SecretDunData.data_dialogue[dialog_id] // if dialog_cfg { // MonopolyController:getInstance():openMonopolyDialogWindow(true, 88, data.index, dialog_cfg) // } // else if ( evt_vo.config.type == PlanesConst.Evt_Type.Board and board_bid { // 广告牌 // this.openPlanesBoardWindow(true, board_bid) // else if ( evt_vo.config.type == PlanesConst.Evt_Type.Buff and Utils.next(buff_bid_list) ~= null { // buff选择 // this.openPlanesBuffChoseWindow(true, buff_bid_list, data.index) // } // 进入副本 sender28601: function sender28601() { if (!PlanesafkController.getInstance().checkPlanesIsOpen()) { return; } var protocal = {}; this.SendProtocal(28601, protocal); }, handle28601: function handle28601(data) { if (data.flag) { // BattleConst.Fight_Type.PlanesWar = 40 BattleController.getInstance().requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.PlanesWar); } }, // 基础数据信息 sender28602: function sender28602() { var protocal = {}; this.SendProtocal(28602, protocal); }, handle28602: function handle28602(data) { this.model.setPlanesRoleLookId(data.look_id); this.model.setHolidayOpen(data.is_holiday); this.model.setCdTime(data.update_time); gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Main_Base_Info_Event, data); }, // 地图信息 sender28603: function sender28603() { var protocal = {}; this.SendProtocal(28603, protocal); }, handle28603: function handle28603(data) { if (!this.is_first_open) { this.is_first_open = true; this.model.checkPlaneafkCanExploreRedPoint(data); } if (data.floor == 0) { this.openPlanesafkOrderactionWindow(false); this.openPlanesafkEndWarnView(false); this.openBuyCardView(false); this.openPlanesafkBoardWindow(false); this.openPlanesafkMasterWindow(false); this.openPlanesafkItemUsePanel(false); this.openPlanesafkHeroListPanel(false); this.openPlanesafkBuffChoseWindow(false); this.openPlanesafkBuffListPanel(false); this.openPlanesafkHireHeroWindow(false); this.openPlanesafkMainWindow(false); //最后才关闭主界面 return; } if (data.floor == 1) { this.model.setIsShowSearchFinish(false); } this.model.setMapData(data); this.model.updateRolePos(data); gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Main_Map_Info_Event, data); }, //领取奖励更新 handle28624: function handle28624(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Last_Reward_Info_Event, data); }, // 本日已领取 sender28625: function sender28625() { var protocal = {}; this.SendProtocal(28625, protocal); }, handle28625: function handle28625(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Update_Get_Reward_Event, data); }, // 进入下一层 sender28604: function sender28604(floor, difficulty) { var protocal = {}; protocal.floor = floor; protocal.difficulty = difficulty; this.SendProtocal(28604, protocal); }, handle28604: function handle28604(data) { nx.tbox(data.msg); if (data.flag == 1) { this.openPlanesafkMainWindow(true); gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Next_Map_Info_Event, data); } }, // 获取通关奖励 sender28605: function sender28605(floor) { var protocal = {}; protocal.floor = floor; this.SendProtocal(28605, protocal); }, handle28605: function handle28605(data) { nx.tbox(data.msg); if (data.flag == 1) { gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Pass_Reward_Info_Event, data); } }, // 格子数据更新 handle28606: function handle28606(data) { this.model.updateRolePos(data); gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Update_Map_Info_Event, data); }, // 对方阵容数据 handle28607: function handle28607(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Get_Master_Data_Event, data); }, // 战斗结果 handle28608: function handle28608(data) { nx.bridge.vset("ResultInfo", data); }, // 更新英雄血量数据 //回血事件英雄变换 handle28609: function handle28609(data) { if (data.partners && Utils.next(data.partners) != null) { this.model.updateMyHeroData(data.partners); } }, // 请求上阵英雄战力总和 计算变阵后总战力 sender28610: function sender28610(partner_ids) { var protocal = {}; protocal.partner_ids = partner_ids; this.SendProtocal(28610, protocal); }, handle28610: function handle28610(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Update_Form_Atk_Event, data.power); }, // 请求保存阵法 sender28611: function sender28611(formation_type, pos_info, hallows_id) { var protocal = {}; protocal.formation_type = formation_type; protocal.pos_info = pos_info; protocal.hallows_id = hallows_id; this.SendProtocal(28611, protocal); }, handle28611: function handle28611(data) { if (data.msg != "") { nx.tbox(data.msg); } if (data.flag == 1) { nx.tbox("msg_saveForm"); gcore.GlobalEvent.fire(PlanesafkEvent.Save_Form_Success_Event); } }, // 请求位面阵容 sender28612: function sender28612() { this.SendProtocal(28612, {}); }, handle28612: function handle28612(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Get_Form_Data_Event, data); gcore.GlobalEvent.fire(HeroEvent.Update_Fun_Form, data); }, // 请求英雄背包数据 sender28613: function sender28613() { this.SendProtocal(28613, {}); }, handle28613: function handle28613(data) { this.model.setAllPlanesHeroData(data.partners); gcore.GlobalEvent.fire(PlanesafkEvent.Get_All_Hero_Event); gcore.GlobalEvent.fire(PlanesafkEvent.Get_Hero_Live_Event); }, // 触发剧情对话 对应旧位面 23111 handle28615: function handle28615(data) { // 待处理//“lwc }, // 请求所有buff列表 sender28620: function sender28620() { this.SendProtocal(28620, {}); }, handle28620: function handle28620(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Get_Buff_Data_Event, data.buffs); }, // 返回商人信息 handle28621: function handle28621(data) { // if (this.planesafk_evt_shop_panel) { // gcore.GlobalEvent.fire(PlanesafkEvent.Evt_Shop_Event, data) // } // else // { this.openPlanesafkEvtShopPanel(true, data); // } }, // 返回租借英雄事件的数据 handle28622: function handle28622(data) { this.openPlanesafkHireHeroWindow(true, data); }, sender28623: function sender28623(pos) { var protocal = {}; protocal.pos = pos; this.SendProtocal(28623, protocal); }, handle28623: function handle28623(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Look_Other_Hero_Event, data); }, // 打开雇佣英雄界面 openPlanesafkHireHeroWindow: function openPlanesafkHireHeroWindow(status, data) { if (status) { nx.bridge.createPanel("WndPlanesafkHire", data); } else { nx.bridge.closePanel("WndPlanesafkHire"); } }, getMapEvtData: function getMapEvtData(line, index) { if (this.planesafk_main_window) { return this.planesafk_main_window.getMapEvtData(line, index); } }, //打开位面冒险主界面 openPlanesafkMainWindow: function openPlanesafkMainWindow(status, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkMain", setting); } else { nx.bridge.closePanel("WndPlanesafkMain"); } }, // 打开位面遗物列表 openPlanesafkBuffListPanel: function openPlanesafkBuffListPanel(status, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkBuffList", setting); } else { nx.bridge.closePanel("WndPlanesafkBuffList"); } }, // 打开buff选择界面 openPlanesafkBuffChoseWindow: function openPlanesafkBuffChoseWindow(status, buff_list, data) { if (status) { nx.bridge.createPanel("WndPlanesafkBuffChoose", { buff_list: buff_list, data: data }); } else { nx.bridge.closePanel("WndPlanesafkBuffChoose"); } }, // 打开位面英雄列表 openPlanesafkHeroListPanel: function openPlanesafkHeroListPanel(status, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkHeroList", setting); } else { nx.bridge.closePanel("WndPlanesafkHeroList"); } }, // 打开使用道具 openPlanesafkItemUsePanel: function openPlanesafkItemUsePanel(status, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkUseItem", setting); } else { nx.bridge.closePanel("WndPlanesafkUseItem"); } }, // 打开位面商人 openPlanesafkEvtShopPanel: function openPlanesafkEvtShopPanel(status, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkEvtShop", setting); } else { nx.bridge.closePanel("WndPlanesafkEvtShop"); } }, // 打开敌方阵容界面 openPlanesafkMasterWindow: function openPlanesafkMasterWindow(status, data) { if (status) { nx.bridge.createPanel("WndPlanesafkMasterInfo", data); } else { nx.bridge.closePanel("WndPlanesafkMasterInfo"); } }, openPlanesafkBoardWindow: function openPlanesafkBoardWindow(status, id, data, setting) { if (status) { nx.bridge.createPanel("WndPlanesafkEvts", { id: id, data: data, setting: setting }); } else { nx.bridge.closePanel("WndPlanesafkEvts"); } }, //-----------------------------------------位面战令活动--------------------------------------------- // 战令基本信息 sender28616: function sender28616() { var protocal = {}; this.SendProtocal(28616, protocal); }, handle28616: function handle28616(data) { this.model.setOrderactionData(data); this.model.checkPlanesafkRedPoint(); //gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_OrderAction_Init_Event, data) }, //一键领取礼包 sender28617: function sender28617(id) { var protocal = {}; protocal.id = id; this.SendProtocal(28617, protocal); }, handle28617: function handle28617(data) { if (data) { nx.tbox(data.msg); } }, //红点 sender28618: function sender28618() { var protocal = {}; this.SendProtocal(28618, protocal); }, handle28618: function handle28618(data) { if (data) { this.model.setOrderactionRedStatus(data.flag); this.model.checkPlanesafkRedPoint(); } gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_OrderAction_First_Red_Event); }, //位面活动提示 sender28619: function sender28619() { var protocal = {}; this.SendProtocal(28619, protocal); }, handle28619: function handle28619(data) { gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_OrderAction_IsPopWarn_Event, data); }, //打开主界面 openPlanesafkOrderactionWindow: function openPlanesafkOrderactionWindow(status) { if (status == true) { var configlv = gdata("PlanesWarOrderData", "data_constant", "limit_lev"); //game.configs.PlanesWarOrderData.data_constant.limit_lev var configday = gdata("PlanesWarOrderData", "data_constant", "open_srv_day"); //game.configs.PlanesWarOrderData.data_constant.open_srv_day var open_srv_day = RoleController.getInstance().getModel().getOpenSrvDay(); var rolevo = RoleController.getInstance().getModel().getRoleVo(); // 是否开启planes_war_order_data: if (configday && configlv && rolevo && (open_srv_day < configday.val || rolevo.lev < configlv.val)) { nx.tbox(string.format(nx.text.getKey("msg_planesafk_open_tip"), configlv.val, configday.val)); return; } if (!this.planesafk_orderaction_window) { this.planesafk_orderaction_window = Utils.createClass("planesafk_orderaction_window", this); //this.planesafk_orderaction_window = new PlanesafkOrderactionWindow() } this.planesafk_orderaction_window.open(); } else { if (this.planesafk_orderaction_window) { this.planesafk_orderaction_window.close(); this.planesafk_orderaction_window = null; } } }, //购买进阶卡 openBuyCardView: function openBuyCardView(status) { if (status == true) { if (!this.buy_card_view) { this.buy_card_view = Utils.createClass("planesafk_orderaction_untie_reward_window", this); //this.buy_card_view = new PlanesafkOrderactionUntieRewardWindow() } this.buy_card_view.open(); } else { if (this.buy_card_view) { this.buy_card_view.close(); this.buy_card_view = null; } } }, //打开活动结束警告界面 openPlanesafkEndWarnView: function openPlanesafkEndWarnView(status, day) { if (status == true) { if (!this.end_warn_view) { this.end_warn_view = Utils.createClass("planesafk_orderaction_end_warn_window", this); //this.end_warn_view = new PlanesafkOrderActionEndWarnWindow() } this.end_warn_view.open(day); } else { if (this.end_warn_view) { this.end_warn_view.close(); this.end_warn_view = null; } } }, //-----------------------------------------位面战令活动end--------------------------------------------- // 位面功能是否开启 checkPlanesIsOpen: function checkPlanesIsOpen(not_tips) { var role_vo = RoleController.getInstance().getRoleVo(); var limit_lv_cfg = gdata("planes_data", "data_const", "planes_open_lev"); //game.configs.PlanesData.data_const["planes_open_lev"] if (limit_lv_cfg) { if (role_vo.lev >= limit_lv_cfg.val) { return true; } else { if (!not_tips) { nx.tbox(limit_lv_cfg.desc); } return false; } } else { return false; } }, __delete: function __delete() { if (this.model != null) { this.model.deleteMe(); this.model = null; } } }); module.exports = PlanesafkController; cc._RF.pop();