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
"use strict";
cc._RF.push(module, '38414tz0/NM7qQqsbBWz8f0', 'partnersummon_controller');
// Scripts/mod/partnersummon/partnersummon_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: {DATE}
// --------------------------------------------------------------------
var SummonEvent = require("partnersummon_event");
 
var MainuiEvent = require("mainui_event");
 
var BattleEvent = require("battle_event");
 
var PartnersummonController = cc.Class({
  "extends": BaseController,
  properties: {
    partner_summon_window: null
  },
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var PartnersummonModel = require("partnersummon_model");
 
    this.model = new PartnersummonModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    // 登录先请求一下 
    if (!this.init_role_event) {
      this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
        gcore.GlobalEvent.unbind(this.init_role_event); // this.send23200();                 
      }.bind(this));
    } // 断线重连的时候
 
 
    if (!this.re_link_game_event) {
      this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {
        var GuideController = require("guide_controller");
 
        if (!GuideController.getInstance().isInGuide()) this.openPartnerSummonWindow(false);
      }.bind(this));
    } // 新获得伙伴弹窗
 
 
    if (!this.get_new_partner_event) {
      this.get_new_partner_event = gcore.GlobalEvent.bind(MainuiEvent.CLOSE_ITEM_VIEW, function () {
        if (this.is_add_partner && this.add_partner_data) {
          this.openSummonGainShowWindow(true, [this.add_partner_data]);
          this.is_add_partner = false;
          this.add_partner_data = null;
        }
      }.bind(this));
    } // 关闭召唤界面后弹出
 
 
    if (!this.battle_result_event) {
      this.battle_result_event = gcore.GlobalEvent.bind(BattleEvent.CLOSE_RESULT_VIEW, function () {
        if (this.is_add_partner && this.add_partner_data) {
          this.openSummonGainShowWindow(true, [this.add_partner_data]);
          this.is_add_partner = false;
          this.add_partner_data = null;
        }
      }.bind(this));
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    // 普通召唤
    this.RegisterProtocal(23200, this.handle23200.bind(this)); //请求召唤信息
 
    this.RegisterProtocal(23201, this.handle23201.bind(this)); //召唤
 
    this.RegisterProtocal(23202, this.handle23202.bind(this)); //更新召唤通用信息
 
    this.RegisterProtocal(23203, this.handle23203.bind(this)); //领取召唤分享奖励
 
    this.RegisterProtocal(23204, this.handle23204.bind(this)); //跟新单个召唤卡库信息
 
    this.RegisterProtocal(11095, this.handle11095.bind(this)); //其他途径获得伙伴推送
 
    this.RegisterProtocal(23212, this.handle23212.bind(this)); //推送新卡库开启
 
    this.RegisterProtocal(23205, this.handle23205.bind(this)); //必出5星
    // 11001
  },
  // 请求召唤信息
  send23200: function send23200() {
    var protocal = {};
    this.SendProtocal(23200, protocal);
  },
  handle23200: function handle23200(summon_data) {
    if (summon_data) this.model.setSummonData(summon_data);
  },
  send23201: function send23201(group_id, times, recruit_type) {
    var protocal = {};
    protocal.group_id = group_id;
    protocal.times = times;
    protocal.recruit_type = recruit_type;
    this.SendProtocal(23201, protocal);
  },
  handle23201: function handle23201(recruit_data) {
    // 召唤信息
    if (recruit_data) {
      this.model.setRecruitData(recruit_data);
      gcore.GlobalEvent.fire(SummonEvent.PartnerSummonSuccess);
    } // this.openSummonGainWindow(true);
 
  },
  handle23202: function handle23202(summon_data) {
    if (summon_data) this.model.updateSummonData(summon_data);
  },
  handle23203: function handle23203() {},
  handle23204: function handle23204() {},
  sender23205: function sender23205() {
    this.SendProtocal(23205, {});
  },
  handle23205: function handle23205(data) {
    this.five_star_data = data;
    gcore.GlobalEvent.fire(SummonEvent.PartnerSummonFiveStar, data);
  },
  //获取5星必出数据
  getFiveStarData: function getFiveStarData() {
    return this.five_star_data;
  },
  handle11095: function handle11095(data) {
    if (data.status == 1) {
      this.openSummonGainShowWindow(true, data);
    } else {
      this.is_add_partner = true;
      this.add_partner_data = data;
    }
  },
  handle23212: function handle23212() {},
  scoreRecruit: function scoreRecruit(group_id, times, recruit_type) {
    if (this.partner_summon_window) {
      this.partner_summon_window.startRecruit(group_id, times, recruit_type);
    }
  },
  // 再次召唤
  againRecruit: function againRecruit() {
    if (this.partner_summon_window) {
      this.partner_summon_window.regainRecruit();
    }
  },
  recurit: function recurit(group_id, times, recruit_type) {
    this.partner_summon_window.sendRecruitProtocal(group_id, times, recruit_type); // againRecruit
  },
  // 主界面
  openPartnerSummonWindow: function openPartnerSummonWindow(status) {
    if (status === false) {
      if (this.partner_summon_window) {
        this.partner_summon_window.close();
        this.partner_summon_window = null;
      }
    } else {
      if (!this.partner_summon_window) {
        var SummonWindow = require("partnersummon_window");
 
        this.partner_summon_window = new SummonWindow(this);
      }
 
      this.partner_summon_window.open();
      this.model.setOpenPartnerSummonFlag(true);
    }
  },
  // 获得伙伴弹窗
  openSummonGainWindow: function openSummonGainWindow(status, data) {
    if (!status) {
      if (!this.summon_gain_window) return;
      this.summon_gain_window.close();
      this.summon_gain_window = null;
    } else {
      if (!this.summon_gain_window) {
        var SummonGainWindow = require("partnersummon_gain_window");
 
        this.summon_gain_window = new SummonGainWindow(this, data);
      }
 
      this.summon_gain_window.open();
    }
  },
  // 展示高级英雄
  openSummonGainShowWindow: function openSummonGainShowWindow(status, show_bids, finish_cb, bg_type) {
    if (!status) {
      if (!this.summon_show_window) return;
      this.summon_show_window.close();
      this.summon_show_window = null;
    } else {
      if (show_bids.length == 1) {
        var config;
        config = Config.partner_data.data_partner_base[show_bids[0].partner_bid];
        if (!config || !config.show_effect || config.show_effect != 1) return;
      }
 
      if (!this.summon_show_window) {
        var SummonShowWindow = require("partnersummon_show_window");
 
        this.summon_show_window = new SummonShowWindow(this, show_bids, finish_cb, bg_type);
      }
 
      this.summon_show_window.open();
    }
  },
  // 积分召唤提示
  openScoreTipWindow: function openScoreTipWindow(status) {
    if (!status) {
      if (!this.summon_score_window) require;
      this.summon_score_window.close();
      this.summon_score_window = null;
    } else {
      if (!this.summon_score_window) {
        var SummonScoreWindow = require("partnersummon_score_window");
 
        this.summon_score_window = new SummonScoreWindow(this);
      }
 
      this.summon_score_window.open();
    }
  },
  getSummonItemRoot: function getSummonItemRoot(name, get_cb) {
    if (this.partner_summon_window) {
      return this.partner_summon_window.root_wnd;
    }
  },
  getSummonResultRoot: function getSummonResultRoot() {
    if (this.summon_gain_window) {
      return this.summon_gain_window.root_wnd;
    }
  },
  getSummonShowRoot: function getSummonShowRoot() {
    if (this.summon_show_window) return this.summon_show_window.root_wnd;
  }
});
module.exports = PartnersummonController;
 
cc._RF.pop();