380 lines
12 KiB
JavaScript
380 lines
12 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'ce806DRwFFKc4wfxpJUe+aC', 'hallows_controller');
|
|
// Scripts/mod/partner/hallows/hallows_controller.js
|
|
|
|
"use strict";
|
|
|
|
// --------------------------------------------------------------------
|
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 这里填写详细说明,主要填写该模块的功能简要
|
|
// <br/>Create: 2019-02-18 14:15:05
|
|
// --------------------------------------------------------------------
|
|
var BridgeController = require("bridge.controller");
|
|
var BackpackEvent = require("backpack_event");
|
|
var Battle_dramaEvent = require("battle_drama_event");
|
|
var HallowsEvent = require("hallows_event");
|
|
var BackPackConst = require("backpack_const");
|
|
// 桥接替换的界面
|
|
|
|
var HallowsController = cc.Class({
|
|
"extends": BridgeController,
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
var HallowsModel = require("hallows_model");
|
|
this.model = new HallowsModel();
|
|
this.model.initConfig();
|
|
},
|
|
// 返回当前的model
|
|
getModel: function getModel() {
|
|
return this.model;
|
|
},
|
|
// 注册监听事件
|
|
registerEvents: function registerEvents() {
|
|
if (this.battle_drama_event == null) {
|
|
this.battle_drama_event = gcore.GlobalEvent.bind(Battle_dramaEvent.BattleDrama_Update_Max_Id, function (max_id) {
|
|
this.requestInitProtocals(max_id);
|
|
}.bind(this));
|
|
}
|
|
if (this.goods_add_event == null) {
|
|
this.goods_add_event = gcore.GlobalEvent.bind(BackpackEvent.ADD_GOODS, function (bag_code, item_list) {
|
|
if (bag_code != BackPackConst.Bag_Code.BACKPACK) return;
|
|
this.checkNeedUpdateRedStatus(item_list);
|
|
}.bind(this));
|
|
}
|
|
if (this.goods_update_event == null) {
|
|
this.goods_update_event = gcore.GlobalEvent.bind(BackpackEvent.MODIFY_GOODS_NUM, function (bag_code, item_list) {
|
|
if (bag_code != BackPackConst.Bag_Code.BACKPACK) return;
|
|
this.checkNeedUpdateRedStatus(item_list);
|
|
}.bind(this));
|
|
}
|
|
if (this.goods_del_event == null) {
|
|
this.goods_del_event = gcore.GlobalEvent.bind(BackpackEvent.DELETE_GOODS, function (bag_code, item_list) {
|
|
if (bag_code != BackPackConst.Bag_Code.BACKPACK) return;
|
|
this.checkNeedUpdateRedStatus(item_list);
|
|
}.bind(this));
|
|
}
|
|
if (this.re_link_game_event = null) {
|
|
this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
|
|
this.resonate_data = null;
|
|
}.bind(this));
|
|
}
|
|
},
|
|
//物品变化的时候做处理,如果是自己操作引起的不需要这里判断的,因为那属于自身更新
|
|
checkNeedUpdateRedStatus: function checkNeedUpdateRedStatus(item_list) {
|
|
if (this.is_self_handle) {
|
|
this.is_self_handle = false;
|
|
return;
|
|
}
|
|
if (this.item_list == null || Utils.next(item_list) == null) return;
|
|
for (var i in item_list) {
|
|
var cfg = item_list[i].config;
|
|
if (cfg) {
|
|
if (cfg.id == 72001 || cfg.id == 72002 || cfg.id == 72003) {
|
|
this.model.checkHallowsRedStatus();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(24100, this.handle24100); // 圣器基础属性
|
|
this.RegisterProtocal(24101, this.handle24101); // 圣器进阶
|
|
this.RegisterProtocal(24102, this.handle24102); // 圣灵穿戴
|
|
this.RegisterProtocal(24103, this.handle24103); // 圣技升级
|
|
this.RegisterProtocal(24104, this.handle24104); // 使用圣印
|
|
this.RegisterProtocal(24105, this.handle24105); // 共鸣变化
|
|
this.RegisterProtocal(24107, this.handle24107); // 更新圣器
|
|
this.RegisterProtocal(24108, this.handle24108); // 新增圣器,这个时候播放激活特效
|
|
|
|
this.RegisterProtocal(24120, this.handle24120); // 圣器任务列表
|
|
this.RegisterProtocal(24121, this.handle24121); // 圣器任务列表
|
|
this.RegisterProtocal(24122, this.handle24122); // 圣器任务列表
|
|
this.RegisterProtocal(24123, this.handle24123); // 神器重铸
|
|
this.RegisterProtocal(24124, this.handle24124); // 是否打开过神器界面
|
|
this.RegisterProtocal(24135, this.handle24135); // 神器精炼
|
|
|
|
this.RegisterProtocal(24140, this.handle24140); //满级属性预览
|
|
// this.requestInitProtocals();
|
|
},
|
|
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
// 配置加载
|
|
var cfgs = ["hallows_data",
|
|
// 行星武器
|
|
"hallows_refine_data" // 行星武器精炼
|
|
];
|
|
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.reqHallowsData(_cb);
|
|
});
|
|
},
|
|
checkIsLock: function checkIsLock() {
|
|
var open_config = game.configs.hallows_data.data_const.hallows_open;
|
|
if (open_config == null) return null;
|
|
var ret = nx.bridge.checkConditions([open_config.val]);
|
|
return ret;
|
|
},
|
|
reqHallowsData: function reqHallowsData(_cb) {
|
|
// 功能解锁检查
|
|
var is_open = this.checkIsLock();
|
|
|
|
// 锁定中不请求数据
|
|
if (nx.dt.objNEmpty(is_open)) {
|
|
nx.dt.fnInvoke(_cb, true);
|
|
return;
|
|
}
|
|
this.SendProtocal(24100, {});
|
|
this.SendProtocal(24120, {}, _cb);
|
|
},
|
|
//监测圣器系统是否解锁
|
|
checkIsOpen: function checkIsOpen(show_desc) {
|
|
var open_config = game.configs.source_data.data_source_data[39];
|
|
if (open_config == null) return false;
|
|
var ret = nx.bridge.checkConditions([open_config.lev_limit]);
|
|
if (show_desc && ret.val) {
|
|
nx.tbox(ret.desc);
|
|
}
|
|
var is_open = ret.val;
|
|
return is_open;
|
|
},
|
|
//初始登记请求的一些数据
|
|
requestInitProtocals: function requestInitProtocals() {
|
|
if (this.battle_drama_event) {
|
|
gcore.GlobalEvent.unbind(this.battle_drama_event);
|
|
this.battle_drama_event = null;
|
|
}
|
|
this.requestHallowsInfo();
|
|
},
|
|
//打开圣器的圣印界面
|
|
openHallowsTraceWindow: function openHallowsTraceWindow(status, data) {
|
|
if (status) {
|
|
nx.bridge.createPanel("WNdHallowsTrace", data);
|
|
} else {
|
|
nx.bridge.closePanel("WNdHallowsTrace");
|
|
}
|
|
},
|
|
//圣器装备的tips
|
|
openHallowsTips: function openHallowsTips(status, data) {
|
|
nx.bridge.createPanel("WndHallowsDetail", data);
|
|
},
|
|
openHallowsTipsWindow: function openHallowsTipsWindow(status, type, data) {
|
|
if (data == null) return;
|
|
var params = {};
|
|
params.type = type; //1 激活 2进阶
|
|
params.data = data;
|
|
// this.step_tips_window.open( params );
|
|
nx.bridge.createPanel("WndHallowsTip", params);
|
|
},
|
|
//激活和进阶二合一
|
|
//圣器激活界面
|
|
|
|
//共鸣
|
|
// --[[function HallowsController:openHallowsResonateUpWindow(status, data)
|
|
// if not status then
|
|
// if self.resonate_up_window then
|
|
// self.resonate_up_window:close()
|
|
// self.resonate_up_window = null
|
|
// end
|
|
// else
|
|
// if self.resonate_up_window == null then
|
|
// self.resonate_up_window = HallowsResonateUpWindow.New()
|
|
// end
|
|
// self.resonate_up_window:open(data)
|
|
// end
|
|
// end --]]
|
|
|
|
requestHallowsInfo: function requestHallowsInfo() {
|
|
this.SendProtocal(24100, {});
|
|
this.SendProtocal(24120, {});
|
|
},
|
|
handle24100: function handle24100(data) {
|
|
this.model.updateHallowsInfo(data);
|
|
},
|
|
//更新圣器
|
|
handle24107: function handle24107(data) {
|
|
this.model.updateHallowsData(data);
|
|
gcore.GlobalEvent.fire(HallowsEvent.HallowsUpdateEvent, data.id);
|
|
},
|
|
//激活圣器
|
|
handle24108: function handle24108(data) {
|
|
this.model.updateHallowsData(data);
|
|
// 如果是激活了最后一个神器,且神器任务界面正在显示,则切换为神器升级界面
|
|
|
|
// /通知面板更新数据
|
|
gcore.GlobalEvent.fire(HallowsEvent.HallowsActivityEvent, data.id);
|
|
//播放激活特效
|
|
this.openHallowsTipsWindow(true, 1, data);
|
|
},
|
|
//圣器进阶
|
|
requestHallowsAdvance: function requestHallowsAdvance(id, is_auto) {
|
|
this.is_self_handle = true;
|
|
var auto_type = 0;
|
|
if (is_auto) {
|
|
auto_type = 1;
|
|
}
|
|
var protocal = {};
|
|
protocal.id = id;
|
|
protocal.is_auto = auto_type;
|
|
this.SendProtocal(24101, protocal);
|
|
},
|
|
handle24101: function handle24101(data) {
|
|
// nx.tbox(data.msg);
|
|
//升阶了
|
|
if (data.result == 1) {
|
|
this.openHallowsTipsWindow(true, 2, data.id);
|
|
gcore.GlobalEvent.fire(HallowsEvent.UpdateHallowsDetailInfoList, data.id);
|
|
} else {
|
|
this.is_self_handle = false;
|
|
}
|
|
gcore.GlobalEvent.fire(HallowsEvent.HallowsAdvanceEvent, data.id, data.result);
|
|
},
|
|
//升级圣器技能
|
|
requestHallowsSkillUpgrade: function requestHallowsSkillUpgrade(hallows_id) {
|
|
this.is_self_handle = true;
|
|
var protocal = {};
|
|
protocal.hallows_id = hallows_id;
|
|
this.SendProtocal(24103, protocal);
|
|
},
|
|
handle24103: function handle24103(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
if (data.result == 1) {
|
|
// gcore.GlobalEvent.fire(HallowsEvent.HallowsSkillUpgradeEvent, data.hallows_id, data.id);
|
|
} else {
|
|
this.is_self_handle = false;
|
|
}
|
|
},
|
|
//穿戴一件装备
|
|
requestHallowsEquip: function requestHallowsEquip(hallows_id, item_id, pos) {
|
|
this.is_self_handle = true;
|
|
hallows_id = hallows_id || 0;
|
|
item_id = item_id || 1;
|
|
pos = pos || 1;
|
|
var protocal = {};
|
|
protocal.hallows_id = hallows_id;
|
|
protocal.id = item_id;
|
|
protocal.pos = pos;
|
|
this.SendProtocal(24102, protocal);
|
|
},
|
|
handle24102: function handle24102(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
if (data.result == 1) {
|
|
gcore.GlobalEvent.fire(HallowsEvent.HallowsEqupUpEvent, data.id, data.pos);
|
|
} else {
|
|
this.is_self_handle = false;
|
|
}
|
|
},
|
|
//使用圣印物品
|
|
requestUseTraceItem: function requestUseTraceItem(hallows_id, num) {
|
|
this.is_self_handle = true;
|
|
hallows_id = hallows_id || 0;
|
|
num = num || 1;
|
|
var protocal = {};
|
|
protocal.hallows_id = hallows_id;
|
|
protocal.num = num;
|
|
this.SendProtocal(24104, protocal);
|
|
},
|
|
handle24104: function handle24104(_data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
if (_data.result == 1) {
|
|
this.openHallowsTraceWindow(false);
|
|
} else {
|
|
this.is_self_handle = false;
|
|
}
|
|
},
|
|
// 初始化圣器任务列表
|
|
handle24120: function handle24120(data) {
|
|
this.model.updateHallowsTask(data.list);
|
|
},
|
|
// 圣器任务更新信息
|
|
handle24121: function handle24121(data) {
|
|
this.model.updateHallowsTask(data.list);
|
|
},
|
|
requestSubmitHallowsTask: function requestSubmitHallowsTask(id) {
|
|
var protocal = {};
|
|
protocal.id = id;
|
|
this.SendProtocal(24122, protocal);
|
|
},
|
|
handle24122: function handle24122(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
},
|
|
//共鸣变化
|
|
handle24105: function handle24105(data) {
|
|
this.resonate_data = data;
|
|
// this.openHallowsResonateUpWindow(true, data);
|
|
},
|
|
|
|
// 请求神器重铸
|
|
requestHallowsReset: function requestHallowsReset(id) {
|
|
var protocal = {};
|
|
protocal.id = id;
|
|
this.SendProtocal(24123, protocal);
|
|
},
|
|
handle24123: function handle24123(_data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.requestHallowsInfo();
|
|
},
|
|
// 请求标记打开神器界面
|
|
requestSignOpenHallows: function requestSignOpenHallows() {
|
|
this.SendProtocal(24124, {});
|
|
},
|
|
handle24124: function handle24124(data) {
|
|
if (data.is_first) {
|
|
this.model.setOpenHallowsFlag(data.is_first);
|
|
}
|
|
},
|
|
__delete: function __delete() {
|
|
if (this.model != null) {
|
|
this.model.DeleteMe();
|
|
this.model = null;
|
|
}
|
|
},
|
|
send24135: function send24135(hallows_id) {
|
|
var protocal = {};
|
|
protocal.hallows_id = hallows_id;
|
|
this.SendProtocal(24135, protocal);
|
|
},
|
|
handle24135: function handle24135(data) {
|
|
// 失败判定
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
if (data.code == 1) {
|
|
var new_data = {};
|
|
new_data.id = data.hallows_id;
|
|
new_data.refine_lev = data.refine_lev;
|
|
this.model.updateHallowsData(new_data);
|
|
gcore.GlobalEvent.fire(HallowsEvent.HallowsUpdateEvent, data.hallows_id, true);
|
|
}
|
|
},
|
|
send24140: function send24140(hallows_id) {
|
|
this.detail_id = hallows_id;
|
|
var protocal = {};
|
|
protocal.hallows_id = hallows_id;
|
|
this.SendProtocal(24140, protocal);
|
|
},
|
|
handle24140: function handle24140(data) {
|
|
this.model.createHallow(data);
|
|
this.openHallowsTips(true, this.detail_id);
|
|
}
|
|
});
|
|
module.exports = HallowsController;
|
|
|
|
cc._RF.pop(); |