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
"use strict";
cc._RF.push(module, 'e8d7c26Iv5NxrbZP2BWe7mN', 'battle_drama_controller');
// Scripts/mod/battle_drama/battle_drama_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2018-12-25 14:56:32
// --------------------------------------------------------------------
var BattleEvent = require("battle_event");
 
var BattleConst = require("battle_const");
 
var StoryEvent = require("story_event");
 
var LevupgradeController = require("levupgrade_controller");
 
var MainuiEvent = require("mainui_event");
 
var Battle_dramaController = cc.Class({
  "extends": BaseController,
  properties: {
    role_vo: null
  },
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var Battle_dramaModel = require("battle_drama_model");
 
    this.model = new Battle_dramaModel();
    this.model.initConfig();
    this.cache_list = []; //缓存界面列表
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    this.create_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
      gcore.GlobalEvent.unbind(this.create_role_event);
      this.create_role_event = null;
 
      var RoleController = require("role_controller");
 
      this.role_vo = RoleController.getInstance().getRoleVo(); // this.requestInitProto();
    }.bind(this));
    this.battle_exit_event = gcore.GlobalEvent.bind(BattleEvent.CLOSE_RESULT_VIEW, function (combat_type) {
      if (combat_type == BattleConst.Fight_Type.Darma) {
        this.handleUnlock();
      } else {
        gcore.GlobalEvent.fire(StoryEvent.BATTLE_RESULT_OVER);
      }
    }.bind(this));
 
    if (this.loading_enter_scene == null) {
      this.loading_enter_scene = gcore.GlobalEvent.bind(MainuiEvent.LOADING_ENTER_SCENE, function () {
        this.showCachePanel();
      }.bind(this));
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(13000, this.on13000); // 剧情副本数据
 
    this.RegisterProtocal(13001, this.on13001); // 当前关卡信息
 
    this.RegisterProtocal(13002, this.on13002); // 制作下一关
 
    this.RegisterProtocal(13003, this.on13003); // 挑战BOSS
 
    this.RegisterProtocal(13004, this.on13004); // 使用快速作战
 
    this.RegisterProtocal(13006, this.on13006); // 剧情副本常规信息
 
    this.RegisterProtocal(13007, this.on13007); // 快速作战收获物品展示以及收集金币显示
 
    this.RegisterProtocal(13008, this.on13008); // 通关奖励显示
 
    this.RegisterProtocal(13009, this.on13009); // 领取通关奖励
 
    this.RegisterProtocal(13010, this.on13010); // 开通下一章节
 
    this.RegisterProtocal(13011, this.on13011); // 快速作战BUFF信息
 
    this.RegisterProtocal(13015, this.on13015); // 通关录像
 
    this.RegisterProtocal(13017, this.on13017); // 累积挂机时间
 
    this.RegisterProtocal(13019, this.on13019); // 服务端主动推送挂机收益信息
 
    this.RegisterProtocal(13018, this.on13018); // 主动领取挂机奖励
 
    this.RegisterProtocal(13016, this.on13016); // 剧情战斗结束的结算显示 
 
    this.RegisterProtocal(13020, this.handle13020); // 玩家剧情副本超过其他玩家百分比 
 
    this.RegisterProtocal(13039, this.on13039); // 快速作战第一次花费点击
 
    this.RegisterProtocal(13040, this.on13040); // 快速作战第一次花费提示
  },
  // 登录游戏之后初始化请求的协议
  requestInitProto: function requestInitProto() {// this.SendProtocal(13006, {});
    // this.SendProtocal(13008, {});
    // this.SendProtocal(13011, {});
    // this.SendProtocal(13017, {});
  },
  send13000: function send13000() {
    this.SendProtocal(13000, {});
  },
  on13000: function on13000(data) {
    if (data && this.role_vo) {
      this.model.setDramaData(data);
    }
  },
  // 更新关卡信息
  on13001: function on13001(data) {
    this.model.updateDramaData(data);
  },
  // 针对快速作战的数据信息
  on13006: function on13006(data) {
    this.model.setQuickData(data);
  },
  // 通关奖励展示
  on13008: function on13008(data) {
    this.model.setDramaReward(data);
  },
  // 快速作战buff信息,这个后面放到需要时候请求去
  on13011: function on13011(data) {
    this.model.setBuffData(data);
  },
  // 累积挂机时间
  on13017: function on13017(data) {
    this.model.updateHookAccumulateTime(data);
  },
  // 剧情副本战斗结算信息
  on13016: function on13016(data) {
    if (data) {
      require("battle_controller").getInstance().openFinishView(true, require("battle_const").Fight_Type.Darma, data);
    }
  },
  // 主动领取挂机奖励
  requestGetHookTimeAwards: function requestGetHookTimeAwards() {
    this.SendProtocal(13018, {});
  },
  on13018: function on13018(data) {
    message(data.msg);
  },
  // 服务端主动推送挂机收益展示
  on13019: function on13019(data) {
    // 剧情或者引导中不需要显示处理,这个后续补上去
    if (this.commonalert) return;
 
    if (IS_LOADING == true) {
      this.cache_list.push({
        "function": function (data) {
          this.on13019(data);
        }.bind(this, data)
      });
      return;
    }
 
    var MainUIController = require("mainui_controller");
 
    var MainUiConst = require("mainui_const");
 
    var main_index = MainUIController.getInstance().getMainUIIndex();
    var desc = Utils.TI18N("您的挂机收益即将达到上限,请前往出击界面领取");
    var confirm_str = Utils.TI18N("前往");
 
    if (main_index == MainUiConst.btn_index.drama_scene) {
      confirm_str = Utils.TI18N("确定");
      desc = Utils.TI18N("您的挂机收益即将达到上限,请点击收益宝箱领取");
    }
 
    var CommonAlert = require("commonalert");
 
    var confirm_callback = function () {
      if (main_index != MainUiConst.btn_index.drama_scene) {
        MainUIController.getInstance().changeMainUIStatus(MainUiConst.btn_index.drama_scene);
      }
 
      this.commonalert = null;
    }.bind(this);
 
    var cancel_callback = function cancel_callback() {
      this.commonalert = null;
    };
 
    this.commonalert = CommonAlert.show(desc, confirm_str, confirm_callback, Utils.TI18N("取消"), cancel_callback, null, null, {
      view_tag: SCENE_TAG.reconnect
    });
  },
  // 快速作战和收集金币展示
  on13007: function on13007(data) {
    this.openDramHookRewardView(true, data);
  },
  // 打开剧情这边挂机资产
  openDramHookRewardView: function openDramHookRewardView(status, data) {
    if (!status) {
      if (this.battle_drama_hook_reward_view) {
        this.battle_drama_hook_reward_view.close();
        this.battle_drama_hook_reward_view = null;
      }
    } else {
      // -- 如果在引导中,并且不是特殊处理的的引导,就不弹
      // local guide_config = GuideController:getInstance():getGuideConfig()
      // if guide_config and guide_config.id ~= GuideConst.special_id.quick_guide and guide_config.id ~= GuideConst.special_id.hook_guide  then
      //     return 
      // end
      // -- 设置不要马上显示升级
      LevupgradeController.getInstance().waitForOpenLevUpgrade(true);
 
      if (this.battle_drama_hook_reward_view == null) {
        this.battle_drama_hook_reward_view = Utils.createClass("battle_drama_hook_reward_window");
      }
 
      this.battle_drama_hook_reward_view.open(data);
    }
  },
  // 打开快速作战的界面
  openDramBattleQuickView: function openDramBattleQuickView(status) {
    if (!status) {
      if (this.battle_drama_quick_win) {
        this.battle_drama_quick_win.close();
        this.battle_drama_quick_win = null;
      }
    } else {
      LevupgradeController.getInstance().waitForOpenLevUpgrade(true);
 
      if (!this.battle_drama_quick_win) {
        this.battle_drama_quick_win = Utils.createClass("battle_drama_quick_window");
      }
 
      this.battle_drama_quick_win.open();
    }
  },
  // 打开通关奖励界面
  openDramaRewardWindow: function openDramaRewardWindow(status) {
    if (!status) {
      if (this.battle_drama_reward_view) {
        this.battle_drama_reward_view.close();
        this.battle_drama_reward_view = null;
      }
    } else {
      if (!this.battle_drama_reward_view) {
        this.battle_drama_reward_view = Utils.createClass("battle_drama_reward_window");
      }
 
      this.battle_drama_reward_view.open();
    }
  },
  // 打开剧情章节录像 
  openDramaPassVedioWindow: function openDramaPassVedioWindow(status) {
    if (!status) {
      if (this.battle_drama_vedio_view) {
        this.battle_drama_vedio_view.close();
        this.battle_drama_vedio_view = null;
      }
    } else {
      if (!this.battle_drama_vedio_view) {
        this.battle_drama_vedio_view = Utils.createClass("battle_drama_pass_vedio_window");
      }
 
      this.battle_drama_vedio_view.open();
    }
  },
  //掉落信息总览界面
  openDramDropWindows: function openDramDropWindows(value, max_dun_id) {
    if (!value) {
      if (this.battle_drama_drop_tips_view) {
        this.battle_drama_drop_tips_view.close();
        this.battle_drama_drop_tips_view = null;
      }
    } else {
      if (!this.battle_drama_drop_tips_view) {
        this.battle_drama_drop_tips_view = Utils.createClass("battle_drama_drop_window");
      }
 
      this.battle_drama_drop_tips_view.open(max_dun_id);
    }
  },
  //  剧情副本的章节地图界面
  openBattleDramaMapWindows: function openBattleDramaMapWindows(status, chapter_id) {
    if (status == true) {
      if (this.battle_drama_map_view == null) {
        this.battle_drama_map_view = Utils.createClass("battle_drama_map_window", this);
      }
 
      if (this.battle_drama_map_view && this.battle_drama_map_view.isOpen() == false) {
        this.battle_drama_map_view.open(chapter_id);
      }
    } else {
      if (this.battle_drama_map_view) {
        this.battle_drama_map_view.close();
        this.battle_drama_map_view = null;
      }
    }
  },
  // 打开Boss信息界面
  openDramBossInfoView: function openDramBossInfoView(value, data) {
    if (value == false) {
      if (this.battle_drama_boss_info != null) {
        this.battle_drama_boss_info.close();
        this.battle_drama_boss_info = null;
      }
    } else {
      if (this.battle_drama_boss_info == null) {
        this.battle_drama_boss_info = Utils.createClass("battle_drama_boos_info_window", this);
      }
 
      if (this.battle_drama_boss_info && this.battle_drama_boss_info.isOpen() == false) {
        this.battle_drama_boss_info.open(data);
      }
    }
  },
  // 制作下一关,请求该协议,会同步返回 13000, 13010
  send13002: function send13002() {
    this.SendProtocal(13002, {});
  },
  // 开启下一章节
  on13002: function on13002(data) {
    message(data.msg);
  },
  // 开通下一章节,客户端请求13002 之后的返回
  on13010: function on13010(data) {
    this.handleUnlockChapter(data);
  },
  // 打开世界地图,并且播放一些列动画
  handleUnlockChapter: function handleUnlockChapter(data) {
    if (Config.dungeon_data.data_drama_dungeon_info[data.dun_id]) {
      var next_id = Config.dungeon_data.data_drama_dungeon_info[data.dun_id].next_id;
 
      if (next_id == 0) {
        data.is_last_chapter = true;
      }
    }
 
    data.is_last_chapter = false;
 
    if (data) {
      var WorldmapController = require("worldmap_controller");
 
      WorldmapController.getInstance().openWorldMapMainWindow(true, data);
    }
  },
  // 挑战BOSS
  send13003: function send13003() {
    this.SendProtocal(13003, {
      is_auto: 0
    });
  },
  // 挑战BOSS返回
  on13003: function on13003(data) {
    message(data.msg);
  },
  // 快速作战
  send13004: function send13004() {
    this.SendProtocal(13004, {});
  },
  // 快速作战返回
  on13004: function on13004(data) {
    message(data.msg);
  },
  // 领取通关奖励
  send13009: function send13009(id) {
    var protocal = {};
    protocal.id = id;
    this.SendProtocal(13009, protocal);
  },
  // 领取通关奖励返回
  on13009: function on13009(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.model.updateDramaReward(data.id);
    }
  },
  // 请求通关录像
  send13015: function send13015(id) {
    var protocal = {};
    protocal.dun_id = id;
    this.SendProtocal(13015, protocal);
  },
  // 录像
  on13015: function on13015(data) {
    if (data && data.dungeon_replay_log) {
      var DramaEvent = require("battle_drama_event");
 
      gcore.GlobalEvent.fire(DramaEvent.UpdatePassVedioDataEvent, data.dungeon_replay_log);
    }
  },
  // 剧情副本进度超过其他玩家百分比
  send13020: function send13020() {
    this.SendProtocal(13020, {});
  },
  handle13020: function handle13020(data) {
    if (data.val) {
      var DramaEvent = require("battle_drama_event");
 
      gcore.GlobalEvent.fire(DramaEvent.UpdateDramaProgressDataEvent, data.val);
    }
  },
  getDramaBattlePassRewardRoot: function getDramaBattlePassRewardRoot() {
    if (this.battle_drama_reward_view) return this.battle_drama_reward_view.root_wnd;
  },
  getDramaBattleHookRewardRoot: function getDramaBattleHookRewardRoot() {
    if (this.battle_drama_hook_reward_view) return this.battle_drama_hook_reward_view.root_wnd;
  },
  getDramBattleQuickRoot: function getDramBattleQuickRoot() {
    if (this.battle_drama_quick_win) return this.battle_drama_quick_win.root_wnd;
  },
  handleUnlock: function handleUnlock() {
    var drama_data = this.model.getDramaData();
 
    if (drama_data) {
      var is_show,
          _data = this.model.getPreStatus(drama_data.max_dun_id);
 
      if (is_show && _data.is_show == true) {
        this.openBattleDramaUnlockWindow(true, _data);
        cc.sys.localStorage.setItem('drama_data', JSON.stringify(drama_data.max_dun_id)); // SysEnv:getInstance():saveDramaTipsFile({ dun_id = drama_data.max_dun_id})
      } else {
        // -- 直接抛出时间可以播放引导或者剧情了
        gcore.GlobalEvent.fire(StoryEvent.BATTLE_RESULT_OVER);
      }
    }
  },
  openBattleDramaUnlockWindow: function openBattleDramaUnlockWindow() {
    var self = this;
 
    if (value == false) {
      if (self.battle_drama_unlock_view != null) {
        self.battle_drama_unlock_view.close();
        self.battle_drama_unlock_view = null;
      }
    } else {
      if (self.battle_drama_unlock_view == null) {
        var BattleDramaUnlockWindow = require("battle_drama_unlock_window");
 
        self.battle_drama_unlock_view = new BattleDramaUnlockWindow();
      }
 
      if (self.battle_drama_unlock_view && self.battle_drama_unlock_view.isOpen() == false) {
        self.battle_drama_unlock_view.open(data);
      }
    }
  },
  openBattleDramaUnlockChapterView: function openBattleDramaUnlockChapterView(value, data) {
    var self = this;
 
    if (value == false) {
      if (self.battle_drama_unlock_chapter_view != null) {
        self.battle_drama_unlock_chapter_view.close();
        self.battle_drama_unlock_chapter_view = null;
      }
    } else {
      if (self.battle_drama_unlock_chapter_view == null) {
        var BattleDramaUnlockChapterView = require("battle_drama_unlock_chapter_window");
 
        self.battle_drama_unlock_chapter_view = new BattleDramaUnlockChapterView();
      }
 
      if (self.battle_drama_unlock_chapter_view && self.battle_drama_unlock_chapter_view.isOpen() == false) {
        self.battle_drama_unlock_chapter_view.open(data);
      }
    }
  },
  //进入主场景后显示缓存的界面
  showCachePanel: function showCachePanel() {
    if (this.cache_list == null || this.cache_list.length <= 0) return;
 
    for (var i in this.cache_list) {
      if (this.cache_list[i]["function"]) {
        this.cache_list[i]["function"]();
      }
    }
 
    this.cache_list = [];
  },
  send13039: function send13039() {
    this.SendProtocal(13039, {});
  },
  //快速作战第一次花费记录
  on13039: function on13039(data) {},
  send13040: function send13040() {
    this.SendProtocal(13040, {});
  },
  //快速作战第一次花费记录
  on13040: function on13040(data) {
    this.model.setFirstFresh(data.flag != 1);
  }
});
module.exports = Battle_dramaController;
 
cc._RF.pop();