Files
fc/dev/project/library/imports/55/5519783b-47ca-448b-b32e-97859ab42561.js
2026-05-24 10:21:26 +08:00

404 lines
12 KiB
JavaScript

"use strict";
cc._RF.push(module, '55197g7R8pEi7Mul4WatCVh', 'endless_trail_controller');
// Scripts/mod/pve/endless_trail/endless_trail_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-04 21:12:18
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var BattleConst = require("battle_const");
var BTC = require("battle_controller");
var Endless_trailEvent = require("endless_trail_event");
var Endless_trailController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var Endless_trailModel = require("endless_trail_model");
this.model = new Endless_trailModel();
this.model.initConfig();
this.cache_buff_data = null;
this.auto_skill = 0;
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {
var _this = this;
if (this.init_role_event == null) {
this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
gcore.GlobalEvent.unbind(this.init_role_event);
this.init_role_event = null;
// this.role_vo = RoleController.getInstance().getRoleVo();
// if(this.role_vo!=null){
// this.requestInitProtocal(true);
// if(this.role_assets_event == null){
// this.role_assets_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function(key, value){
// if(key == "lev"){
// this.requestInitProtocal();
// }else if(key == "open_day"){
// this.requestInitProtocal();
// }
// }.bind(this))
// }
// }
}.bind(this));
}
if (this.battle_enter_event == null) {
this.battle_enter_event = gcore.GlobalEvent.bind(EventId.ENTER_FIGHT, function (combat_type) {
if (combat_type == BattleConst.Fight_Type.Endless) {
if (this.cache_buff_data) {
//判断是否存在协议
this.openEndlessBuffView(true, this.cache_buff_data);
this.cache_buff_data = null;
}
}
}.bind(this));
}
// 断线重连的时候
if (this.re_link_game_event == null) {
this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
this.requestInitProtocal(true);
}.bind(this));
}
// 如果是竞技场退出战斗的话,并且也是存在当前请求打开竞技场面板的情况下,则打开竞技场面板
if (this.battle_exit_event == null) {
this.battle_exit_event = gcore.GlobalEvent.bind(EventId.EXIT_FIGHT, function (combat_type) {
this.openEndlessBattleView(false);
if (combat_type == BattleConst.Fight_Type.Endless) {
this.openEndlessBuffView(false);
}
}.bind(this));
}
if (this.auto_select_buff_event = null) {
this.auto_select_buff_event = gcore.GlobalEvent.bind(Endless_trailEvent.AUTO_SELECT_BUFF_DATA, function () {
//随机一个buff选出
console.log("自动选buff");
var id = Math.floor(Math.random() * 3);
var buff = _this.cache_buff_data.list[id];
if (buff) {
_this.send23911(buff.buff_id, 0);
}
});
}
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(23900, this.handle23900); // 基础信息
this.RegisterProtocal(23901, this.handle23901); // 挑战无尽
this.RegisterProtocal(23902, this.handle23902); //战斗界面信息
this.RegisterProtocal(23903, this.handle23903); //首通奖励展示
this.RegisterProtocal(23904, this.handle23904); //领取奖励通关奖励
this.RegisterProtocal(23905, this.handle23905); //已派出伙伴信息
this.RegisterProtocal(23906, this.handle23906); //领取奖励通关奖励
this.RegisterProtocal(23907, this.handle23907); //可雇佣伙伴列表信息
this.RegisterProtocal(23908, this.handle23908); //派出伙伴
this.RegisterProtocal(23909, this.handle23909); //雇佣伙伴
this.RegisterProtocal(23910, this.handle23910); //Buff列表
this.RegisterProtocal(23911, this.handle23911); //选择Buff
},
// 从服务器初始化数据
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this2 = this;
// 配置加载
var cfgs = ["endless_data" // 无尽试炼副本
];
this.loadConfigs(cfgs, function (_ret, _data) {
_this2.reqEndlessData(_cb);
});
},
reqEndlessData: function reqEndlessData(_cb) {
// 锁定中不请求数据
var is_open = this.checkIsOpen();
if (nx.dt.objNEmpty(is_open)) {
nx.dt.fnInvoke(_cb, true);
return;
}
this.SendProtocal(23900, {}, _cb);
this.SendProtocal(23903, {});
this.SendProtocal(23906, {});
},
checkIsOpen: function checkIsOpen() {
var open_config = game.configs.endless_data.data_const.open_lev;
if (open_config == null) return null;
var ret = nx.bridge.checkConditions(open_config.val);
return ret;
},
requestInitProtocal: function requestInitProtocal(force) {
var is_open = this.checkIsOpen();
if (is_open == true) {
this.send23900();
this.send23903();
this.send23906();
if (this.role_assets_event) {
this.role_vo.unbind(this.role_assets_event);
this.role_assets_event = null;
}
}
},
// 协议相关
send23900: function send23900(formation_type, pos_info) {
var protocol = {};
this.SendProtocal(23900, protocol);
},
handle23900: function handle23900(data) {
// 失败判定
if (!this.isGoodData(data)) {
return;
}
if (data) {
this.model.setEndlessData(data);
}
},
send23901: function send23901(formation_type, pos_info, hallows_id) {
var protocol = {};
protocol.type = 5;
protocol.formation_type = formation_type;
protocol.pos_info = pos_info;
protocol.hallows_id = hallows_id;
this.SendProtocal(23901, protocol);
},
handle23901: function handle23901(data) {
// 失败判定
if (!this.isGoodData(data)) {
return;
}
},
send23902: function send23902() {
var protocol = {};
this.SendProtocal(23902, protocol);
},
handle23902: function handle23902(data) {
this.model.setEndlessBattleData(data);
},
send23903: function send23903() {
var protocol = {};
protocol.type = 5;
this.SendProtocal(23903, protocol);
},
handle23903: function handle23903(data) {
// 失败判定
if (!this.isGoodData(data)) {
return;
}
if (data) {
this.model.setFirstData(data);
}
},
send23904: function send23904(id) {
var protocol = {};
protocol.id = id;
protocol.type = 5;
this.SendProtocal(23904, protocol);
},
handle23904: function handle23904(data) {
// 失败判定
if (!this.isGoodData(data)) {
return;
}
if (data.code == 1) {
this.openEndlessRewardTips(false);
}
},
send23905: function send23905() {
var protocol = {};
this.SendProtocal(23905, protocol);
},
handle23905: function handle23905(data) {
if (data) {
this.model.setSendPartnerData(data);
}
},
send23906: function send23906() {
var protocol = {};
this.SendProtocal(23906, protocol);
},
handle23906: function handle23906(data) {
if (data) {
this.model.setHasHirePartnerData(data);
}
},
send23907: function send23907() {
var protocol = {};
this.SendProtocal(23907, protocol);
},
handle23907: function handle23907(data) {
if (data) {
this.model.setHirePartnerData(data);
}
},
send23908: function send23908(id) {
var protocol = {};
protocol.id = id;
this.SendProtocal(23908, protocol);
},
handle23908: function handle23908(data) {
if (data.code == 1) {
gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_SENDPARTNER_SUCESS_DATA, data);
} else {
nx.tbox(data.msg);
}
},
send23909: function send23909(rid, srv_id, id, flag) {
var protocol = {};
protocol.id = id;
protocol.rid = rid;
protocol.srv_id = srv_id;
protocol.flag = flag;
this.SendProtocal(23909, protocol);
},
handle23909: function handle23909(data) {
if (data.code == 1) {
this.send23907();
}
},
send23910: function send23910() {
var protocol = {};
this.SendProtocal(23910, protocol);
},
handle23910: function handle23910(data) {
if (data) {
var is_open = false;
if (BTC.getInstance().getModel().getCombatType() == 11) {
this.openEndlessBuffView(true, data);
is_open = true;
}
// if(!is_open){
this.cache_buff_data = data;
// }
}
},
setAutoCheck: function setAutoCheck(auto) {
if (auto) {
this.auto_skill = 1;
} else {
this.auto_skill = 0;
}
},
getAutoCheck: function getAutoCheck() {
return this.auto_skill;
},
send23911: function send23911(buff_id, auto) {
var protocol = {};
protocol.buff_id = buff_id;
protocol.is_auto = auto;
this.SendProtocal(23911, protocol);
},
handle23911: function handle23911(data) {
// 失败判定
if (!this.isGoodData(data)) {
return;
}
this.cache_buff_data = null;
if (data.code == 1) {
this.openEndlessBuffView(false);
}
},
// --打开界面相关--
// 打开主界面
openEndlessMainWindow: function openEndlessMainWindow(status) {
if (status) {
this.model.getFirstKindList();
this.model.getFiveKindList();
this.model.getRankKindList();
nx.bridge.createPanel("WndEndlessMain", {});
} else {
nx.bridge.closePanel("WndEndlessMain");
}
},
// 战斗界面
openEndlessBattleView: function openEndlessBattleView(status) {
if (status) {
nx.bridge.createPanel("WndEndlessBattle", {});
if (this.cache_buff_data) {
//判断是否存在协议
this.openEndlessBuffView(true, this.cache_buff_data);
this.cache_buff_data = null;
}
} else {
nx.bridge.closePanel("WndEndlessBattle");
}
},
// buff界面
openEndlessBuffView: function openEndlessBuffView(status, data, is_force) {
if (status) {
nx.bridge.createPanel("WndEndlessBuff", data);
} else {
nx.bridge.closePanel("WndEndlessBuff");
}
},
// 排行榜界面
openEndlessRankView: function openEndlessRankView(status) {
if (status == true) {
if (!this.endless_rank_window) {
this.endless_rank_window = Utils.createClass("endless_rank_window", this);
}
this.endless_rank_window.open();
} else {
if (this.endless_rank_window) {
this.endless_rank_window.close();
this.endless_rank_window = null;
}
}
},
// 我方支援界面
openEndlessMyHelpView: function openEndlessMyHelpView(status) {
if (status) {
nx.bridge.createPanel("WndEndlessMyHelp", {});
} else {
nx.bridge.closePanel("WndEndlessMyHelp");
}
},
// 好友支援界面
openEndlessFriendHelpView: function openEndlessFriendHelpView(status) {
if (status) {
nx.bridge.createPanel("WndEndlessOtherHelp", {});
} else {
nx.bridge.closePanel("WndEndlessOtherHelp");
}
},
// 奖励详情一览
openEndlessRewardWindow: function openEndlessRewardWindow(status) {
if (status) {
nx.bridge.createPanel("WndEndlessReward", {});
} else {
nx.bridge.closePanel("WndEndlessReward");
}
},
// 战斗领取
openEndlessRewardTips: function openEndlessRewardTips(status, id) {
if (status == true) {
if (!this.endless_reward_tips) {
this.endless_reward_tips = Utils.createClass("endlesstrail_awards_tips_window", this);
}
this.endless_reward_tips.open(id);
} else {
if (this.endless_reward_tips) {
this.endless_reward_tips.close();
this.endless_reward_tips = null;
}
}
},
__delete: function __delete() {
if (this.model != null) {
this.model.DeleteMe();
this.model = null;
}
}
});
module.exports = Endless_trailController;
cc._RF.pop();