difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
"use strict";
cc._RF.push(module, '90240VouUVJFa2ZnVyWZCD8', 'forgehouse_controller');
// Scripts/mod/forgehouse/forgehouse_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     锻造屋的模块,合成装备的地方
// <br/>Create: 2019-01-03 10:09:32
// --------------------------------------------------------------------
var ForgehouseController = cc.Class({
  "extends": BaseController,
  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);
  },
  // 合成
  handle11080: function handle11080(data) {
    message(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) {
      message(Utils.TI18N("暂时无法合成任何装备或金币不足"));
      return;
    }
 
    if (data.type == 0) {
      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) {
    message(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) {
    if (bool == true) {
      if (this.all_synthsis_view == null) {
        this.all_synthsis_view = Utils.createClass("equipment_all_synthesis_window");
      }
 
      this.all_synthsis_view.open(data);
    } else {
      if (this.all_synthsis_view) {
        this.all_synthsis_view.close();
        this.all_synthsis_view = null;
      }
    }
  },
  //打开合成日志界面
  openEquipmentCompRecordWindow: function openEquipmentCompRecordWindow(bool) {
    if (bool == true) {
      if (this.comp_record_view == null) {
        this.comp_record_view = Utils.createClass("equipment_comp_record_window");
      }
 
      this.comp_record_view.open();
    } else {
      if (this.comp_record_view) {
        this.comp_record_view.close();
        this.comp_record_view = null;
      }
    }
  },
  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();