498 lines
17 KiB
JavaScript
498 lines
17 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'e8d7c26Iv5NxrbZP2BWe7mN', 'battle_drama_controller');
|
|
// Scripts/mod/battle_drama/battle_drama_controller.js
|
|
|
|
"use strict";
|
|
|
|
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 这里填写详细说明,主要填写该模块的功能简要
|
|
// <br/>Create: 2018-12-25 14:56:32
|
|
// --------------------------------------------------------------------
|
|
var BridgeController = require("bridge.controller");
|
|
var BattleEvent = require("battle_event");
|
|
var DramaEvent = require("battle_drama_event");
|
|
var BattleConst = require("battle_const");
|
|
var MainuiEvent = require("mainui_event");
|
|
// 桥接替换的界面
|
|
var BattleController = require("../battle/battle_controller");
|
|
var Battle_dramaController = cc.Class({
|
|
"extends": BridgeController,
|
|
properties: {
|
|
role_vo: null
|
|
},
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
var Battle_dramaModel = require("battle_drama_model");
|
|
this.model = new Battle_dramaModel();
|
|
this.model.initConfig();
|
|
this.cache_list = []; //缓存界面列表
|
|
|
|
this.is_ready_battle_drama = false; //开始准备等待挑战boss
|
|
},
|
|
|
|
// 返回当前的model
|
|
getModel: function getModel() {
|
|
return this.model;
|
|
},
|
|
// 注册监听事件
|
|
registerEvents: function registerEvents() {
|
|
this.create_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
|
|
gcore.GlobalEvent.unbind(this.create_role_event);
|
|
this.create_role_event = null;
|
|
var RoleController = require("role_controller");
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
|
}.bind(this));
|
|
if (this.loading_enter_scene == null) {
|
|
this.loading_enter_scene = gcore.GlobalEvent.bind(MainuiEvent.LOADING_ENTER_SCENE, function () {
|
|
this.showCachePanel();
|
|
}.bind(this));
|
|
}
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(13000, this.on13000); // 剧情副本数据
|
|
this.RegisterProtocal(13001, this.on13001); // 当前关卡信息
|
|
this.RegisterProtocal(13002, this.on13002); // 制作下一关
|
|
this.RegisterProtocal(13003, this.on13003); // 挑战BOSS
|
|
this.RegisterProtocal(13004, this.on13004); // 使用快速作战
|
|
this.RegisterProtocal(13006, this.on13006); // 剧情副本常规信息
|
|
this.RegisterProtocal(13007, this.on13007); // 快速作战收获物品展示以及收集金币显示
|
|
this.RegisterProtocal(13008, this.on13008); // 通关奖励显示
|
|
this.RegisterProtocal(13009, this.on13009); // 领取通关奖励
|
|
this.RegisterProtocal(13010, this.on13010); // 开通下一章节
|
|
this.RegisterProtocal(13011, this.on13011); // 快速作战BUFF信息
|
|
this.RegisterProtocal(13015, this.on13015); // 通关录像
|
|
this.RegisterProtocal(13017, this.on13017); // 累积挂机时间
|
|
this.RegisterProtocal(13019, this.on13019); // 服务端主动推送挂机收益信息
|
|
this.RegisterProtocal(13018, this.on13018); // 主动领取挂机奖励
|
|
|
|
this.RegisterProtocal(13016, this.on13016); // 剧情战斗结束的结算显示
|
|
this.RegisterProtocal(13020, this.handle13020); // 玩家剧情副本超过其他玩家百分比
|
|
|
|
this.RegisterProtocal(13033, this.on13033); //新版本通知服务端实际战斗结束
|
|
this.RegisterProtocal(13039, this.on13039); // 快速作战第一次花费点击
|
|
this.RegisterProtocal(13040, this.on13040); // 快速作战第一次花费提示
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["dungeon_data",
|
|
//剧情副本
|
|
"formation_data",
|
|
// 阵法
|
|
"arena_elite_data", "drama_story_data",
|
|
// 主线副本怪物提示
|
|
"misc_data" // 每周福利、月度礼包
|
|
];
|
|
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.reqDramaData(_cb);
|
|
});
|
|
},
|
|
reqDramaData: function reqDramaData(_cb) {
|
|
this.CB13006 = _cb;
|
|
this.SendProtocal(13000, {});
|
|
this.SendProtocal(13006, {});
|
|
this.SendProtocal(13008, {});
|
|
this.SendProtocal(13017, {}, _cb);
|
|
},
|
|
send13000: function send13000() {
|
|
this.SendProtocal(13000, {});
|
|
},
|
|
on13000: function on13000(data) {
|
|
if (nx.dt.objEmpty(game.configs.dungeon_data)) {
|
|
return;
|
|
}
|
|
if (data && this.role_vo) {
|
|
this.model.setDramaData(data);
|
|
}
|
|
},
|
|
send13033: function send13033(id) {
|
|
this.SendProtocal(13033, {
|
|
dun_id: id
|
|
});
|
|
},
|
|
on13033: function on13033() {},
|
|
// 更新关卡信息
|
|
on13001: function on13001(data) {
|
|
this.model.updateDramaData(data);
|
|
nx.bridge.vset("BattleDrameCd", data.cool_time);
|
|
},
|
|
send13006: function send13006() {
|
|
this.SendProtocal(13006, {});
|
|
},
|
|
// 针对快速作战的数据信息
|
|
on13006: function on13006(data) {
|
|
this.model.setQuickData(data);
|
|
},
|
|
send13008: function send13008() {
|
|
this.SendProtocal(13008, {});
|
|
},
|
|
// 通关奖励展示
|
|
on13008: function on13008(data) {
|
|
var obj = nx.bridge.vget("SpecialPass");
|
|
|
|
// for(let i in data.spe_list){
|
|
|
|
// }
|
|
for (var r = 0; r < data.list.length; r++) {
|
|
var rritem = data.list[r];
|
|
obj[rritem.id] = true;
|
|
}
|
|
nx.bridge.vset("SpecialPass", obj);
|
|
this.model.setDramaReward(data);
|
|
},
|
|
// 快速作战buff信息,这个后面放到需要时候请求去
|
|
on13011: function on13011(data) {
|
|
this.model.setBuffData(data);
|
|
},
|
|
send13017: function send13017() {
|
|
this.SendProtocal(13017, {});
|
|
},
|
|
// 累积挂机时间
|
|
on13017: function on13017(data) {
|
|
gcore.GlobalEvent.fire(DramaEvent.UpHookRewardWin, data);
|
|
this.model.updateHookAccumulateTime(data);
|
|
},
|
|
// 剧情副本战斗结算信息
|
|
on13016: function on13016(data) {
|
|
nx.bridge.vset("ResultInfo", data);
|
|
if (data) {
|
|
require("battle_controller").getInstance().openOtherFinish(require("battle_const").Fight_Type.Darma);
|
|
}
|
|
require("battle_controller").getInstance().pushSpecialRetInfo(data.combat_type, data);
|
|
},
|
|
// 主动领取挂机奖励
|
|
requestGetHookTimeAwards: function requestGetHookTimeAwards(_cb) {
|
|
this.SendProtocal(13018, {}, _cb);
|
|
},
|
|
on13018: function on13018(data) {
|
|
if (!nx.dt.arrNEmpty(data.msg)) {
|
|
nx.tbox(data.msg);
|
|
}
|
|
},
|
|
// 服务端主动推送挂机收益展示
|
|
on13019: function on13019(data) {
|
|
//修改成prompt事件推送
|
|
var role_vo = require("role_controller").getInstance().getRoleVo();
|
|
if (role_vo && game.configs.dungeon_data) {
|
|
var limt_lev = game.configs.dungeon_data.data_drama_const.maxtime_guaji_lv.val;
|
|
if (role_vo.lev >= limt_lev) {
|
|
var desc = nx.text.getKey("battle_gj_reward1");
|
|
// 跳转提示
|
|
nx.mbox(desc, ['cancel', 'confirm'], function (_key, _box) {
|
|
_box.close();
|
|
if (_key == 'confirm') {
|
|
var MC = BattleController.getInstance();
|
|
if (MC) {
|
|
MC.requestOpenBattleRelevanceWindow(BattleConst.Fight_Type.Darma);
|
|
}
|
|
}
|
|
}, "DramaReward");
|
|
}
|
|
}
|
|
},
|
|
// 快速作战和收集金币展示
|
|
on13007: function on13007(data) {
|
|
require("mainui_controller").getInstance().openGetItemView(true, data.items);
|
|
},
|
|
// 打开剧情这边挂机资产
|
|
openDramHookRewardView: function openDramHookRewardView(status, data) {
|
|
if (!status) {
|
|
nx.bridge.closePanel("WndBattleHookReward");
|
|
} else {
|
|
// -- 设置不要马上显示升级
|
|
nx.bridge.createPanel("WndBattleHookReward", data);
|
|
}
|
|
},
|
|
// 打开快速作战的界面
|
|
openDramBattleQuickView: function openDramBattleQuickView(status) {
|
|
if (!status) {
|
|
nx.bridge.closePanel("WndBattleQuick");
|
|
} else {
|
|
nx.bridge.createPanel("WndBattleQuick", {});
|
|
}
|
|
},
|
|
// 打开通关奖励界面
|
|
openDramaRewardWindow: function openDramaRewardWindow(status) {
|
|
if (!status) {
|
|
nx.bridge.closePanel("WndBattleReward");
|
|
} else {
|
|
nx.bridge.createPanel("WndBattleReward", {});
|
|
}
|
|
},
|
|
// 打开剧情章节录像
|
|
openDramaPassVedioWindow: function openDramaPassVedioWindow(status) {
|
|
if (!status) {
|
|
if (this.battle_drama_vedio_view) {
|
|
this.battle_drama_vedio_view.close();
|
|
this.battle_drama_vedio_view = null;
|
|
}
|
|
} else {
|
|
if (!this.battle_drama_vedio_view) {
|
|
this.battle_drama_vedio_view = Utils.createClass("battle_drama_pass_vedio_window");
|
|
}
|
|
this.battle_drama_vedio_view.open();
|
|
}
|
|
},
|
|
//掉落信息总览界面
|
|
openDramDropWindows: function openDramDropWindows(value, max_dun_id) {
|
|
if (!value) {
|
|
if (this.battle_drama_drop_tips_view) {
|
|
this.battle_drama_drop_tips_view.close();
|
|
this.battle_drama_drop_tips_view = null;
|
|
}
|
|
} else {
|
|
if (!this.battle_drama_drop_tips_view) {
|
|
this.battle_drama_drop_tips_view = Utils.createClass("battle_drama_drop_window");
|
|
}
|
|
this.battle_drama_drop_tips_view.open(max_dun_id);
|
|
}
|
|
},
|
|
// 剧情副本的章节地图界面
|
|
openBattleDramaMapWindows: function openBattleDramaMapWindows(status, chapter_id) {
|
|
if (status == true) {
|
|
if (this.battle_drama_map_view == null) {
|
|
this.battle_drama_map_view = Utils.createClass("battle_drama_map_window", this);
|
|
}
|
|
this.battle_drama_map_view.open(chapter_id);
|
|
} else {
|
|
if (this.battle_drama_map_view) {
|
|
this.battle_drama_map_view.close();
|
|
this.battle_drama_map_view = null;
|
|
}
|
|
}
|
|
},
|
|
// 打开Boss信息界面
|
|
openDramBossInfoView: function openDramBossInfoView(value, dun_id) {
|
|
if (value) {
|
|
nx.bridge.createPanel("WndBossInfo", {
|
|
dun_id: dun_id
|
|
});
|
|
} else {
|
|
nx.bridge.closePanel("WndBossInfo");
|
|
}
|
|
},
|
|
// 制作下一关,请求该协议,会同步返回 13000, 13010
|
|
send13002: function send13002() {
|
|
gcore.GlobalEvent.fire(BattleEvent.INIT_BATTLE_RESBG);
|
|
this.SendProtocal(13002, {});
|
|
},
|
|
// 开启下一章节
|
|
on13002: function on13002(data) {},
|
|
// 开通下一章节,客户端请求13002 之后的返回
|
|
on13010: function on13010(data) {
|
|
this.handleUnlockChapter(data);
|
|
},
|
|
// 打开世界地图,并且播放一些列动画
|
|
handleUnlockChapter: function handleUnlockChapter(data) {
|
|
if (game.configs.dungeon_data.data_drama_dungeon_info[data.dun_id]) {
|
|
var next_id = game.configs.dungeon_data.data_drama_dungeon_info[data.dun_id].next_id;
|
|
if (next_id == 0) {
|
|
data.is_last_chapter = true;
|
|
}
|
|
}
|
|
data.is_last_chapter = false;
|
|
if (data) {
|
|
// var WorldmapController = require("worldmap_controller")
|
|
// WorldmapController.getInstance().openWorldMapMainWindow(true,data)
|
|
}
|
|
},
|
|
// 挑战BOSS
|
|
send13003: function send13003() {
|
|
var is_vip_skip = nx.storage.get("vip_skip");
|
|
var auto = Number(is_vip_skip) || 0;
|
|
this.SendProtocal(13003, {
|
|
is_auto: auto
|
|
});
|
|
// gcore.GlobalEvent.fire( BattleEvent.WAITTING_TO_BATTLE, 1 );
|
|
},
|
|
send13003_new: function send13003_new() {
|
|
var is_vip_skip = nx.storage.get("vip_skip");
|
|
var auto = Number(is_vip_skip) || 0;
|
|
this.SendProtocal(13003, {
|
|
is_auto: auto
|
|
});
|
|
// gcore.GlobalEvent.fire( BattleEvent.WAITTING_TO_BATTLE, 1 );
|
|
},
|
|
|
|
// 挑战BOSS返回
|
|
on13003: function on13003(data) {
|
|
if (data.code == 0) {
|
|
if (nx.dt.strNEmpty(data.msg)) {
|
|
nx.tbox(data.msg);
|
|
}
|
|
}
|
|
if (this.is_ready_battle_drama) {
|
|
var BattleController = require("battle_controller");
|
|
BattleController.getInstance().send20062();
|
|
}
|
|
},
|
|
// 快速作战
|
|
send13004: function send13004() {
|
|
this.SendProtocal(13004, {});
|
|
},
|
|
// 快速作战返回
|
|
on13004: function on13004(data) {
|
|
if (nx.dt.strNEmpty(data.msg)) {
|
|
nx.tbox(data.msg);
|
|
}
|
|
},
|
|
// 领取通关奖励
|
|
send13009: function send13009(type, id) {
|
|
var protocal = {};
|
|
protocal.type = type;
|
|
protocal.id = id;
|
|
this.SendProtocal(13009, protocal);
|
|
},
|
|
// 领取通关奖励返回
|
|
on13009: function on13009(data) {
|
|
if (data.code == 1) {
|
|
if (data.type == 0) {
|
|
this.model.updateDramaReward(data.id);
|
|
} else if (data.type == 1) {
|
|
this.model.updateDramaSpeReward(data.id);
|
|
var obj = nx.bridge.vget("SpecialPass");
|
|
obj[data.id] = true;
|
|
nx.bridge.vset("SpecialPass", obj);
|
|
}
|
|
} else {
|
|
nx.tbox(data.msg);
|
|
}
|
|
},
|
|
// 请求通关录像
|
|
send13015: function send13015(id) {
|
|
var protocal = {};
|
|
protocal.dun_id = id;
|
|
this.SendProtocal(13015, protocal);
|
|
},
|
|
// 录像
|
|
on13015: function on13015(data) {
|
|
if (data && data.dungeon_replay_log) {
|
|
gcore.GlobalEvent.fire(DramaEvent.UpdatePassVedioDataEvent, data.dungeon_replay_log);
|
|
}
|
|
},
|
|
// 剧情副本进度超过其他玩家百分比
|
|
send13020: function send13020() {
|
|
this.SendProtocal(13020, {});
|
|
},
|
|
handle13020: function handle13020(data) {
|
|
if (data.val) {
|
|
// var DramaEvent = require("battle_drama_event")
|
|
// gcore.GlobalEvent.fire(DramaEvent.UpdateDramaProgressDataEvent, data.val);
|
|
var WorldEvent = require("worldmap_event");
|
|
gcore.GlobalEvent.fire(WorldEvent.UPDATE_CURRENT_LEVEL, data.val);
|
|
}
|
|
},
|
|
getDramaBattlePassRewardRoot: function getDramaBattlePassRewardRoot() {
|
|
if (this.battle_drama_reward_view) return this.battle_drama_reward_view.root_wnd;
|
|
},
|
|
getDramaBattleHookRewardRoot: function getDramaBattleHookRewardRoot() {
|
|
if (this.battle_drama_hook_reward_view) return this.battle_drama_hook_reward_view.root_wnd;
|
|
},
|
|
getDramBattleQuickRoot: function getDramBattleQuickRoot() {
|
|
if (this.battle_drama_quick_win) return this.battle_drama_quick_win.root_wnd;
|
|
},
|
|
handleUnlock: function handleUnlock() {
|
|
var drama_data = this.model.getDramaData();
|
|
if (drama_data) {
|
|
var is_show,
|
|
_data2 = this.model.getPreStatus(drama_data.max_dun_id);
|
|
if (is_show && _data2.is_show == true) {
|
|
this.openBattleDramaUnlockWindow(true, _data2);
|
|
cc.sys.localStorage.setItem('drama_data', JSON.stringify(drama_data.max_dun_id));
|
|
}
|
|
}
|
|
},
|
|
openBattleDramaUnlockWindow: function openBattleDramaUnlockWindow() {
|
|
var self = this;
|
|
if (value == false) {
|
|
if (self.battle_drama_unlock_view != null) {
|
|
self.battle_drama_unlock_view.close();
|
|
self.battle_drama_unlock_view = null;
|
|
}
|
|
} else {
|
|
if (self.battle_drama_unlock_view == null) {
|
|
var BattleDramaUnlockWindow = require("battle_drama_unlock_window");
|
|
self.battle_drama_unlock_view = new BattleDramaUnlockWindow();
|
|
}
|
|
self.battle_drama_unlock_view.open(data);
|
|
}
|
|
},
|
|
showWorldLevelTips: function showWorldLevelTips(state) {
|
|
if (state) {
|
|
if (!this.battle_drama_world_tip) {
|
|
var WorldTips = require("battle_drama_world_lev_tips");
|
|
this.battle_drama_world_tip = new WorldTips();
|
|
}
|
|
this.battle_drama_world_tip.open();
|
|
} else {
|
|
if (this.battle_drama_world_tip != null) {
|
|
this.battle_drama_world_tip.close();
|
|
this.battle_drama_world_tip = null;
|
|
}
|
|
}
|
|
},
|
|
openBattleDramaUnlockChapterView: function openBattleDramaUnlockChapterView(value, data) {
|
|
var self = this;
|
|
if (value == false) {
|
|
if (self.battle_drama_unlock_chapter_view != null) {
|
|
self.battle_drama_unlock_chapter_view.close();
|
|
self.battle_drama_unlock_chapter_view = null;
|
|
}
|
|
} else {
|
|
if (self.battle_drama_unlock_chapter_view == null) {
|
|
var BattleDramaUnlockChapterView = require("battle_drama_unlock_chapter_window");
|
|
self.battle_drama_unlock_chapter_view = new BattleDramaUnlockChapterView();
|
|
}
|
|
self.battle_drama_unlock_chapter_view.open(data);
|
|
}
|
|
},
|
|
//进入主场景后显示缓存的界面
|
|
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 = [];
|
|
},
|
|
send13039: function send13039() {
|
|
this.SendProtocal(13039, {});
|
|
},
|
|
//快速作战第一次花费记录
|
|
on13039: function on13039(data) {},
|
|
send13040: function send13040() {
|
|
this.SendProtocal(13040, {});
|
|
},
|
|
//快速作战第一次花费记录
|
|
on13040: function on13040(data) {
|
|
this.model.setFirstFresh(data.flag != 1);
|
|
},
|
|
//打开boss介绍界面
|
|
openDramaBossWindow: function openDramaBossWindow(status, drama_id) {
|
|
if (!status) {
|
|
if (this.drama_boss_window != null) {
|
|
this.drama_boss_window.close();
|
|
this.drama_boss_window = null;
|
|
}
|
|
} else {
|
|
if (this.drama_boss_window == null) {
|
|
var BattleDramaUnlockChapterView = require("battle_drama_boss_window");
|
|
this.drama_boss_window = new BattleDramaUnlockChapterView();
|
|
}
|
|
if (this.drama_boss_window) {
|
|
this.drama_boss_window.open(drama_id);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
module.exports = Battle_dramaController;
|
|
|
|
cc._RF.pop(); |