"use strict"; cc._RF.push(module, '62167uC4DxBcKgCTRWlKWsl', 'battle_controller'); // Scripts/mod/battle/battle_controller.js "use strict"; // @author: xxx@syg.com(必填, 创建模块的人员) // -------------------------------------------------------------------- // @description: // 战斗控制器 //
Create: 2018-11-28 19:19:19 // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var BattleEvent = require("battle_event"); var BattleConst = require("battle_const"); var MainuiEvent = require("mainui_event"); var BattleRolePool = require("battle_role_pool"); var FID = require("bridge.function.ids"); var BattleController = cc.Class({ "extends": BridgeController, name: "BattleController", // 销毁 onDestroy: function onDestroy() { // 强制清除scene this.openDramaFightUI(false); this.model.closeFormView(); this.clearBattleScene(); if (BattleRolePool.getInstance) { BattleRolePool.getInstance().clearCachePool(); delete BattleRolePool.instance; BattleRolePool.instance = null; } this._super(); }, // 初始化配置数据 initConfig: function initConfig() { this.model = Utils.createClass("battle_model"); this.hook_model = Utils.createClass("battle_hook_model"); this.model.initConfig(); this.hook_model.initConfig(); this.is_watch_replay = false; // 是否属于观战状态 this.is_unlock_chapter = false; // 是否解锁章节中 this.is_normal_battle = false; // 是否是真战斗 this.finish_result_view_list = {}; // 胜利面板列表 this.finish_fail_view_list = {}; // 失败面板列表; this.cache_list = []; //缓存界面列表 this.is_watch_witness = false; // --是否为观战状态 this.init_fight_status = false; this.circle_round_data = null; // --挂机缓存数据 this.cur_fight_type = 0; this.is_battle_start = false; //--是否已进入战斗状态 this.is_pk_battle = false; //--是否切磋状态 this.extend_fight_type = BattleConst.Fight_Type.Darma; //--额外的战斗类型记录 this.fighting_type_list = {}; this.is_drama_result = false; this.sum_lev = 0; // --己方总等级 this.enemy_lev = 0; //--敌方总等级 //关于假数据 this.is_battle_hook_wait = false; //开始假挂机数据等待 this.battle_test_data = {}; this.is_test_skip = false; //特殊·结算 this.special_results = {}; }, // 返回当前的model getModel: function getModel() { return this.model; }, // 假战斗数据 getHookModel: function getHookModel() { return this.hook_model; }, // 注册监听事件 registerEvents: function registerEvents() { if (this.loading_enter_scene == null) { this.loading_enter_scene = gcore.GlobalEvent.bind(MainuiEvent.LOADING_ENTER_SCENE, function () { this.showCachePanel(); }.bind(this)); } //请求进入竞技场之前,需要告诉服务器,我要进去了,有没有真是战斗,快点告诉我 if (this.combat_type_back_event == null) { this.combat_type_back_event = gcore.GlobalEvent.bind(BattleEvent.COMBAT_TYPE_BACK, function (combat_type, type) { if (type === 0) { //不存在战斗 this.openRelevanceWindowAtOnce(combat_type); } // else{ // let config = game.configs.combat_type_data.data_fight_list[combat_type]; // if(config && config.des){ // let tip = cc.js.formatStr(nx.text.getKey("battle_loading_tip"),config.des); // return nx.tbox(tip); // } // } }, this); } // 退出战斗需要打开进入战斗之前的一些窗体 if (!this.battle_exit_event) { this.battle_exit_event = gcore.GlobalEvent.bind(EventId.EXIT_FIGHT, function (combat_type) { this.openRelevanceWindowAtOnce(combat_type); }.bind(this)); } }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(20027, this.scInitFightStart); // 战斗真正初始化数据,从0到1的战斗 this.RegisterProtocal(20001, this.handle20001); this.RegisterProtocal(20002, this.scRoundFightStart); // 回合开始的播报 -- 包含回合开始的buff this.RegisterProtocal(20004, this.scRoundFightOn); // 回合中的播报 -- 包含回合结束buff和效果播报的buff this.RegisterProtocal(20006, this.scFightEnd); // 战斗结算的,也就是真是战斗结束的 this.RegisterProtocal(20008, this.scFightExit); // 退出战斗 this.RegisterProtocal(20009, this.scSkipFirstTeam); // 跳过一队 this.RegisterProtocal(20013, this.scReBattleFight); // 战斗重连,切进战斗或者短线重连的战斗 this.RegisterProtocal(20014, this.scBattlePk); // 战斗切磋请求 this.RegisterProtocal(20015, this.scBattlePkRe); // 战斗切磋返回 this.RegisterProtocal(20016, this.scBattlePkTwice); // 战斗切磋同意 this.RegisterProtocal(20020, this.scRoundNextFight); // 下一波怪物 this.RegisterProtocal(20022, this.scFightSpeed); // 改变播放速度 this.RegisterProtocal(20029, this.scRecordBattle); // 看录像 this.RegisterProtocal(20033, this.handle20033); // 切磋结算 this.RegisterProtocal(20034, this.handle20034); // 切磋视频分享 this.RegisterProtocal(20036, this.handle20036); // 观看跨服录像,最后应该29协议全部转到这一条 this.RegisterProtocal(20060, this.handle20060); // 请求战斗类型返回,这个时候只需要做对应ui操作的 this.RegisterProtocal(20061, this.handle20061); // 假战斗初始化的,如果触发这个数据但是实际上是在真战斗中的时候,不做处理 this.RegisterProtocal(20062, this.handle20062); // 跳过战斗 this.RegisterProtocal(20063, this.handle20063); this.RegisterProtocal(20064, this.handle20064); //直接请求通关 this.RegisterProtocal(20065, this.handle20065); //新版战斗总回合数 this.RegisterProtocal(20066, this.handle20066); //无尽试炼下波次上报 this.RegisterProtocal(20070, this.handle20070); this.RegisterProtocal(20080, this.handle20080); }, reqBaseFromServer: function reqBaseFromServer(_cb) { // 配置加载 var cfgs = ["battle_act_data", // 英雄战斗模型 "battle_bg_data", // 战斗场景 "buff_data", // buff "combat_halo_data", // 阵容光环配置 "combat_type_data", // 战斗配置(类型、天平模式、倍速等) "battle_lens_data"]; this.loadConfigs(cfgs, function (_ret, _data) { nx.dt.fnInvoke(_cb, true); }); }, openDramaFightUI: function openDramaFightUI(status) { if (this.show_fight_ui_status == status && this.fight_ui_combat == this.model.getFightStatus()) { return; } this.show_fight_ui_status = status; this.fight_ui_combat = this.model.getFightStatus(); if (!status) { nx.bridge.closePanel("WndBattleHook"); this.model.setBattleListPanelTime(); } else { nx.bridge.createPanel("WndBattleHook", { is_real_combat: this.model.getFightStatus() }); this.model.setBattleListPanelTime(0); } this.setIsNormaBattle(this.model.getFightStatus()); this.model.startCountDownToDelete(); }, // 是否在战斗中 isInFight: function isInFight() { return this.model.getFightStatus(); }, // 是否有战斗场景 hadBattleScene: function hadBattleScene() { return this.model.getBattleScene() != null; }, // 设置战斗场景的状态 handleBattleSceneStatus: function handleBattleSceneStatus(status) { this.model.handleBattleSceneStatus(status); }, handle20001: function handle20001(data) {}, // 根据战斗类型请求数据,r如果是切出战斗的话 则 combat_type:BattleConst.Fight_Type.Nil send20060: function send20060(combat_type, _cb) { var protocal = { combat_type: combat_type }; this.SendProtocal(20060, protocal, _cb); //新版战斗需要清除参数 if (this.isInFight()) {} }, // 返回战斗状态, handle20060: function handle20060(data) { if (data.combat_type == 0) { // 这个就是切出战斗, this.clearBattleScene(); } else {} gcore.GlobalEvent.fire(BattleEvent.COMBAT_TYPE_BACK, data.combat_type, data.type); }, send20070: function send20070(id, _cb) { var protocal = { id: id }; this.SendProtocal(20070, protocal, _cb); }, // 返回战斗状态, handle20070: function handle20070(data) { if (!this.isGoodData(data)) { return; } if (data.id != null) { this.show_bat_id = data.id; } }, getShowBatID: function getShowBatID() { return this.show_bat_id; }, OutResult: function OutResult() { this.SendProtocal(20080, {}); }, handle20080: function handle20080(_data) { if (!this.isGoodData(_data)) { return; } }, handle20063: function handle20063(data) { if (data.type_list) { this.in_bat_list = data.type_list; } }, send20064: function send20064(combat_type) { var protocal = { combat_type: combat_type }; this.SendProtocal(20064, protocal); }, handle20064: function handle20064(data) { console.log(data); }, handle20065: function handle20065(data) {}, send20066: function send20066(wave) { var protocal = { wave: wave }; this.SendProtocal(20066, protocal); }, handle20066: function handle20066(data) {}, waitOvertimeBattleHook: function waitOvertimeBattleHook() { var _this = this; if (!this.connect_timer) { this.connect_timer = gcore.Timer.set(function () { if (_this.is_battle_hook_wait) { _this.is_battle_hook_wait = false; //关闭 gcore.GlobalEvent.fire(BattleEvent.COMBAT_TYPE_BACK, 3, 2); //锁定假战斗 } }, 1000, 1); } }, pushBattleResultData: function pushBattleResultData(data) {}, // 战斗结算的,也有可能不需要出结算面板 scFightEnd: function scFightEnd(data) { if (data.show_panel_type == 1 || data.combat_type == BattleConst.Fight_Type.LadderWar) { nx.bridge.vset("ResultInfo", data); } var is_replay = false; if (data.combat_type > 1000) { data.combat_type = data.combat_type - 1000; is_replay = true; } this.model.showWin(data, is_replay); }, // 清理战斗场景,在退出战斗或者战斗结算之后,如果个战斗是剧情副本的战斗,那么就不需要清理掉场景,而是直接切换到假战斗 clearBattleScene: function clearBattleScene() { this.model.clearBattleScene(); }, // 请求切出战斗 requestCutOutBattle: function requestCutOutBattle(_cb) { this.send20060(BattleConst.Fight_Type.Nil, _cb); }, // 战斗初始化数据 scInitFightStart: function scInitFightStart(data) { var skip = nx.storage.get("vip_skip"); if (Number(skip) == 1) return; if (this.is_test_skip) { this.is_test_skip = false; return; } if (BattleConst.canDoBattle(data.combat_type)) { if (data.combat_type == 35 || data.combat_type == 27) {//组队竞技场 //加一个开始标志 // this.model.setInitFightData( data ); } else { // this.model.setArenaTeamStart( false ); } // if( this.model.isArenaTeamStart() ) return; //设置最大回合数 // this.model.setMaxActionCount( game.configs.combat_type_data.data_fight_list[ data.combat_type ].max_action_count ); this.model.updateCurBattleData(data, true); this.prepareLoaderBattleScene(data.combat_type, 2); } }, // 切进战斗 scReBattleFight: function scReBattleFight(data) { if (BattleConst.canDoBattle(data.combat_type)) { this.model.updateCurBattleData(data, false); this.prepareLoaderBattleScene(data.combat_type, 2); } }, // 回合开始的播报 scRoundFightStart: function scRoundFightStart(data) { if (nx.dt.objEmpty(data)) return; nx.debug("回合开始播报"); this.model.playRoundStart(data); }, // 回合中的播报 scRoundFightOn: function scRoundFightOn(data) { if (nx.dt.objEmpty(data)) return; nx.debug("回合播报"); this.model.playRoundIn(data); }, // 回合播报结束通知服务端,对应的是20004 csSkillPlayEnd: function csSkillPlayEnd() { nx.debug("20004 播报完成"); this.SendProtocal(20005, {}); }, // 回合开始播报完成之后,通知服务端,对应的是20002 csRoundFightEnd: function csRoundFightEnd() { nx.debug("20002 播报完成"); this.SendProtocal(20019, {}); }, // 战斗初始化完成之后 csReadyFightStart: function csReadyFightStart() { nx.debug("战斗初始化完成,通知服务端可以开始播报了"); this.SendProtocal(20001, {}); }, // 请求跳过战斗 send20062: function send20062() { this.SendProtocal(20062, {}); }, handle20062: function handle20062(data) { if (!this.isGoodData(data)) { return; } }, // 假战斗数据 handle20061: function handle20061(data) { cc.log("假战斗数据"); //清除假数据 this.is_battle_hook_wait = false; if (this.connect_timer) { gcore.Timer.del(this.connect_timer); this.connect_timer = null; } if (this.hook_model) { this.hook_model.updateUnrealBattleData(data); } this.prepareLoaderBattleScene(data.combat_type, 1); // } }, csRecordBattle: function csRecordBattle(replay_id) { var protocal = {}; protocal.replay_id = replay_id; this.SendProtocal(20029, protocal); }, // 战斗录像,这里只是记录战斗录像状态 scRecordBattle: function scRecordBattle(data) { nx.tbox(data.msg); if (data.code == 1) { this.setWatchReplayStatus(true); } }, // 切磋结果返回 handle20033: function handle20033(data) { if (data.combat_type == null) { data.combat_type = BattleConst.Fight_Type.PK; } if (data.show_panel_type == null) { data.show_panel_type = 2; nx.bridge.vset("ResultInfo", data); } this.model.showWin(data); }, newPKResultWin: function newPKResultWin() { // if( !this.battle_pk_result_data ) return; // let data = this.battle_pk_result_data; // if( data.combat_type == null ) { // data.combat_type = BattleConst.Fight_Type.PK; // } // if( data.show_panel_type == null ) { // data.show_panel_type = 1 // } // this.model.showWin( this.battle_pk_result_data ); // this.battle_pk_result_data = null; }, // 分享切磋视频 on20034: function on20034(replay_id, channel, target_name, share_type) { var protocal = {}; protocal.replay_id = replay_id; protocal.channel = channel; protocal.target_name = target_name; protocal.share_type = share_type; this.SendProtocal(20034, protocal); }, handle20034: function handle20034(data) { nx.tbox(data.msg); }, /** * 切换进战斗的唯一接口 * @param {*} combat_type * @param {*} in_fight_type 0:没有战斗 1:假战斗 2:真战斗 */ prepareLoaderBattleScene: function prepareLoaderBattleScene(combat_type, in_fight_type) { if (combat_type == 1) { //gm测试战斗 this.ui_fight_type = 1; } if (this.ui_fight_type == 0) return; if (this.model) { this.model.createBattleScene(in_fight_type, combat_type); // 进入战斗,抛出事件 if (in_fight_type == 2) { gcore.GlobalEvent.fire(EventId.ENTER_FIGHT, combat_type, in_fight_type); } } }, /** * 下一波怪物的入口 * @param {*} data */ scRoundNextFight: function scRoundNextFight(data) { if (data) { this.model.upDateNextMon(data); } }, // 战斗每一帧更新 update: function update(dt) { // this.model.mapMovescheduleUpdate(dt); }, // 切换战斗背景移动状态,主要是用于真假剧情战斗切换 changeMoveMapStatus: function changeMoveMapStatus(status) { this.model.changeMoveMapStatus(); }, // 查看录像返回 sender_20036: function sender_20036(replay_id, replay_srv_id) { var protocal = { replay_id: replay_id, replay_srv_id: replay_srv_id }; this.SendProtocal(20036, protocal); }, handle20036: function handle20036(data) { if (data.code == 1) { this.setWatchReplayStatus(true); } }, // 退出战斗 csFightExit: function csFightExit() { this.SendProtocal(20008, {}); }, scFightExit: function scFightExit(data) { nx.tbox(data.msg); }, // 跳过一队 csSkipFirstTeam: function csSkipFirstTeam() { this.SendProtocal(20009, {}); }, scSkipFirstTeam: function scSkipFirstTeam(data) { nx.tbox(data.msg); }, // 是否是观战状态 getWatchReplayStatus: function getWatchReplayStatus() { return this.is_watch_replay; }, // 设置观战状态 setWatchReplayStatus: function setWatchReplayStatus(status) { this.is_watch_replay = status; }, // 是否是观战或者切磋状态 getIsClickStatus: function getIsClickStatus() { var combat_type = this.model.getCombatType(); return this.getWatchReplayStatus() || combat_type == BattleConst.Fight_Type.PK || combat_type == BattleConst.Fight_Type.HeroTestWar; }, setUnlockChapterStatus: function setUnlockChapterStatus(status) { this.is_unlock_chapter = status; }, getUnlockChapterStatus: function getUnlockChapterStatus() { return this.is_unlock_chapter; }, //进入主场景后显示缓存的界面 showCachePanel: function showCachePanel() { if (this.cache_list == null || this.cache_list.length <= 0) return; for (var i in this.cache_list) { if (this.cache_list[i]["function"]) { this.cache_list[i]["function"](); } } this.cache_list = []; }, //特殊結算 pushSpecialRetInfo: function pushSpecialRetInfo(combat_type, data) { this.special_results[combat_type] = data; //如果當前戰鬥就是目標戰鬥,那就直接結算 if (this.model.getCombatType() == 0) { //this.getIsSameBattleType(combat_type) || this.checkSpecialResults(); } }, //每次特殊結算界面關閉時,清除目標數據 delSpecialRetInfo: function delSpecialRetInfo(combat_type) { if (this.special_results[combat_type]) { console.log("特殊结算缓存清除"); delete this.special_results[combat_type]; } }, checkSpecialResults: function checkSpecialResults() { console.log("特殊结算展示"); for (var type in this.special_results) { nx.bridge.createPanel("WndSpecialSettle", { data: this.special_results[type] }); return; } }, // 战斗结算界面 openFinishView: function openFinishView(status, combat_type, data) { if (status == true) { if (!this.is_unlock_chapter) { if (combat_type == BattleConst.Fight_Type.LadderWar) { nx.storage.set("battleArena", FID.CrossLadder); gcore.GlobalEvent.fire(BattleEvent.DISPENSE_TYPE_RESLUT); } else if (combat_type == BattleConst.Fight_Type.Arean_Team) {//組隊競技場 // var ArenateamController = require("arenateam_controller") // ArenateamController.getInstance().openArenateamFightResultPanel(true, data) } else if (combat_type == BattleConst.Fight_Type.PK) {// PK // this.finish_result_view_list[combat_type] = Utils.createClass("battle_pk_result_window"); // this.finish_result_view_list[combat_type].open(data) } else if (combat_type == BattleConst.Fight_Type.Arena) { //自己有自己的结算界面 nx.storage.set("battleArena", FID.Arena); gcore.GlobalEvent.fire(BattleEvent.DISPENSE_TYPE_RESLUT); } else if (combat_type == BattleConst.Fight_Type.Adventrue) { var _data2 = nx.bridge.vget("ResultInfo"); this.model.result(_data2, null); nx.bridge.vset("ResultInfo", {}); } else if (combat_type == BattleConst.Fight_Type.Training_Camp) { nx.storage.set("battleArena", FID.NewTrain); // nx.bridge.createPanel( "WndTrainingCamp" ); } // else if(combat_type == 3 || combat_type == 7){ // if(data.result == 1){ // this.checkSpecialResults(combat_type); // }else{ // if( combat_type != 0 ){ // this.openOtherFinish( combat_type ); // } // } // } else { if (data.result == 1) { //设置不要马上显示升级 // LevupgradeController.getInstance().waitForOpenLevUpgrade(true) if (combat_type == 0) { gcore.GlobalEvent.fire(BattleEvent.DISPENSE_TYPE_RESLUT); return; } this.openOtherFinish(combat_type); } else { // cc.log( "打开失败界面" ) if (combat_type != 0) { this.openOtherFinish(combat_type); } } } } } else { if (this.finish_result_view_list[combat_type]) { this.finish_result_view_list[combat_type].close(); this.finish_result_view_list[combat_type] = null; } } }, getFinishView: function getFinishView(combat_type) { if (this.finish_result_view_list) { return this.finish_result_view_list[combat_type]; } }, //打开战斗伤害统计界面 openBattleHarmInfoView: function openBattleHarmInfoView(status, data) { // if (status == true) { // if (this.harm_info_view == null) { // this.harm_info_view = Utils.createClass("battle_harm_info_window"); // } // this.harm_info_view.open(data); // } else { // if (this.harm_info_view) { // this.harm_info_view.close(); // this.harm_info_view = null; // } // } }, //主要用于结算id不等于20006的结算功能 openOtherFinish: function openOtherFinish(combat_type) { if (this.getIsSameBattleType(combat_type)) { var data = nx.bridge.vget("ResultInfo"); if (data.result) { if (data.result == 1) { //成功 this.openWinFinishView(true, combat_type); // nx.bridge.Tag2PanelClose("WndWinSettle"); } else { //失败 this.openFailFinishView(true, combat_type); // nx.bridge.Tag2PanelClose("WndFailSettle"); } nx.bridge.vset("DailyPop", 1); } else {//不需要结算数据 } } }, openWinFinishView: function openWinFinishView(status, combat_type) { if (status) { if (!this.is_unlock_chapter) { //设置不要马上显示升级 var data = nx.bridge.vget("ResultInfo"); if (data.combat_type != combat_type) return; nx.bridge.createPanel("WndWinSettle", { combat_type: combat_type }); } else { this.battle_controller.send20060(BattleConst.Fight_Type.Darma); } } else { nx.bridge.closePanel("WndWinSettle"); nx.bridge.vset("ResultInfo", {}); } }, //失败结算界面 openFailFinishView: function openFailFinishView(status, combat_type) { if (status) { if (!this.is_unlock_chapter) { //设置不要马上显示升级 nx.bridge.createPanel("WndFailSettle", { combat_type: combat_type }); } else { this.battle_controller.send20060(BattleConst.Fight_Type.Darma); } } else { nx.bridge.closePanel("WndFailSettle"); nx.bridge.vset("ResultInfo", {}); } }, //获取是否相同的战斗类型 getIsSameBattleType: function getIsSameBattleType(combat_type) { return combat_type == this.model.getCombatType(); }, getIsInBattleing: function getIsInBattleing(combat_type) { for (var i in this.in_bat_list) { var type = this.in_bat_list[i]; if (type != 11 && combat_type == type) { //非无尽试炼 return true; } } return false; }, // -- 打开阵营详细面板 openBattleCampView: function openBattleCampView(status, form_id) { if (status == true) { nx.bridge.createPanel("WndBattkeCamp", { form_id: form_id }); } else { nx.bridge.closePanel("WndBattkeCamp"); } }, // 记录是否为假战斗的战斗 setIsNormaBattle: function setIsNormaBattle(status) { this.is_normal_battle = status; }, // 是否是假战斗.... getIsNoramalBattle: function getIsNoramalBattle() { return this.is_normal_battle; }, // 改变战斗速度 csFightSpeed: function csFightSpeed(speed) { var protocal = {}; protocal.speed = speed; this.SendProtocal(20022, protocal); }, scFightSpeed: function scFightSpeed(data) { if (data.code == 0) { nx.tbox(data.msg); } }, getCtrlBattleScene: function getCtrlBattleScene(cal_back) { var battle_scen = this.model.getBattleScene(); cal_back(battle_scen); }, getDramaFightUI: function getDramaFightUI(finish_cb) { if (finish_cb) { finish_cb(this.model.getDramaFightUI()); } else { if (this.model) return this.model.getDramaFightUI(); } }, // ---------------------切磋请求 csBattlePk: function csBattlePk(target_id, target_srv_id, is_province) { var protocal = {}; protocal.target_id = target_id; protocal.target_srv_id = target_srv_id; protocal.is_province = is_province; this.SendProtocal(20014, protocal); }, scBattlePk: function scBattlePk(data) { nx.tbox(data.msg); require("chat_controller").getInstance().closeChatPanel(false); require("friend_controller").getInstance().openFriendCheckPanel(false); }, // 被切磋对象,在18600收到提示之后,调用这个接口同意或者取消掉 confirmBattlePk: function confirmBattlePk(promptVo) {}, // 被切磋对象,同意切磋或者拒绝切磋 csBattlePkRe: function csBattlePkRe(bool, data) { var protocal = {}; protocal.target_id = data.target_id; protocal.target_srv_id = data.target_srv_id; protocal.is_agree = bool ? 1 : 0; this.SendProtocal(20015, protocal); }, scBattlePkRe: function scBattlePkRe(data) { nx.tbox(data.msg); }, // 目标这统一了自己发起的请求.这时候自己的二次确认 scBattlePkTwice: function scBattlePkTwice(data) { if (data) { if (!this.isInFight()) { var accept_fun = function () { this.csBattlePkTwiceConfirm(true, { target_srv_id: data.target_srv_id, target_id: data.target_id }); }.bind(this); var refuse_fun = function () { this.csBattlePkTwiceConfirm(false, { target_srv_id: data.target_srv_id, target_id: data.target_id }); }.bind(this); var desc = cc.js.formatStr(Utils.TI18N("玩家%s同意了你的切磋请求,点击”立即切磋“立即进入切磋战斗?"), data.target_name || ""); nx.mbox(desc, ["cancel", "confirm"], function (_key, _box) { if (_key == "cancel") { refuse_fun(); } else if (_key == "confirm") { accept_fun(); } }, "friend_str12"); } } }, // 发起者同意进战斗或者拒绝 csBattlePkTwiceConfirm: function csBattlePkTwiceConfirm(bool, data) { var protocal = {}; protocal.target_id = data.target_id; protocal.target_srv_id = data.target_srv_id; protocal.is_agree = bool ? 1 : 0; ; this.SendProtocal(20016, protocal); }, // 打开buff总览界面 openBattleBuffInfoView: function openBattleBuffInfoView(status, left_name, right_name) { if (status) { nx.bridge.createPanel("WndBattleBuffInfo", { left_name: left_name, right_name: right_name }); } else { nx.bridge.closePanel("WndBattleBuffInfo"); } }, // - 更新buff列表界面数据 updateBattleBuffListView: function updateBattleBuffListView(data, group, partner_bid) { if (this.buff_list_view && this.buff_list_view.checkIsChosedBuffList(group, partner_bid)) { this.buff_list_view.setData(data); } }, // -- 打开buff列表界面 openBattleBuffListView: function openBattleBuffListView(status, data, group, partner_bid) { if (status) { nx.bridge.createPanel("WndBattleBuffList", { data: data, group: group, partner_bid: partner_bid }); } else { nx.bridge.closePanel("WndBattleBuffList"); } }, openBattleView: function openBattleView(status, combat_type) { if (status) this.createMap(null, BattleConst.Fight_Type.Darma);else { if (this.resources_load) { this.resources_load.DeleteMe(); this.resources_load = null; } this.setCurFightType(0); this.send20060(0); this.circle_round_data = null; // 這個地方感覺需要判斷當前是不是在戰鬥中,否則這裡也會拋出退出戰鬥事件 this.clear(true); } }, clear: function clear(is_change) { this.model.clear(true); this.battle_hook_model.battleclear(); var is_detele = this.getExtendFightType() != BattleConst.Fight_Type.Darma || this.cur_fight_type == 0; if (this.battle_scene && !tolua.isnull(this.battle_scene)) { if (is_detele == true || is_change == true) { if (this.resources_load) { this.resources_load.DeleteMe(); this.resources_load = null; } this.battle_scene.cleanFightView(); this.battle_scene.destroy(); this.battle_scene = null; this.fight_type = null; } } }, setCurFightType: function setCurFightType(fight_type) { this.cur_fight_type = fight_type; }, /*****战斗面板切换 */ // 获取当前的面板 getUIFightType: function getUIFightType() { return this.ui_fight_type; }, // 设置当前面板数据 setUIFightType: function setUIFightType(value) { this.ui_fight_type = value; }, // 是否在剧情副本界面 checkIsInDramaUIFight: function checkIsInDramaUIFight() { return this.ui_fight_type == 4; }, // 请求打开战斗相关的窗体,同时也包含了剧情副本的 requestOpenBattleRelevanceWindow: function requestOpenBattleRelevanceWindow(battle_type, params, _cb) { this.relevance_ui_last_type = this.ui_fight_type; this.relevance_battle_type = battle_type; this.relevance_params = params; this.relevance_ui_fight_type = BattleConst.getUIFightByFightType(battle_type); this.setUIFightType(this.relevance_ui_fight_type); this.send20060(battle_type, _cb); }, // 还原之前的ui战斗类型,因为可能几个带战斗类型的面板互相调用 resetUIFightType: function resetUIFightType() { if (this.relevance_ui_last_type) { this.ui_fight_type = this.relevance_ui_last_type; this.relevance_ui_last_type = 0; } }, //新手演示和试用战斗触发 1 演示 2 试用 //id 英雄id 1默认试用 requestUseHeroBattle: function requestUseHeroBattle(type, id) { var _this2 = this; if (type === void 0) { type = 1; } if (id === void 0) { id = 1; } var fight_type = 44; if (type == 2) { fight_type = 45; } this.requestOpenBattleRelevanceWindow(fight_type, null, function (_data) { if (_data) { _this2.send20070(id); nx.bridge.plot.next(); } }); }, //打开关联窗体,这里针对世界boss又需要重新判断调整 openRelevanceWindowAtOnce: function openRelevanceWindowAtOnce(combat_type) { if (combat_type == BattleConst.Fight_Type.WorldBoss || combat_type == BattleConst.Fight_Type.SingleBoss) { if (this.relevance_battle_type != BattleConst.Fight_Type.WorldBoss && this.relevance_battle_type != BattleConst.Fight_Type.SingleBoss) return; } else { if (this.relevance_battle_type != combat_type) return; } if (combat_type == BattleConst.Fight_Type.GuildDun) { //公會boss nx.bridge.createPanel("WndGuildChallenge"); } else if (combat_type == BattleConst.Fight_Type.StarTower) { //試煉塔 nx.bridge.createPanel("WndStartower", {}); } else if (combat_type == BattleConst.Fight_Type.Arena) { //競技場 nx.bridge.createPanel("WndArenaLoopChallenge"); } else if (combat_type == BattleConst.Fight_Type.CrossChampion) { //跨服冠军赛 nx.bridge.createPanel("WndCrossChampionWorship"); } else if (combat_type == BattleConst.Fight_Type.Endless) { //無盡試煉 require("endless_trail_controller").getInstance().openEndlessMainWindow(true); } else if (combat_type == BattleConst.Fight_Type.ExpeditFight) { // require( "heroexpedit_controller" ).getInstance().openHeroExpeditView( true ) } else if (combat_type == BattleConst.Fight_Type.LadderWar) { //天梯賽 nx.bridge.createPanel("WndLadder"); } else if (combat_type == BattleConst.Fight_Type.DungeonStone) { //日常副本 nx.bridge.createPanel("WndDungeonMain", {}); } else if (combat_type == BattleConst.Fight_Type.GuildWar) { nx.bridge.createPanel("WndGuildBatMain", {}); } else if (combat_type == BattleConst.Fight_Type.Adventrue) { nx.bridge.createPanel("WndAdventureModel", {}); } else if (combat_type == BattleConst.Fight_Type.LimitExercise) { // require( "limitexercise_controller" ).getInstance().openLimitExerciseChangeView( true ) } else if (combat_type == BattleConst.Fight_Type.ElementWar) { //元素神殿 require("element_controller").getInstance().openElementMainWindow(true); } else if (combat_type == BattleConst.Fight_Type.PlanesWar) { //位面戰爭 nx.bridge.createPanel("WndPlanesafkMain", {}); } else if (combat_type == BattleConst.Fight_Type.Training_Camp) { // 新手训练营 nx.bridge.createPanel("WndTrainingCamp"); } else if (combat_type == BattleConst.Fight_Type.Arean_Team) {// 组队竞技场 // require( "arenateam_controller" ).getInstance().openArenateamMainWindow( true ) } else if (combat_type == BattleConst.Fight_Type.EliteMatchWar || combat_type == BattleConst.Fight_Type.EliteKingMatchWar) { nx.bridge.createPanel("WndEliteRankMain", {}); } else if (combat_type == BattleConst.Fight_Type.GuildSecretArea) {//公會秘境 // require( "guildsecretarea_controller" ).getInstance().openGuildsecretareaMainWindow( true, this.relevance_params ) } else if (combat_type == BattleConst.Fight_Type.HeavenWar) { //神裝副本 nx.bridge.createPanel("WndHeavenMain", {}); } else if (combat_type == BattleConst.Fight_Type.newYearBoss) { //陣營大戰 nx.bridge.createPanel("WndCampfightMain", {}); } this.relevance_battle_type = null; this.relevance_params = null; } /*****战斗面板切换 */ }); module.exports = BattleController; cc._RF.pop();