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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class SevenLoginDlg : DlgBase<SevenLoginDlg, SevenLoginBehaviour>
{
public override string fileName
{
get
{
return "GameSystem/SevenAwardDlg";
}
}
public override int sysid
{
get
{
return XFastEnumIntEqualityComparer<XSysDefine>.ToInt(XSysDefine.XSys_SevenActivity);
}
}
public override int layer
{
get
{
return 1;
}
}
public override bool pushstack
{
get
{
return true;
}
}
public override bool autoload
{
get
{
return true;
}
}
private XSevenLoginDocument _Doc;
private List<SevenLoginWrapItem> m_WrapContentItems;
private int m_wrapContentHeight = 104;
private Vector3 m_RewardStartPos = Vector3.zero;
private uint m_TimeRecord = 0u;
private List<XFx> m_ItemEffectList;
private Vector3 m_ItemScale;
private string m_dialogSharedLocation = string.Empty;
private int mCurDayID = 0;
public override void RegisterEvent()
{
base.RegisterEvent();
base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickCloseHandle));
base.uiBehaviour.m_dialogClose.RegisterClickEventHandler(new ButtonClickEventHandler(this.ClickDialogClose));
}
protected override void Init()
{
base.Init();
this._Doc = XDocuments.GetSpecificDocument<XSevenLoginDocument>(XSevenLoginDocument.uuID);
this._Doc.SevenLoginView = this;
base.uiBehaviour.m_dialogTransform.gameObject.SetActive(false);
}
protected override void OnLoad()
{
base.OnLoad();
this.m_WrapContentItems = new List<SevenLoginWrapItem>();
this.m_ItemEffectList = new List<XFx>();
this.m_ItemScale = new Vector3(0.8f, 0.8f, 0.8f);
}
protected override void OnUnload()
{
bool flag = this.m_WrapContentItems != null;
if (flag)
{
int i = 0;
int count = this.m_WrapContentItems.Count;
while (i < count)
{
this.m_WrapContentItems[i] = null;
i++;
}
this.m_WrapContentItems.Clear();
this.m_WrapContentItems = null;
}
bool flag2 = this.m_ItemEffectList != null;
if (flag2)
{
int j = 0;
int count2 = this.m_ItemEffectList.Count;
while (j < count2)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_ItemEffectList[j], true);
j++;
}
this.m_ItemEffectList.Clear();
this.m_ItemEffectList = null;
}
this.ClearShardTexture();
this.ClearDialogSharedTexture();
this._Doc.SevenLoginView = null;
base.OnUnload();
}
private void ClearEffectList()
{
bool flag = this.m_ItemEffectList != null;
if (flag)
{
int i = 0;
int count = this.m_ItemEffectList.Count;
while (i < count)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_ItemEffectList[i], true);
i++;
}
this.m_ItemEffectList.Clear();
}
}
protected override void OnShow()
{
base.OnShow();
this.Refresh();
}
protected override void OnHide()
{
int i = 0;
int count = this.m_ItemEffectList.Count;
while (i < count)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_ItemEffectList[i], true);
i++;
}
XSingleton<XTimerMgr>.singleton.KillTimer(this.m_TimeRecord);
base.OnHide();
}
public void Refresh()
{
this.ConfigSevenItemList();
this.ConfigSevenMessage();
this.ConfigImportTime(null);
}
public void ShowDialogSheredTexture()
{
bool flag = this._Doc.NextImportItem == 0;
if (!flag)
{
this.ClearDialogSharedTexture();
string dialogSharedString = this._Doc.GetDialogSharedString();
bool flag2 = string.IsNullOrEmpty(dialogSharedString) || dialogSharedString.Equals(this.m_dialogSharedLocation);
if (!flag2)
{
base.uiBehaviour.m_dialogTexture.SetTexturePath(dialogSharedString);
this.m_dialogSharedLocation = dialogSharedString;
base.uiBehaviour.m_dialogTransform.gameObject.SetActive(true);
base.uiBehaviour.m_dialogTexture.MakePixelPerfect();
}
}
}
private bool ClickDialogClose(IXUIButton btn)
{
base.uiBehaviour.m_dialogTransform.gameObject.SetActive(false);
return true;
}
private bool OnClickCloseHandle(IXUIButton btn)
{
this.SetVisibleWithAnimation(false, null);
return true;
}
private void ConfigImportTime(object o)
{
XSingleton<XTimerMgr>.singleton.KillTimer(this.m_TimeRecord);
int lastSecond = this._Doc.GetLastSecond();
bool flag = lastSecond > 0;
if (flag)
{
ItemList.RowData itemConf = XBagDocument.GetItemConf(this._Doc.NextImportItem);
base.uiBehaviour.m_LoginDayLabel.SetText(XStringDefineProxy.GetString("SEVEN_LOGIN_TIMERECORD", new object[]
{
(itemConf == null) ? string.Empty : itemConf.ItemName[0],
XSingleton<UiUtility>.singleton.TimeDuarationFormatString(lastSecond, 3)
}));
this.m_TimeRecord = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.ConfigImportTime), null);
}
else
{
base.uiBehaviour.m_LoginDayLabel.SetText(string.Empty);
}
}
private void ConfigSevenMessage()
{
bool flag = this._Doc.NextImportDay > 0;
if (flag)
{
base.uiBehaviour.m_MessageLabel.SetVisible(true);
string key = XSingleton<XCommon>.singleton.StringCombine("SEVEN_LOGIN_MESSAGE", this._Doc.NextImportDay.ToString());
ItemList.RowData itemConf = XBagDocument.GetItemConf(this._Doc.NextImportItem);
base.uiBehaviour.m_MessageLabel.SetText(XStringDefineProxy.GetString(key, new object[]
{
this._Doc.NextImportDay,
(itemConf == null) ? string.Empty : itemConf.ItemName[0]
}));
string sharedString = this._Doc.GetSharedString();
base.uiBehaviour.m_shardTexture.SetTexturePath(sharedString);
}
else
{
this.ResetShow();
base.uiBehaviour.m_MessageLabel.SetVisible(false);
}
}
private void ClearShardTexture()
{
base.uiBehaviour.m_shardTexture.SetTexturePath("");
}
private void ClearDialogSharedTexture()
{
this.m_uiBehaviour.m_dialogTexture.SetTexturePath("");
this.m_dialogSharedLocation = string.Empty;
}
private void ResetShow()
{
int i = 0;
int count = this.m_ItemEffectList.Count;
while (i < count)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_ItemEffectList[i], true);
i++;
}
}
private void ConfigSevenItemList()
{
this.ClearEffectList();
int i = this.m_WrapContentItems.Count;
List<LoginReward> loginRewards = this._Doc.LoginRewards;
loginRewards.Sort(new Comparison<LoginReward>(this.CompareWrapItem));
int count = loginRewards.Count;
Vector3 localPosition = base.uiBehaviour.m_WrapContentTemp.localPosition;
while (i < count)
{
GameObject gameObject = XCommon.Instantiate<GameObject>(base.uiBehaviour.m_WrapContentTemp.gameObject);
gameObject.SetActive(true);
gameObject.name = XSingleton<XCommon>.singleton.StringCombine("WrapItem_", i.ToString());
gameObject.transform.parent = base.uiBehaviour.m_WrapContentScrollView.gameObject.transform;
gameObject.transform.localScale = Vector3.one;
gameObject.transform.localPosition = localPosition;
localPosition.y += (float)this.m_wrapContentHeight;
SevenLoginWrapItem sevenLoginWrapItem = new SevenLoginWrapItem();
sevenLoginWrapItem.Init(gameObject.transform);
this.m_WrapContentItems.Add(sevenLoginWrapItem);
sevenLoginWrapItem.m_GetButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGetRewardClick));
i++;
}
base.uiBehaviour.m_RewardPool.FakeReturnAll();
for (int j = 0; j < i; j++)
{
bool flag = j < count;
if (flag)
{
this.WrapContentItemUpdated(this.m_WrapContentItems[j], loginRewards[j]);
}
else
{
this.WrapContentItemUpdated(this.m_WrapContentItems[j], null);
}
XSingleton<XGameUI>.singleton.m_uiTool.MarkParentAsChanged(this.m_WrapContentItems[j].transform.gameObject);
}
base.uiBehaviour.m_RewardPool.ActualReturnAll(false);
base.uiBehaviour.m_WrapContentScrollView.ResetPosition();
}
private bool OnGetRewardClick(IXUIButton btn)
{
this.mCurDayID = (int)btn.ID;
int num = (int)XBagDocument.BagDoc.GetVirtualItemCount(ItemEnum.FATIGUE);
uint redayFatigue = this._Doc.GetRedayFatigue(this.mCurDayID);
int @int = XSingleton<XGlobalConfig>.singleton.GetInt("MaxFatigue");
bool flag = redayFatigue > 0u && (long)num + (long)((ulong)redayFatigue) > (long)@int;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowFatigueSureDlg(new ButtonClickEventHandler(this.GetSureLogReward));
}
else
{
btn.SetEnable(false, false);
this.GetSureLogReward(null);
}
return true;
}
private bool GetSureLogReward(IXUIButton btn)
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
this._Doc.GetLoginReward(this.mCurDayID);
return true;
}
private void SetItemEffect(GameObject parent, string effectName)
{
bool flag = string.IsNullOrEmpty(effectName);
if (!flag)
{
XFx xfx = XSingleton<XFxMgr>.singleton.CreateUIFx(effectName, parent.transform, false);
bool flag2 = xfx != null;
if (flag2)
{
this.m_ItemEffectList.Add(xfx);
}
}
}
private void WrapContentItemUpdated(SevenLoginWrapItem slwi, LoginReward reward)
{
bool flag = reward == null;
if (flag)
{
slwi.Set(null);
}
else
{
List<ItemBrief> items = reward.items;
slwi.Set(reward);
int i = 0;
int count = items.Count;
while (i < count)
{
GameObject gameObject = base.uiBehaviour.m_RewardPool.FetchGameObject(false);
gameObject.transform.parent = slwi.RewardParent;
gameObject.transform.localPosition = new Vector3(this.m_RewardStartPos.x + (float)(i * 75), this.m_RewardStartPos.y, this.m_RewardStartPos.z);
gameObject.transform.localScale = this.m_ItemScale;
IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
IXUISprite ixuisprite2 = gameObject.transform.Find("Quality").GetComponent("XUISprite") as IXUISprite;
ixuisprite.ID = (ulong)items[i].itemID;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)items[i].itemID);
this.SetItemEffect(ixuisprite2.gameObject, itemConf.ItemEffect);
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, itemConf, (int)items[i].itemCount, false);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
i++;
}
}
}
private int CompareWrapItem(LoginReward reward1, LoginReward reward2)
{
bool flag = reward1.state == reward2.state;
int result;
if (flag)
{
result = reward2.day - reward1.day;
}
else
{
result = this.GetSortIndexByState(reward1.state) - this.GetSortIndexByState(reward2.state);
}
return result;
}
private int GetSortIndexByState(LoginRewardState state)
{
int result = 0;
switch (state)
{
case LoginRewardState.LOGINRS_CANNOT:
result = 2;
break;
case LoginRewardState.LOGINRS_HAVEHOT:
result = 3;
break;
case LoginRewardState.LOGINRS_HAVE:
result = 1;
break;
}
return result;
}
}
}
|