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
"use strict";
cc._RF.push(module, 'f7c5aZEqeBGzoV1Dxl18Q+q', 'heroexpedit_controller');
// Scripts/mod/heroexpedit/heroexpedit_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-11 14:13:49
// --------------------------------------------------------------------
var LoginEvent = require("login_event");
 
var HeroController = require("hero_controller");
 
var EsecsiceConst = require("esecsice_const");
 
var HeroExpeditEvent = require("heroexpedit_event");
 
var MainuiController = require("mainui_controller");
 
var HeroexpeditController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var HeroexpeditModel = require("heroexpedit_model");
 
    this.model = new HeroexpeditModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    if (this.role_event == null) {
      this.role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
        gcore.GlobalEvent.unbind(this.role_event);
        this.role_event = null; // this.sender24410();
        // this.sender24405();
        // this.sender24400();
      }.bind(this));
    }
 
    if (this.re_link_game_event == null) {
      this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
        this.openHeroExpeditView(false);
        this.openHeroExpeditLevelView(false);
        this.openEmpolyPanelView(false);
        this.openBrowsePanelView(false); // this.sender24405();
        // this.sender24410();
        // this.sender24400();
      }.bind(this));
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(24400, this.handle24400);
    this.RegisterProtocal(24401, this.handle24401);
    this.RegisterProtocal(24402, this.handle24402);
    this.RegisterProtocal(24403, this.hander24403);
    this.RegisterProtocal(24404, this.hander24404);
    this.RegisterProtocal(24405, this.hander24405);
    this.RegisterProtocal(24406, this.hander24406);
    this.RegisterProtocal(24407, this.hander24407);
    this.RegisterProtocal(24408, this.hander24408);
    this.RegisterProtocal(24409, this.hander24409);
    this.RegisterProtocal(24410, this.hander24410);
  },
  // 请求远征数据
  sender24400: function sender24400() {
    this.SendProtocal(24400, {});
  },
  handle24400: function handle24400(data) {
    this.model.setExpeditData(data);
    this.grard_id = data.guard_id;
    gcore.GlobalEvent.fire(HeroExpeditEvent.HeroExpeditViewEvent, data);
    gcore.GlobalEvent.fire(HeroExpeditEvent.Red_Point_Event);
  },
  // 获取关卡
  getGrardID: function getGrardID() {
    return this.grard_id || 1;
  },
  // 获取关卡守将信息
  sender24401: function sender24401(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(24401, proto);
  },
  handle24401: function handle24401(data) {
    if (!data) return;
    var box_pos = this.model.getExpeditBoxData();
    var status = false;
 
    for (var i in box_pos) {
      if (box_pos[i] == data.id) {
        status = true;
        break;
      }
    }
 
    if (status == true) {
      this.openBrowsePanelView(true, data);
    } else {
      if (data.id <= this.grard_id) {
        this.openHeroExpeditLevelView(true, data);
        gcore.GlobalEvent.fire(HeroExpeditEvent.levelMessageEvent, data);
      } else {
        message(Utils.TI18N("先通关前置关卡"));
      }
    }
  },
  // 领取关卡宝箱
  sender24402: function sender24402(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(24402, proto);
  },
  handle24402: function handle24402(data) {
    message(data.msg);
 
    if (data.code == 1) {
      var expedit_data = this.model.getExpeditData();
      expedit_data.reward.push({
        reward_id: data.id
      });
      gcore.GlobalEvent.fire(HeroExpeditEvent.Get_Box_Event, data.id);
    }
  },
  // 挑战
  sender24403: function sender24403(formation_type, pos_info, hallows_id) {
    var proto = {};
    proto.formation_type = formation_type;
    proto.pos_info = pos_info;
    proto.hallows_id = hallows_id;
    this.SendProtocal(24403, proto);
  },
  hander24403: function hander24403(data) {
    message(data.msg);
 
    if (data.code == 1) {
      HeroController.getInstance().openFormGoFightPanel(false);
    }
  },
  // 伙伴信息
  sender24404: function sender24404() {
    this.SendProtocal(24404, {});
  },
  hander24404: function hander24404(data) {
    this.model.setPartnerMessage(data.list);
    gcore.GlobalEvent.fire(HeroExpeditEvent.EmployEvent);
  },
  // 已派出伙伴信息
  sender24405: function sender24405() {
    this.SendProtocal(24405, {});
  },
  hander24405: function hander24405(data) {
    this.model.setHeroSendRedPoint(data.list.length);
    gcore.GlobalEvent.fire(HeroExpeditEvent.EmploySendEvent, data);
  },
  // 雇佣伙伴
  sender24406: function sender24406() {
    this.SendProtocal(24406, {});
  },
  hander24406: function hander24406(data) {
    this.model.setEmployPartner(data.list);
  },
  // 派出伙伴
  sender24407: function sender24407(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(24407, proto);
  },
  hander24407: function hander24407(data) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(HeroExpeditEvent.EmploySendEvent_Success, data.id);
    }
  },
  // 英雄出战
  sender24409: function sender24409() {
    this.SendProtocal(24409, {});
  },
  hander24409: function hander24409(data) {
    this.model.setHeroBloodById(data);
  },
  // 远征红点,仅限过关
  sender24410: function sender24410() {
    this.SendProtocal(24410, {});
  },
  hander24410: function hander24410(data) {
    this.model.setLevelRedPoint(data.is_show);
  },
  // 雇佣伙伴
  sender24408: function sender24408(rid, srv_id, id) {
    var proto = {};
    proto.rid = rid;
    proto.srv_id = srv_id;
    proto.id = id;
    this.SendProtocal(24408, proto);
  },
  hander24408: function hander24408(data) {
    message(data.msg);
  },
  // 打开远征界面
  openHeroExpeditView: function openHeroExpeditView(bool) {
    if (bool == true) {
      var open_data = Config.dailyplay_data.data_exerciseactivity[EsecsiceConst.execsice_index.heroexpedit];
 
      if (open_data == null) {
        message(Utils.TI18N("远征数据异常"));
        return;
      }
 
      var bool = MainuiController.getInstance().checkIsOpenByActivate(open_data.activate);
 
      if (bool == false) {
        message(open_data.lock_desc);
        return;
      }
 
      if (!this.heroExpeditView) {
        this.heroExpeditView = Utils.createClass("heroexpedit_window", this);
      }
 
      if (this.heroExpeditView && this.heroExpeditView.isOpen() == false) {
        this.heroExpeditView.open();
      }
    } else {
      if (this.heroExpeditView) {
        this.heroExpeditView.close();
        this.heroExpeditView = null;
      }
    }
  },
  // 打开远征关卡信息界面
  openHeroExpeditLevelView: function openHeroExpeditLevelView(bool, data) {
    if (bool == true) {
      if (!this.heroExpeditLevelView) {
        this.heroExpeditLevelView = Utils.createClass("heroexpedit_level_window", this);
      }
 
      if (this.heroExpeditLevelView && this.heroExpeditLevelView.isOpen() == false) {
        this.heroExpeditLevelView.open(data);
      }
    } else {
      if (this.heroExpeditLevelView) {
        this.heroExpeditLevelView.close();
        this.heroExpeditLevelView = null;
      }
    }
  },
  // 打开远征雇佣界面
  openEmpolyPanelView: function openEmpolyPanelView(bool) {
    if (bool == true) {
      if (!this.empolyPanelView) {
        this.empolyPanelView = Utils.createClass("empoly_window", this);
      }
 
      if (this.empolyPanelView && this.empolyPanelView.isOpen() == false) {
        this.empolyPanelView.open();
      }
    } else {
      if (this.empolyPanelView) {
        this.empolyPanelView.close();
        this.empolyPanelView = null;
      }
    }
  },
  // 打开查看宝箱奖励
  openBrowsePanelView: function openBrowsePanelView(bool, data) {
    if (bool == true && data) {
      if (!this.browsePanelView) {
        this.browsePanelView = Utils.createClass("browse_window", this);
      }
 
      if (this.browsePanelView && this.browsePanelView.isOpen() == false) {
        this.browsePanelView.open(data);
      }
    } else {
      if (this.browsePanelView) {
        this.browsePanelView.close();
        this.browsePanelView = null;
      }
    }
  },
  __delete: function __delete() {}
});
module.exports = HeroexpeditController;
 
cc._RF.pop();