Files
fc/dev/project/library/imports/90/90240568-b945-4915-ad99-9d5c966420fc.js
T
2026-05-24 10:21:26 +08:00

143 lines
4.3 KiB
JavaScript

"use strict";
cc._RF.push(module, '90240VouUVJFa2ZnVyWZCD8', 'forgehouse_controller');
// Scripts/mod/partner/cmps/reform/forgehouse_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 锻造屋的模块,合成装备的地方
// <br/>Create: 2019-01-03 10:09:32
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
// 桥接替换的界面
var ForgehouseController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var ForgehouseModel = require("forgehouse_model");
this.model = new ForgehouseModel();
this.model.initConfig();
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(11080, this.handle11080);
this.RegisterProtocal(11079, this.handle11079);
this.RegisterProtocal(11081, this.handle11081);
this.RegisterProtocal(11082, this.handle11082);
},
// 从服务器初始化数据
reqBaseFromServer: function reqBaseFromServer(_cb) {
nx.dt.fnInvoke(_cb, true);
},
// 合成
handle11080: function handle11080(data) {
nx.tbox(data.msg);
if (data.result == 1) {
gcore.GlobalEvent.fire(EventId.COMPOSITE_RESULT);
}
},
// 请求合成物品
send11080: function send11080(id, num) {
var proto = {};
proto.base_id = id;
proto.num = num;
this.SendProtocal(11080, proto);
},
//一键合成装备预览
send11079: function send11079(base_id, num) {
var proto = {};
proto.base_id = Number(base_id);
proto.num = num || 0;
this.SendProtocal(11079, proto);
},
handle11079: function handle11079(data) {
if (Utils.next(data.list) == null) {
nx.tbox(nx.text.getKey("lab_forgehouse_controller_tip1"));
return;
}
if (data.type == 0) {
gcore.GlobalEvent.fire(EventId.COMPOSITE_PREVIEW, data);
// this.openEquipmentAllSynthesisWindow(true, data);
}
},
//一键合成
send11081: function send11081(base_id, num) {
var proto = {};
proto.base_id = base_id;
proto.num = num || 0;
this.SendProtocal(11081, proto);
},
handle11081: function handle11081(data) {
nx.tbox(data.msg);
if (data.result == 1) {
this.openEquipmentAllSynthesisWindow(false);
gcore.GlobalEvent.fire(EventId.COMPOSITE_RESULT);
}
},
//合成日志
send11082: function send11082() {
this.SendProtocal(11082, {});
},
handle11082: function handle11082(data) {
gcore.GlobalEvent.fire(EventId.COMPOSITE_RECORD, data);
},
// 打开关闭锻造屋
//sub_type:1为装备锻造;2为符文锻造
openForgeHouseView: function openForgeHouseView(status, sub_type) {
if (!status) {
if (this.forgehouse_win) {
this.forgehouse_win.close();
this.forgehouse_win = null;
}
} else {
if (this.forgehouse_win == null) {
var ForgehouseWindow = require("forge_house_window");
this.forgehouse_win = new ForgehouseWindow();
}
this.forgehouse_win.open(sub_type);
}
},
//打开一键合成预览界面
openEquipmentAllSynthesisWindow: function openEquipmentAllSynthesisWindow(bool, data, _cb) {
if (bool == true) {
nx.bridge.createPanel("WndPartnerEquipCompoundPreviewPanel", {
data: data,
cb: _cb
});
} else {
nx.bridge.closePanel("WndPartnerEquipCompoundPreviewPanel");
}
},
//打开合成日志界面
openEquipmentCompRecordWindow: function openEquipmentCompRecordWindow(bool) {
if (bool == true) {
nx.bridge.createPanel("WndPartnerEquipCompoundRecordsPanel");
} else {
nx.bridge.closePanel("WndPartnerEquipCompoundRecordsPanel");
}
},
getForgeHouseRoot: function getForgeHouseRoot() {
if (this.forgehouse_win) return this.forgehouse_win.root_wnd;
},
getForgeArtifactRoot: function getForgeArtifactRoot() {
if (this.forgehouse_win) {
if (this.forgehouse_win.panel_list) {
return this.forgehouse_win.panel_list[2].root_wnd;
}
}
}
});
module.exports = ForgehouseController;
cc._RF.pop();