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
|
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class SuperRiskOpenboxHandler : DlgHandlerBase
{
private IXUITexture m_TopBox;
private XUIPool BoxPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private GameObject m_SpeedFrame;
private IXUILabel m_SpeedTime;
private IXUIButton m_SpeedButton;
private IXUILabelSymbol m_SpeedCost;
private IXUIButton m_StartButton;
private IXUILabel m_StartTime;
private IXUISprite m_CloseBg;
private XSuperRiskDocument _doc;
private int m_CurrentSlot = -1;
private float m_fCoolTime = 1f;
private float m_fLastClickBtnTime = 0f;
private float m_fLastClickBtnTime1 = 0f;
protected override void Init()
{
this._doc = (XSingleton<XGame>.singleton.Doc.GetXComponent(XSuperRiskDocument.uuID) as XSuperRiskDocument);
this.m_CloseBg = (base.PanelObject.transform.Find("Close").GetComponent("XUISprite") as IXUISprite);
this.m_TopBox = (base.PanelObject.transform.Find("Box").GetComponent("XUITexture") as IXUITexture);
Transform transform = base.PanelObject.transform.Find("List/Item");
this.BoxPool.SetupPool(transform.parent.gameObject, transform.gameObject, 3u, false);
this.m_SpeedFrame = base.PanelObject.transform.Find("SpeedFrame").gameObject;
this.m_SpeedTime = (base.PanelObject.transform.Find("SpeedFrame/Time").GetComponent("XUILabel") as IXUILabel);
this.m_SpeedButton = (base.PanelObject.transform.Find("SpeedFrame/SpeedBtn").GetComponent("XUIButton") as IXUIButton);
this.m_SpeedCost = (base.PanelObject.transform.Find("SpeedFrame/SpeedBtn/Cost").GetComponent("XUILabelSymbol") as IXUILabelSymbol);
this.m_StartButton = (base.PanelObject.transform.Find("OpenBtn").GetComponent("XUIButton") as IXUIButton);
this.m_StartTime = (base.PanelObject.transform.Find("OpenBtn/Time").GetComponent("XUILabel") as IXUILabel);
}
public override void RegisterEvent()
{
this.m_CloseBg.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnCloseClick));
this.m_SpeedButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSpeedClick));
this.m_StartButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnStartClick));
base.RegisterEvent();
}
protected void OnCloseClick(IXUISprite sp)
{
base.SetVisible(false);
}
protected override void OnHide()
{
this.m_CurrentSlot = -1;
base.OnHide();
}
public void ClearCatchTex()
{
this.m_TopBox.SetTexturePath("");
}
public void ShowBox(int slot)
{
base.SetVisible(true);
ClientBoxInfo clientBoxInfo = this._doc.SlotBoxInfo[slot];
bool flag = clientBoxInfo != null;
if (flag)
{
this.m_CurrentSlot = slot;
int num = -1;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)clientBoxInfo.itemID);
bool flag2 = itemConf != null;
if (flag2)
{
num = (int)itemConf.ItemQuality;
}
this.m_TopBox.SetTexturePath(this.GetBoxPicByState(clientBoxInfo.itemID, RiskBoxState.RISK_BOX_LOCKED));
this.BoxPool.ReturnAll(false);
int num2 = 0;
RiskMapFile.RowData currentMapData = this._doc.GetCurrentMapData();
for (int i = 0; i < currentMapData.BoxPreview.Count; i++)
{
bool flag3 = currentMapData.BoxPreview[i, 0] == num;
if (flag3)
{
num2++;
}
}
int num3 = -(num2 - 1) * this.BoxPool.TplWidth / 2;
int num4 = 0;
for (int j = 0; j < currentMapData.BoxPreview.Count; j++)
{
bool flag4 = currentMapData.BoxPreview[j, 0] == num;
if (flag4)
{
GameObject gameObject = this.BoxPool.FetchGameObject(false);
gameObject.transform.localPosition = new Vector3((float)(num3 + num4 * this.BoxPool.TplWidth), 0f, 0f);
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, currentMapData.BoxPreview[j, 1], currentMapData.BoxPreview[j, 2], false);
IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite.ID = (ulong)((long)currentMapData.BoxPreview[j, 1]);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
num4++;
}
}
bool flag5 = clientBoxInfo.state == RiskBoxState.RISK_BOX_LOCKED;
if (flag5)
{
this.m_StartButton.gameObject.SetActive(true);
this.m_SpeedFrame.SetActive(false);
this.m_StartTime.SetText(XSingleton<UiUtility>.singleton.TimeFormatString((int)clientBoxInfo.leftTime, 2, 3, 4, false, true));
}
bool flag6 = clientBoxInfo.state == RiskBoxState.RISK_BOX_UNLOCKED;
if (flag6)
{
this.m_StartButton.gameObject.SetActive(false);
this.m_SpeedFrame.SetActive(true);
SuperRiskSpeedCost speedCost = this._doc.GetSpeedCost(num);
bool flag7 = (int)clientBoxInfo.leftTime % speedCost.time == 0;
int cost;
if (flag7)
{
cost = (int)clientBoxInfo.leftTime / speedCost.time * speedCost.itemCount;
}
else
{
cost = ((int)clientBoxInfo.leftTime / speedCost.time + 1) * speedCost.itemCount;
}
this.m_SpeedCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(cost, (ItemEnum)speedCost.itemID);
}
bool flag8 = clientBoxInfo.state == RiskBoxState.RISK_BOX_CANGETREWARD || clientBoxInfo.state == RiskBoxState.RISK_BOX_GETREWARD;
if (flag8)
{
XSingleton<XDebug>.singleton.AddErrorLog("Wrong super risk state!", null, null, null, null, null);
}
}
}
public void BoxStateChange(int slot)
{
bool flag = slot != this.m_CurrentSlot;
if (!flag)
{
bool flag2 = this._doc.SlotBoxInfo.ContainsKey(slot);
if (flag2)
{
ClientBoxInfo clientBoxInfo = this._doc.SlotBoxInfo[slot];
bool flag3 = clientBoxInfo != null && clientBoxInfo.state == RiskBoxState.RISK_BOX_UNLOCKED;
if (flag3)
{
this.m_StartButton.gameObject.SetActive(false);
this.m_SpeedFrame.SetActive(true);
this.m_SpeedTime.SetText(XSingleton<UiUtility>.singleton.TimeFormatString((int)clientBoxInfo.leftTime, 0, 3, 4, false, true));
int quality = 1;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)clientBoxInfo.itemID);
bool flag4 = itemConf != null;
if (flag4)
{
quality = (int)itemConf.ItemQuality;
}
SuperRiskSpeedCost speedCost = this._doc.GetSpeedCost(quality);
bool flag5 = (int)clientBoxInfo.leftTime % speedCost.time == 0;
int cost;
if (flag5)
{
cost = (int)clientBoxInfo.leftTime / speedCost.time * speedCost.itemCount;
}
else
{
cost = ((int)clientBoxInfo.leftTime / speedCost.time + 1) * speedCost.itemCount;
}
this.m_SpeedCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(cost, (ItemEnum)speedCost.itemID);
}
bool flag6 = clientBoxInfo.state == RiskBoxState.RISK_BOX_CANGETREWARD;
if (flag6)
{
base.SetVisible(false);
}
}
else
{
base.SetVisible(false);
}
}
}
private string GetBoxPicByState(uint itemID, RiskBoxState state)
{
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemID);
bool flag = itemConf != null;
string result;
if (flag)
{
string text = XSingleton<XCommon>.singleton.StringCombine("atlas/UI/GameSystem/SuperRisk/bx", ((int)(itemConf.ItemQuality - 1)).ToString());
bool flag2 = state == RiskBoxState.RISK_BOX_UNLOCKED;
if (flag2)
{
text = XSingleton<XCommon>.singleton.StringCombine(text, "_1");
}
result = text;
}
else
{
result = "";
}
return result;
}
public bool OnSpeedClick(IXUIButton button)
{
bool flag = this.SetButtonCool(this.m_fCoolTime);
bool result;
if (flag)
{
result = true;
}
else
{
ClientBoxInfo clientBoxInfo = this._doc.SlotBoxInfo[this.m_CurrentSlot];
bool flag2 = clientBoxInfo == null;
if (flag2)
{
result = true;
}
else
{
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)clientBoxInfo.itemID);
bool flag3 = itemConf == null;
if (flag3)
{
result = true;
}
else
{
int itemQuality = (int)itemConf.ItemQuality;
SuperRiskSpeedCost speedCost = this._doc.GetSpeedCost(itemQuality);
ulong itemCount = XBagDocument.BagDoc.GetItemCount(speedCost.itemID);
bool flag4 = (int)clientBoxInfo.leftTime % speedCost.time == 0;
int num;
if (flag4)
{
num = (int)clientBoxInfo.leftTime / speedCost.time * speedCost.itemCount;
}
else
{
num = ((int)clientBoxInfo.leftTime / speedCost.time + 1) * speedCost.itemCount;
}
bool flag5 = (long)num > (long)itemCount;
if (flag5)
{
XSingleton<UiUtility>.singleton.ShowItemAccess(speedCost.itemID, null);
result = true;
}
else
{
this._doc.ChangeBoxState(this.m_CurrentSlot, RiskBoxState.RISK_BOX_CANGETREWARD);
result = true;
}
}
}
}
return result;
}
public bool OnStartClick(IXUIButton button)
{
bool flag = this.SetButtonCool1(this.m_fCoolTime);
bool result;
if (flag)
{
result = true;
}
else
{
foreach (KeyValuePair<int, ClientBoxInfo> keyValuePair in this._doc.SlotBoxInfo)
{
bool flag2 = keyValuePair.Value.state == RiskBoxState.RISK_BOX_UNLOCKED;
if (flag2)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("CannotUnLockAnyBox"), "fece00");
return true;
}
}
this._doc.ChangeBoxState(this.m_CurrentSlot, RiskBoxState.RISK_BOX_UNLOCKED);
result = true;
}
return result;
}
public override void OnUpdate()
{
base.OnUpdate();
bool flag = this.m_CurrentSlot == -1;
if (!flag)
{
bool flag2 = this._doc.SlotBoxInfo.ContainsKey(this.m_CurrentSlot);
if (flag2)
{
ClientBoxInfo clientBoxInfo = this._doc.SlotBoxInfo[this.m_CurrentSlot];
bool flag3 = clientBoxInfo.state == RiskBoxState.RISK_BOX_UNLOCKED;
if (flag3)
{
this.m_SpeedTime.SetText(XSingleton<UiUtility>.singleton.TimeFormatString((int)clientBoxInfo.leftTime, 2, 3, 4, false, true));
}
}
}
}
private bool SetButtonCool(float time)
{
float num = Time.realtimeSinceStartup - this.m_fLastClickBtnTime;
bool flag = num < time;
bool result;
if (flag)
{
result = true;
}
else
{
this.m_fLastClickBtnTime = Time.realtimeSinceStartup;
result = false;
}
return result;
}
private bool SetButtonCool1(float time)
{
float num = Time.realtimeSinceStartup - this.m_fLastClickBtnTime1;
bool flag = num < time;
bool result;
if (flag)
{
result = true;
}
else
{
this.m_fLastClickBtnTime1 = Time.realtimeSinceStartup;
result = false;
}
return result;
}
}
}
|