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
"use strict";
cc._RF.push(module, '37b0araJRtEkKK/cygIgYP6', 'primus_controller');
// Scripts/mod/primus/primus_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-03-16 10:23:00
// --------------------------------------------------------------------
var PrimusController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var PrimusModel = require("primus_model");
 
    this.model = new PrimusModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {},
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    // this.RegisterProtocal(1110, this.on1110);
    this.RegisterProtocal(20700, this.handle20700); //请求玩家挑战次数
 
    this.RegisterProtocal(20701, this.handle20701); //请求挑战位置信息
 
    this.RegisterProtocal(20702, this.handle20702); //请求发起挑战
 
    this.RegisterProtocal(20703, this.handle20703); //请求挑战记录
 
    this.RegisterProtocal(20705, this.handle20705); //请求挑战结束
  },
  // 请求玩家挑战次数
  requestPrimusChallengeCount: function requestPrimusChallengeCount() {
    var protocal = {};
    this.SendProtocal(20700, protocal);
  },
  handle20700: function handle20700(data) {
    this.model.recordChallengeCount(data);
 
    var PrimusEvent = require("primus_event");
 
    gcore.GlobalEvent.fire(PrimusEvent.Updata_Primus_RedPoint);
  },
  // 请求挑战位置信息
  sender20701: function sender20701() {
    var protocal = {};
    this.SendProtocal(20701, protocal);
  },
  handle20701: function handle20701(data) {
    if (data && this.primus_main_window) {
      this.primus_main_window.setData(data);
    }
  },
  // 请求发起挑战
  sender20702: function sender20702(pos, num) {
    var protocal = {};
    protocal.pos = pos;
    protocal.num = num;
    this.SendProtocal(20702, protocal);
  },
  handle20702: function handle20702(data) {
    message(data.msg);
 
    if (data.code == true) {
      this.openPrimusChallengePanel(false);
    }
  },
  // 请求挑战记录
  sender20703: function sender20703(pos) {
    var protocal = {};
    protocal.pos = pos;
    this.SendProtocal(20703, protocal);
  },
  handle20703: function handle20703(data) {
    // -- message(data.msg)
    this.openPrimusChallengeRecordPanel(true, data);
  },
  // 战斗结果
  handle20705: function handle20705(data) {
    // -- message(data.msg)
    this.openPrimusChallengeResultWindow(true, data);
  },
  //  打开荣耀神殿主角界面
  openPrimusMainWindow: function openPrimusMainWindow(status) {
    if (status == false) {
      if (this.primus_main_window != null) {
        this.primus_main_window.close();
        this.primus_main_window = null;
      }
    } else {
      var EsecsiceConst = require("esecsice_const");
 
      var open_data = Config.dailyplay_data.data_exerciseactivity[EsecsiceConst.execsice_index.honourfane];
 
      if (open_data == null) {
        message(Utils.TI18N("星河神殿数据异常"));
        return;
      }
 
      var MainuiController = require("mainui_controller");
 
      var bool = MainuiController.getInstance().checkIsOpenByActivate(open_data.activate);
 
      if (bool == false) {
        message(open_data.lock_desc);
        return;
      }
 
      this.model.is_show_redpoint = false;
 
      if (this.primus_main_window == null) {
        this.primus_main_window = Utils.createClass("primus_main_window", this);
      }
 
      if (this.primus_main_window && this.primus_main_window.isOpen() == false) {
        this.primus_main_window.open();
      }
    }
  },
  //  打开荣耀神殿挑战界面
  openPrimusChallengePanel: function openPrimusChallengePanel(status, data, is_have_title) {
    if (status == false) {
      if (this.primus_challenge_panel != null) {
        this.primus_challenge_panel.close();
        this.primus_challenge_panel = null;
      }
    } else {
      if (this.primus_challenge_panel == null) {
        this.primus_challenge_panel = Utils.createClass("primus_challenge_window", this);
 
        if (this.primus_challenge_panel && this.primus_challenge_panel.isOpen() == false) {
          this.primus_challenge_panel.open([data, is_have_title]);
        }
      }
    }
  },
  //  打开荣耀神殿挑战界面
  openPrimusChallengeRecordPanel: function openPrimusChallengeRecordPanel(status, data) {
    if (status == false) {
      if (this.primus_challenge_record_panel != null) {
        this.primus_challenge_record_panel.close();
        this.primus_challenge_record_panel = null;
      }
    } else {
      if (this.primus_challenge_record_panel == null) {
        this.primus_challenge_record_panel = Utils.createClass("primus_challenge_record_window", this);
      }
 
      if (this.primus_challenge_record_panel && this.primus_challenge_record_panel.isOpen() == false) {
        this.primus_challenge_record_panel.open(data);
      }
    }
  },
  //  打开荣耀神殿挑战结果
  openPrimusChallengeResultWindow: function openPrimusChallengeResultWindow(status, data) {
    if (status == false) {
      if (this.primus_challenge_result_window != null) {
        this.primus_challenge_result_window.close();
        this.primus_challenge_result_window = null;
      }
    } else {
      if (this.primus_challenge_result_window == null) {
        this.primus_challenge_result_window = Utils.createClass("primus_challenge_result_window", this);
      }
 
      if (this.primus_challenge_result_window && this.primus_challenge_result_window.isOpen() == false) {
        this.primus_challenge_result_window.open(data);
      }
    }
  },
  //  判断是否开启星河神殿
  checkIsCanOpenPrimusWindow: function checkIsCanOpenPrimusWindow() {
    var RoleController = require("role_controller");
 
    var role_vo = RoleController.getInstance().getRoleVo();
    var lev = role_vo && role_vo.lev || 0;
    var limit_lev = Config.primus_data.data_const.open_lev.val;
 
    if (lev < limit_lev) {
      message(cc.js.formatStr(Utils.TI18N("等级达到%s级开启\"星河神殿\"玩法"), limit_lev));
      return false;
    }
 
    return true;
  },
  __delete: function __delete() {
    if (this.model != null) {
      this.model.DeleteMe();
      this.model = null;
    }
  }
});
module.exports = PrimusController;
 
cc._RF.pop();