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
"use strict";
cc._RF.push(module, '500d4JGxaZCYoRxcfgT5eE5', 'arena_champion_cur_guess_panel');
// Scripts/mod/arena/view/champion/arena_champion_cur_guess_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-13 11:42:08
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var ArenaEvent = require("arena_event");
 
var ArenaConst = require("arena_const");
 
var BattleController = require("battle_controller");
 
var ArenaChampionCurGuessPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("arena", "arena_champion_cur_guess_panel");
    this.ctrl = arguments[0];
    this.model = this.ctrl.getChamPionModel();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {},
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.main_panel_nd = this.seekChild("main_panel");
    this.container_nd = this.seekChild("container");
    this.guess_value_lb = this.seekChild("guess_value", cc.Label);
    this.left_name_lb = this.seekChild("left_name", cc.Label);
    this.right_name_lb = this.seekChild("right_name", cc.Label);
    this.left_total_value_lb = this.seekChild("left_total_value", cc.Label);
    this.right_total_value_lb = this.seekChild("right_total_value", cc.Label);
    this.left_guess_btn_nd = this.seekChild("left_guess_btn");
    this.right_guess_btn_nd = this.seekChild("right_guess_btn");
    this.left_btn_title_lb = this.seekChild("left_btn_title", cc.Label);
    this.right_btn_title_lb = this.seekChild("right_btn_title", cc.Label);
    this.left_guess_btn_nd.btn_tag = 1;
    this.right_guess_btn_nd.btn_tag = 2;
    this.left_guess_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickGussBtn, this);
    this.right_guess_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickGussBtn, this);
    this.progress_bar_pb = this.seekChild("progress_bar", cc.ProgressBar);
    var img = this.seekChild("item_img_2", cc.Sprite);
    this.loadRes(PathTool.getIconPath("item", "19"), function (res) {
      img.spriteFrame = res;
    }.bind(this));
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    // 更新竞猜的比赛数据
    this.addGlobalEvent(ArenaEvent.UpdateGuessMatchInfoEvent, function (data) {
      cc.log("竞猜数据");
      cc.log(data);
 
      if (data) {
        this.updateFightInfo(data);
      }
    }.bind(this)); // 冠军赛可押注资产变化
 
    this.addGlobalEvent(ArenaEvent.UpdateRoleInfoBetEvent, function (can_bit, bit_type) {
      can_bit = can_bit || 0;
      this.guess_value_lb.string = can_bit;
      this.changeGuessBtnStatus(bit_type);
    }.bind(this)); // 押注某场比赛的返回
 
    this.addGlobalEvent(ArenaEvent.UpdateBetMatchValueEvent, function (data) {
      if (data) {
        this.bet_data = data;
        this.updateBetMatchValue(data);
      }
 
      cc.log("押注后返回");
      cc.log(data);
    }.bind(this));
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.updageWidget(params);
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.vs_panel) {
      this.vs_panel.deleteMe();
      this.vs_panel = null;
    }
  },
  onVisible: function onVisible(status) {
    if (status) {
      this.is_change_tab = true;
    }
  },
  // 更新竞猜信息
  updateMyGuessList: function updateMyGuessList() {},
  // 主界面基础信息更新
  updateBaseInfo: function updateBaseInfo() {
    if (this.root_wnd) {
      this.updageWidget(); // this.ctrl.sender20253();
    }
  },
  updageWidget: function updageWidget() {
    var base_info = this.base_info = this.model.getBaseInfo();
    var role_info = this.role_info = this.model.getRoleInfo();
    if (!base_info || !role_info) return; // self.is_change_tab = status // 是否是切换面板的,如果是切换面板,在收到20252协议之后,要判断base是2的就要根据20252的录像id进去查看录像
 
    if (base_info.step == ArenaConst.champion_step.unopened || base_info.step == ArenaConst.champion_step.score && (base_info.round == 0 || base_info.round === 1 && base_info.round_status == ArenaConst.champion_round_status.prepare)) {
      this.root_wnd.active = false;
    } else {
      this.root_wnd.active = true; // if (base_info.flag !== 0) {
 
      this.ctrl.sender20253(); // }
    }
 
    this.guess_value_lb.string = role_info.can_bet;
  },
  updateFightInfo: function updateFightInfo(data) {
    if (!data) return;
 
    if (!this.vs_panel) {
      var VsPanel = require("arena_champion_vs_panel");
 
      this.vs_panel = new VsPanel();
      this.vs_panel.setParent(this.container_nd);
      this.vs_panel.show();
    }
 
    this.vs_panel.updateFightInfo(data); // if (!this.bet_data) {
 
    this.bet_data = data;
    this.updateBetMatchValue(data); // }
 
    if (this.root_wnd && this.root_wnd.active && !this.is_change_tab) {
      if (this.base_info && this.base_info.flag == 2 && data.replay_id != 0 && this.cur_data && !this.cur_data.replay_id) {
        var base_info_key = this.base_info.step + "_" + this.base_info.round;
        var data_key = data.step + "_" + data.round;
 
        if (base_info_key == data_key) {
          BattleController.getInstance().csRecordBattle(data.replay_id);
        }
      }
    }
 
    this.cur_data = data;
    this.is_change_tab = false;
  },
  updateBetMatchValue: function updateBetMatchValue(data) {
    var a_bet = data.a_bet || 0;
    var b_bet = data.b_bet || 0;
    this.left_total_value_lb.string = cc.js.formatStr(Utils.TI18N("赔率:%s"), parseInt(data.a_bet_ratio / 10) / 100);
    this.right_total_value_lb.string = cc.js.formatStr(Utils.TI18N("赔率:%s"), parseInt(data.b_bet_ratio / 10) / 100);
 
    if (this.bet_data) {
      this.bet_data.a_bet_ratio = data.a_bet_ratio;
      this.bet_data.b_bet_ratio = data.b_bet_ratio;
    }
 
    var total_bet = a_bet + b_bet;
 
    if (total_bet === 0) {
      this.progress_bar_pb.progress = 0.5;
    } else {
      this.progress_bar_pb.progress = a_bet / total_bet;
    } // name
 
 
    if (data.a_name) this.left_name_lb.string = data.a_name;
    if (data.b_name) this.right_name_lb.string = data.b_name;
    if (data.bet_type !== undefined) this.changeGuessBtnStatus(data.bet_type);
  },
  changeGuessBtnStatus: function changeGuessBtnStatus(bet_type) {
    bet_type = bet_type || 0;
    if (this.guess_bet_type == bet_type) return;
    this.guess_bet_type = bet_type;
    var l_btn_str = "";
    var r_btn_str = "";
 
    if (bet_type == 0) {
      l_btn_str = Utils.TI18N("竞猜");
      r_btn_str = Utils.TI18N("竞猜");
    } else {
      if (bet_type == 1) {
        l_btn_str = Utils.TI18N("已竞猜");
        r_btn_str = Utils.TI18N("竞猜");
      } else {
        l_btn_str = Utils.TI18N("竞猜");
        r_btn_str = Utils.TI18N("已竞猜");
      }
    }
 
    this.left_btn_title_lb.string = l_btn_str;
    this.right_btn_title_lb.string = r_btn_str;
  },
  onClickGussBtn: function onClickGussBtn(event) {
    cc.log(event.target.btn_tag);
    var info_index = "a_";
    if (event.target.btn_tag == 2) info_index = "b_";
 
    if (this.guess_bet_type !== 0) {
      message(Utils.TI18N("已经竞猜过啦"));
    } else {
      if (this.base_info && this.role_info && this.bet_data) {
        if (this.base_info.round_status == ArenaConst.champion_round_status.guess) {
          var data = {};
          data.name = this.bet_data[info_index + "name"];
          data.srv_id = this.bet_data[info_index + "srv_id"];
          data.rid = this.bet_data[info_index + "rid"];
          data.bet_ratio = this.bet_data[info_index + "bet_ratio"];
          data.can_bet = this.role_info.can_bet;
          data.bet_type = event.target.btn_tag;
          this.ctrl.openArenaChampionGuessWindow(true, data);
        } else {
          message(Utils.TI18N("当前阶段不可以押注"));
        }
      }
    }
  }
});
 
cc._RF.pop();