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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
"use strict";
cc._RF.push(module, 'ce806DRwFFKc4wfxpJUe+aC', 'hallows_controller');
// Scripts/mod/hallows/hallows_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-02-18 14:15:05
// --------------------------------------------------------------------
var MainuiConst = require("mainui_const");
 
var MainuiController = require("mainui_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": BaseController,
  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.backpack_init_event == null){
    //     this.backpack_init_event = gcore.GlobalEvent.bing(BackpackEvent.GET_ALL_DATA,(function(){
    //         // -- if bag_code ~= BackPackConst.Bag_Code.BACKPACK then return end
    //         // -- self.role_vo = RoleController:getInstance():getRoleVo() 
    //         // -- if self.role_vo  == nil then
    //         // --     if self.init_role_event == nil then
    //         // --         self.init_role_event = GlobalEvent:getInstance():Bind(EventId.ROLE_CREATE_SUCCESS, function()
    //         // --             GlobalEvent:getInstance():UnBind(self.init_role_event)
    //         // --             self.role_vo = RoleController:getInstance():getRoleVo() 
    //         // --             if self.role_vo then
    //         // --                 self:requestInitProtocals()
    //         // --             end
    //         // --         end)
    //         // --     end
    //         // -- else
    //         // --     self:requestInitProtocals()
    //         // -- end
    //     }).bind(this))
    // }
    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 () {
        var GuideController = require("guide_controller");
 
        if (!GuideController.getInstance().isInGuide()) {
          this.resonate_data = null;
          this.openHallowsMainWindow(false);
        }
      }.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); // 是否打开过神器界面
  },
  //监测圣器系统是否解锁
  checkIsOpen: function checkIsOpen(show_desc) {
    var open_config = Config.function_data.data_base[MainuiConst.btn_index.hallows + 1];
    if (open_config == null) return false;
    var is_open = MainuiController.getInstance().checkIsOpenByActivate(open_config.activate);
 
    if (show_desc && !is_open) {
      message(open_config.desc);
    }
 
    return is_open;
  },
  //初始登记请求的一些数据
  requestInitProtocals: function requestInitProtocals() {
    var can_request = this.checkIsOpen();
 
    if (can_request) {
      if (this.battle_drama_event) {
        gcore.GlobalEvent.unbind(this.battle_drama_event);
        this.battle_drama_event = null;
      }
 
      this.requestHallowsInfo();
    }
  },
  //引导需要
  getHallowsRoot: function getHallowsRoot(finish_cb) {
    if (!finish_cb) {
      if (this.hallows_window) {
        return this.hallows_window.root_wnd;
      }
    } else {
      if (this.hallows_window) {
        this.hallows_window.getRootWnd(finish_cb);
      } else {
        finish_cb(null);
      }
    }
  },
  //引导需要
  getHallowsActivityRoot: function getHallowsActivityRoot(finish_cb) {
    if (!finish_cb) {
      if (this.activity_window) {
        return this.activity_window.root_wnd;
      }
    } else {
      if (this.activity_window) {
        this.activity_window.getRootWnd(finish_cb);
      } else {
        finish_cb(null);
      }
    }
  },
  // 引导需要
  getHallowsPreviewRoot: function getHallowsPreviewRoot(finish_cb) {
    if (!finish_cb) {
      if (this.hallows_preview) {
        return this.hallows_preview.root_wnd;
      }
    } else {
      if (this.hallows_preview) {
        this.hallows_preview.getRootWnd(finish_cb);
      } else {
        finish_cb(null);
      }
    }
  },
  //打开圣器主界面
  openHallowsMainWindow: function openHallowsMainWindow(status, hallows_id, index) {
    if (!status) {
      if (this.hallows_window) {
        this.hallows_window.close();
        this.hallows_window = null;
      }
    } else {
      //判断开启
      if (!this.checkIsOpen(true)) return; // //是否打开过神器界面,第一次打开时要打开失落神器界面(引导需要)
      // var open_flag = this.model.getHallowsOpenFlag();
      // if(open_flag == 0){
      //     this.requestSignOpenHallows()
      //     this.openHallowsPreviewWindow(true)
      //     return
      // }
 
      if (this.hallows_window == null) {
        //如果已经全部激活,则打开神器主界面(包含升级和技能);否则打开神器任务界面
        if (this.model.checkIsHaveAllHallows()) {
          this.hallows_window = Utils.createClass("hallows_main_window", this);
        } else {
          this.hallows_window = Utils.createClass("hallows_task_window", this);
        }
      }
 
      if (this.hallows_window && this.hallows_window.isOpen() == false) {
        this.hallows_window.open(hallows_id, index);
      }
    }
  },
  // 打开所有神器预览界面
  openHallowsPreviewWindow: function openHallowsPreviewWindow(status) {
    if (status) {
      if (this.hallows_preview == null) {
        this.hallows_preview = Utils.createClass("hallows_preview_window", this);
      }
 
      if (this.hallows_preview && this.hallows_preview.isOpen() == false) {
        this.hallows_preview.open();
      }
    } else {
      if (this.hallows_preview) {
        this.hallows_preview.close();
        this.hallows_preview = null;
      }
    }
  },
  //打开圣器的圣印界面
  openHallowsTraceWindow: function openHallowsTraceWindow(status, data) {
    if (!status) {
      if (this.trace_window) {
        this.trace_window.close();
        this.trace_window = null;
      }
    } else {
      if (data == null) return;
 
      if (this.trace_window == null) {
        this.trace_window = Utils.createClass("hallows_trace_window", this);
      }
 
      if (this.trace_window && this.trace_window.isOpen() == false) {
        this.trace_window.open(data);
      }
    }
  },
  //圣器装备的tips
  openHallowsTips: function openHallowsTips(status, data) {
    if (!status) {
      if (this.hallows_tips) {
        this.hallows_tips.close();
        this.hallows_tips = null;
      }
    } else {
      if (data == null) return;
 
      if (this.hallows_tips == null) {
        this.hallows_tips = Utils.createClass("hallows_tips_window", this);
      }
 
      if (this.hallows_tips && this.hallows_tips.isOpen() == false) {
        this.hallows_tips.open(data);
      }
    }
  },
  //圣器激活界面
  openHallowsActivityWindow: function openHallowsActivityWindow(status, data) {
    if (!status) {
      if (this.activity_window) {
        this.activity_window.close();
        this.activity_window = null;
      }
    } else {
      if (data == null) return;
 
      if (this.activity_window == null) {
        this.activity_window = Utils.createClass("hallows_activity_window", this);
      }
 
      if (this.activity_window && this.activity_window.isOpen() == false) {
        this.activity_window.open(data);
      }
    }
  },
  //进阶界面
  openHallowsStepUpWindow: function openHallowsStepUpWindow(status, data) {
    if (!status) {
      if (this.step_up_window) {
        this.step_up_window.close();
        this.step_up_window = null;
      } //关闭升阶面板之后,弹出共鸣面板
 
 
      if (this.resonate_data) {
        this.openHallowsResonateUpWindow(true, this.resonate_data);
        this.resonate_data = null;
      }
    } else {
      if (data == null) return;
 
      if (this.step_up_window == null) {
        this.step_up_window = Utils.createClass("hallows_step_up_window", this);
      }
 
      if (this.step_up_window && this.step_up_window.isOpen() == false) {
        this.step_up_window.open(data);
      }
    }
  },
  //共鸣
  // --[[function HallowsController:openHallowsResonateUpWindow(status, data)
  //     if not status then
  //         if self.resonate_up_window then
  //             self.resonate_up_window:close()
  //             self.resonate_up_window = nil
  //         end
  //     else
  //         if self.resonate_up_window == nil 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); // 如果是激活了最后一个神器,且神器任务界面正在显示,则切换为神器升级界面
 
    if (this.model.checkIsHaveAllHallows() && this.hallows_window) {
      this.openHallowsMainWindow(false);
      this.openHallowsMainWindow(true);
    } // /通知面板更新数据
 
 
    gcore.GlobalEvent.fire(HallowsEvent.HallowsActivityEvent, data.id); //播放激活特效
 
    this.openHallowsActivityWindow(true, 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) {
    message(data.msg); //升阶了
 
    if (data.result == 1) {
      this.openHallowsStepUpWindow(true, 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) {
    message(data.msg);
 
    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) {
    message(data.msg);
 
    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) {
    message(data.msg);
 
    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) {
    message(data.msg);
  },
  //共鸣变化
  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) {
    message(data.msg);
  },
  // 请求标记打开神器界面
  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;
    }
  }
});
module.exports = HallowsController;
 
cc._RF.pop();