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
"use strict";
cc._RF.push(module, '55197g7R8pEi7Mul4WatCVh', 'endless_trail_controller');
// Scripts/mod/endless_trail/endless_trail_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-04 21:12:18
// --------------------------------------------------------------------
var MainuiController = require("mainui_controller");
 
var SceneEvent = require("mainscene_event");
 
var LoginEvent = require("login_event");
 
var BattleConst = require("battle_const");
 
var RoleController = require("role_controller");
 
var RoleEvent = require("role_event");
 
var Endless_trailEvent = require("endless_trail_event");
 
var Endless_trailController = cc.Class({
  "extends": BaseController,
  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;
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    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) {
          this.openEndlessBattleView(true);
        }
      }.bind(this));
    } //  断线重连的时候
 
 
    if (this.re_link_game_event == null) {
      this.re_link_game_event = gcore.GlobalEvent.bind(LoginEvent.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));
    }
  },
  // 注册协议接受事件
  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
  },
  checkIsOpen: function checkIsOpen(show_desc) {
    var open_config = Config.endless_data.data_const.open_lev;
    if (open_config == null) return false;
    var is_open = MainuiController.getInstance().checkIsOpenByActivate(open_config.val);
 
    if (show_desc == true && is_open == false) {
      message(open_config.desc);
    }
 
    return is_open;
  },
  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 (data) {
      this.model.setEndlessData(data);
    }
  },
  send23901: function send23901(formation_type, pos_info, hallows_id) {
    var protocol = {};
    protocol.formation_type = formation_type;
    protocol.pos_info = pos_info;
    protocol.hallows_id = hallows_id;
    this.SendProtocal(23901, protocol);
  },
  handle23901: function handle23901(data) {
    message(data.msg);
  },
  send23902: function send23902() {
    var protocol = {};
    this.SendProtocal(23902, protocol);
  },
  handle23902: function handle23902(data) {
    this.model.setEndlessBattleData(data);
  },
  send23903: function send23903() {
    var protocol = {};
    this.SendProtocal(23903, protocol);
  },
  handle23903: function handle23903(data) {
    if (data) {
      this.model.setFirstData(data);
    }
  },
  send23904: function send23904(id) {
    var protocol = {};
    protocol.id = id;
    this.SendProtocal(23904, protocol);
  },
  handle23904: function handle23904(data) {
    message(data.msg);
 
    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) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(Endless_trailEvent.UPDATA_SENDPARTNER_SUCESS_DATA, data);
    }
  },
  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) {
    message(data.msg);
  },
  send23910: function send23910() {
    var protocol = {};
    this.SendProtocal(23910, protocol);
  },
  handle23910: function handle23910(data) {
    cc.log("buff信息", data.end_time - gcore.SmartSocket.getTime());
 
    if (data) {
      var is_open = false;
 
      if (MainuiController.getInstance().checkIsInEndlessUIFight()) {
        this.openEndlessBuffView(true, data);
        is_open = true;
      }
 
      if (!is_open) {
        this.cache_buff_data = data;
      }
    }
  },
  send23911: function send23911(buff_id) {
    var protocol = {};
    protocol.buff_id = buff_id;
    this.SendProtocal(23911, protocol);
  },
  handle23911: function handle23911(data) {
    message(data.msg);
    this.cache_buff_data = null;
 
    if (data.code == 1) {
      this.openEndlessBuffView(false); // 成功选择一个buff之后,也要移除掉提示
 
      var PromptController = require("prompt_controller");
 
      var PromptTypeConst = require("prompt_type_const");
 
      PromptController.getInstance().getModel().removePromptDataByTpye(PromptTypeConst.Endless_trail);
    }
  },
  // --打开界面相关--
  // 打开主界面
  openEndlessMainWindow: function openEndlessMainWindow(status) {
    if (status == true) {
      if (this.checkIsOpen(true) == false) {
        return;
      }
 
      if (!this.endless_main_window) {
        this.endless_main_window = Utils.createClass("endless_trail_main_window", this);
      }
 
      this.model.getFirstKindList();
      this.model.getFiveKindList();
      this.model.getRankKindList();
 
      if (this.endless_main_window && this.endless_main_window.isOpen() == false) {
        this.endless_main_window.open();
      }
    } else {
      if (this.endless_main_window) {
        this.endless_main_window.close();
        this.endless_main_window = null;
      }
    }
  },
  // 战斗界面
  openEndlessBattleView: function openEndlessBattleView(status) {
    if (status == true) {
      if (!this.endless_battle_view) {
        this.endless_battle_view = Utils.createClass("endless_trail_battle_window", this);
      }
 
      if (this.endless_battle_view && this.endless_battle_view.isOpen() == false) {
        if (this.endless_battle_view && this.endless_battle_view.isOpen() == false) {
          this.endless_battle_view.open();
        }
 
        if (this.cache_buff_data) {
          //判断是否存在协议
          this.openEndlessBuffView(true, this.cache_buff_data);
          this.cache_buff_data = null;
        }
      }
    } else {
      if (this.endless_battle_view) {
        this.endless_battle_view.close();
        this.endless_battle_view = null;
      }
    }
  },
  // buff界面
  openEndlessBuffView: function openEndlessBuffView(status, data, is_force) {
    if (status == true) {
      if (!this.endless_buff_window) {
        this.endless_buff_window = Utils.createClass("endless_trail_buff_window", this);
      }
 
      data = data || this.cache_buff_data; // 可能在外面就调用这个时候直接用缓存的buff吧
 
      if (data == null) return;
 
      if (this.endless_buff_window && this.endless_buff_window.isOpen() == false) {
        this.endless_buff_window.open(data);
      } // 移除掉缓存的,因为可能在外面点击去.这个时候不移除掉再进入战斗的时候会又一次打开
 
 
      this.cache_buff_data = null;
    } else {
      if (this.endless_buff_window) {
        if (is_force) {
          // 引导中强制关闭界面,这时重新取出buff数据缓存
          this.cache_buff_data = this.endless_buff_window.getData();
        }
 
        this.endless_buff_window.close();
        this.endless_buff_window = null;
      }
    }
  },
  // 排行榜界面
  openEndlessRankView: function openEndlessRankView(status) {
    if (status == true) {
      if (!this.endless_rank_window) {
        this.endless_rank_window = Utils.createClass("endless_rank_window", this);
      }
 
      if (this.endless_rank_window && this.endless_rank_window.isOpen() == false) {
        this.endless_rank_window.open();
      }
    } else {
      if (this.endless_rank_window) {
        this.endless_rank_window.close();
        this.endless_rank_window = null;
      }
    }
  },
  // 支援界面
  openEndlessFriendHelpView: function openEndlessFriendHelpView(status) {
    if (status == true) {
      if (!this.endless_friendhelp_window) {
        this.endless_friendhelp_window = Utils.createClass("endless_friend_help_window", this);
      }
 
      if (this.endless_friendhelp_window && this.endless_friendhelp_window.isOpen() == false) {
        this.endless_friendhelp_window.open();
      }
    } else {
      if (this.endless_friendhelp_window) {
        this.endless_friendhelp_window.close();
        this.endless_friendhelp_window = null;
      }
    }
  },
  // 奖励详情一览
  openEndlessRewardWindow: function openEndlessRewardWindow(status) {
    if (status == true) {
      if (!this.endless_reward_window) {
        this.endless_reward_window = Utils.createClass("endless_reward_window", this);
      }
 
      if (this.endless_reward_window && this.endless_reward_window.isOpen() == false) {
        this.endless_reward_window.open();
      }
    } else {
      if (this.endless_reward_window) {
        this.endless_reward_window.close();
        this.endless_reward_window = null;
      }
    }
  },
  // 战斗领取
  openEndlessRewardTips: function openEndlessRewardTips(status, id) {
    if (status == true) {
      if (!this.endless_reward_tips) {
        this.endless_reward_tips = Utils.createClass("endlesstrail_awards_tips_window", this);
      }
 
      if (this.endless_reward_tips && this.endless_reward_tips.isOpen() == false) {
        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();