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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI
{
public class XWelfareYyMallHandler : DlgHandlerBase
{
protected override string FileName
{
get
{
return "GameSystem/Welfare/YyMallHandler";
}
}
private const int colNum = 5;
private IXUIButton _refreshBtn;
private IXUIButton _detailBtn;
private IXUIScrollView _scrollView;
private IXUILabel _freeNumLabel;
private IXUILabel _privilegeFreeLabel;
private IXUILabel _dragonCoinLabel;
private IXUISprite _itemSprite;
private Transform _noneTimesTrans;
protected XUIPool _shopItemPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private XFx _refreshTaskEffect;
private Transform _effectPanel;
private IXUISprite _extraRefresh;
private IXUISprite _courtPrivilege;
private XYYMallCategoryHandler _XYYMallCategoryHandler;
protected override void Init()
{
base.Init();
this.InitProperties();
}
protected override void OnShow()
{
base.OnShow();
XWelfareDocument.Doc.RefreshYYMallRedPoint();
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
specificDocument.ReqGoodsList(XSysDefine.XSys_Welfare_YyMall);
bool flag = this._refreshTaskEffect != null;
if (flag)
{
this._refreshTaskEffect.SetActive(false);
}
}
public override void RegisterEvent()
{
base.RegisterEvent();
}
public override void RefreshData()
{
base.RefreshData();
this.RefreshScorllViewContent();
this.RefreshBtnState();
this.RefreshPrivilegeCount();
}
public override void OnUnload()
{
bool flag = this._refreshTaskEffect != null;
if (flag)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this._refreshTaskEffect, true);
}
DlgHandlerBase.EnsureUnload<XYYMallCategoryHandler>(ref this._XYYMallCategoryHandler);
base.OnUnload();
}
public void PlayRefreshEffect()
{
bool flag = this._refreshTaskEffect != null;
if (flag)
{
this._refreshTaskEffect.SetActive(true);
this._refreshTaskEffect.Play(this._effectPanel, Vector3.zero, Vector3.one, 1f, true, false);
}
}
private void RefreshPrivilegeCount()
{
int privilegeFreeRefreshCount = XWelfareDocument.Doc.GetPrivilegeFreeRefreshCount(MemberPrivilege.KingdomPrivilege_Adventurer);
int num = XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Adventurer) ? Math.Max(0, privilegeFreeRefreshCount - XWelfareDocument.Doc.PayMemberPrivilege.usedRefreshShopCount) : privilegeFreeRefreshCount;
this._privilegeFreeLabel.SetText(num + "/" + privilegeFreeRefreshCount);
this._courtPrivilege.SetGrey(XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court));
this._extraRefresh.SetGrey(XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Adventurer));
}
private void RefreshBtnState()
{
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
ShopTypeTable.RowData shopTypeData = specificDocument.GetShopTypeData(XSysDefine.XSys_Welfare_YyMall);
uint rereshCount = specificDocument.RereshCount;
this._refreshBtn.SetEnable(true, false);
bool flag = shopTypeData != null;
if (flag)
{
SeqRef<uint> refreshCount = shopTypeData.RefreshCount;
SeqListRef<uint> refreshCost = shopTypeData.RefreshCost;
bool flag2 = rereshCount >= refreshCount[0] + refreshCount[1];
if (flag2)
{
this._freeNumLabel.gameObject.SetActive(false);
this._dragonCoinLabel.gameObject.SetActive(false);
this._noneTimesTrans.gameObject.SetActive(true);
this._refreshBtn.SetEnable(false, false);
}
else
{
bool flag3 = rereshCount >= refreshCount[0];
if (flag3)
{
this._freeNumLabel.gameObject.SetActive(false);
this._dragonCoinLabel.gameObject.SetActive(true);
this._noneTimesTrans.gameObject.SetActive(false);
int index = (int)Mathf.Min(new float[]
{
rereshCount - refreshCount[0],
refreshCount[1] - 1u,
(float)(refreshCost.Count - 1)
});
int itemID = (int)refreshCost[index, 0];
ItemList.RowData itemConf = XBagDocument.GetItemConf(itemID);
bool flag4 = itemConf != null;
if (flag4)
{
this._itemSprite.SetSprite(itemConf.ItemIcon1[0]);
}
this._dragonCoinLabel.SetText(refreshCost[index, 1].ToString());
}
else
{
this._freeNumLabel.gameObject.SetActive(true);
this._dragonCoinLabel.gameObject.SetActive(false);
this._noneTimesTrans.gameObject.SetActive(false);
this._freeNumLabel.SetText(refreshCount[0] - rereshCount + "/" + refreshCount[0]);
}
}
}
}
private void RefreshScorllViewContent()
{
this._shopItemPool.ReturnAll(false);
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
List<XNormalShopGoods> goodsList = specificDocument.GoodsList;
for (int i = 0; i < goodsList.Count; i++)
{
XNormalShopGoods xnormalShopGoods = goodsList[i];
ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)xnormalShopGoods.item.uid);
bool flag = dataById != null;
if (flag)
{
float num = 0f;
GameObject gameObject = this._shopItemPool.FetchGameObject(false);
IXUISprite ixuisprite = gameObject.transform.Find("UnCompleted").GetComponent("XUISprite") as IXUISprite;
ixuisprite.gameObject.SetActive(false);
bool flag2 = i == 4 || i == 9;
if (flag2)
{
num = 15f;
bool flag3 = !XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court);
if (flag3)
{
ixuisprite.gameObject.SetActive(true);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnOpenCourtPriviege));
}
}
gameObject.transform.localPosition = this._shopItemPool.TplPos + new Vector3((float)(i % 5 * this._shopItemPool.TplWidth) + num, (float)(-(float)i / 5 * this._shopItemPool.TplHeight), 0f);
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject.transform.Find("Item").gameObject, xnormalShopGoods.item.itemID, (int)dataById.ItemOverlap, false);
IXUISprite ixuisprite2 = gameObject.transform.Find("Item/Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite2.ID = (ulong)((long)xnormalShopGoods.item.itemID);
ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickItemIcon));
IXUIButton ixuibutton = gameObject.transform.Find("BtnBuy").GetComponent("XUIButton") as IXUIButton;
ixuibutton.ID = (ulong)((long)i);
ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBuyShopItem));
IXUISprite ixuisprite3 = gameObject.transform.Find("BtnBuy/MoneyCost/Icon").GetComponent("XUISprite") as IXUISprite;
string itemSmallIcon = XBagDocument.GetItemSmallIcon(xnormalShopGoods.priceType, 0u);
ixuisprite3.SetSprite(itemSmallIcon);
Transform transform = gameObject.transform.Find("buyed2");
transform.gameObject.SetActive(dataById.IsPrecious);
GameObject gameObject2 = gameObject.transform.Find("discount").gameObject;
gameObject2.SetActive(dataById.Benefit[1] > 0u && dataById.Benefit[1] != 100u);
IXUILabel ixuilabel = gameObject.transform.Find("discount/t").GetComponent("XUILabel") as IXUILabel;
float num2 = dataById.Benefit[1] / 10f;
ixuilabel.SetText(num2.ToString());
IXUILabel ixuilabel2 = gameObject.transform.Find("BtnBuy/MoneyCost").GetComponent("XUILabel") as IXUILabel;
ixuilabel2.SetText(Mathf.FloorToInt((float)xnormalShopGoods.priceValue * num2 / 10f).ToString());
GameObject gameObject3 = gameObject.transform.Find("buyed").gameObject;
uint dailyCountCondition = (uint)dataById.DailyCountCondition;
int weekCountCondition = (int)dataById.WeekCountCondition;
int num3 = 0;
bool flag4 = dataById.CountCondition > 0u;
if (flag4)
{
num3 = xnormalShopGoods.totalSoldNum;
}
else
{
bool flag5 = dailyCountCondition > 0u;
if (flag5)
{
num3 = xnormalShopGoods.soldNum;
}
else
{
bool flag6 = weekCountCondition != 0;
if (flag6)
{
num3 = (int)xnormalShopGoods.weeklyBuyCount;
}
}
}
int countCondition = (int)dataById.CountCondition;
bool flag7 = dailyCountCondition == 0u && countCondition == 0 && weekCountCondition == 0;
if (flag7)
{
ixuibutton.SetEnable(true, false);
}
else
{
bool flag8 = countCondition != 0;
if (flag8)
{
bool flag9 = num3 >= countCondition;
if (flag9)
{
ixuibutton.SetEnable(false, false);
gameObject3.SetActive(true);
}
else
{
ixuibutton.SetEnable(true, false);
gameObject3.SetActive(false);
}
}
else
{
bool flag10 = dailyCountCondition != 0u && (long)num3 >= (long)((ulong)dailyCountCondition);
if (flag10)
{
ixuibutton.SetEnable(false, false);
gameObject3.SetActive(true);
}
else
{
bool flag11 = weekCountCondition != 0 && num3 >= weekCountCondition;
if (flag11)
{
ixuibutton.SetEnable(false, false);
gameObject3.SetActive(false);
}
else
{
ixuibutton.SetEnable(true, false);
gameObject3.SetActive(false);
}
}
}
}
}
}
this._scrollView.ResetPosition();
}
private void OnOpenAdventurerPriviege(IXUISprite uiSprite)
{
bool flag = !XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Adventurer);
if (flag)
{
XSingleton<UiUtility>.singleton.ShowModalDialog(XStringDefineProxy.GetString("KingdomPrivilege_Adventurer2Unlock"), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.OpenAdventurePriviege));
}
}
private bool OpenAdventurePriviege(IXUIButton button)
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_Welfare_KingdomPrivilege_Adventurer, 0UL);
return true;
}
private void OnOpenCourtPriviege(IXUISprite uiSprite)
{
bool flag = !XWelfareDocument.Doc.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court);
if (flag)
{
XSingleton<UiUtility>.singleton.ShowModalDialog(XStringDefineProxy.GetString("KingdomPrivilege_Court2Unlock"), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.OpenCourtPriviege));
}
}
private bool OpenCourtPriviege(IXUIButton button)
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_Welfare_KingdomPrivilege_Court, 0UL);
return true;
}
private void OnClickItemIcon(IXUISprite spr)
{
bool flag = spr.ID > 0UL;
if (flag)
{
XItem mainItem = XBagDocument.MakeXItem((int)spr.ID, false);
XSingleton<UiUtility>.singleton.ShowTooltipDialogWithSearchingCompare(mainItem, spr, false, 0u);
}
}
private bool OnBuyShopItem(IXUIButton button)
{
int index = (int)button.ID;
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
specificDocument.ReqBuy(index);
return true;
}
private void InitProperties()
{
Transform transform = base.transform.Find("ShopItemList");
GameObject gameObject = transform.Find("ShopItemTpl").gameObject;
this._shopItemPool.SetupPool(transform.gameObject, gameObject, 8u, false);
this._scrollView = (transform.GetComponent("XUIScrollView") as IXUIScrollView);
this._refreshBtn = (base.transform.Find("BtnRefresh").GetComponent("XUIButton") as IXUIButton);
this._refreshBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshShopList));
this._detailBtn = (base.transform.Find("Detail").GetComponent("XUIButton") as IXUIButton);
this._detailBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickOnDetail));
this._freeNumLabel = (base.transform.Find("BtnRefresh/FreeNum").GetComponent("XUILabel") as IXUILabel);
this._privilegeFreeLabel = (base.transform.Find("ExtraRefresh/Count").GetComponent("XUILabel") as IXUILabel);
this._dragonCoinLabel = (base.transform.Find("BtnRefresh/DragonCoinNum").GetComponent("XUILabel") as IXUILabel);
this._noneTimesTrans = base.transform.Find("BtnRefresh/NoneTimes");
this._itemSprite = (base.transform.Find("BtnRefresh/DragonCoinNum/p").GetComponent("XUISprite") as IXUISprite);
this._effectPanel = base.transform.Find("Effect");
this._refreshTaskEffect = XSingleton<XFxMgr>.singleton.CreateFx("Effects/FX_Particle/UIfx/UI_YyMallHandler_Clip01", null, true);
this._refreshTaskEffect.SetActive(false);
this._courtPrivilege = (base.transform.Find("Privilege").GetComponent("XUISprite") as IXUISprite);
this._courtPrivilege.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnOpenCourtPriviege));
this._extraRefresh = (base.transform.Find("ExtraRefresh").GetComponent("XUISprite") as IXUISprite);
this._extraRefresh.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnOpenAdventurerPriviege));
DlgHandlerBase.EnsureCreate<XYYMallCategoryHandler>(ref this._XYYMallCategoryHandler, base.transform, false, this);
}
private bool OnClickOnDetail(IXUIButton button)
{
bool flag = this._XYYMallCategoryHandler != null;
if (flag)
{
this._XYYMallCategoryHandler.SetVisible(true);
}
return true;
}
private bool OnRefreshShopList(IXUIButton button)
{
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
bool flag = specificDocument.CanBuyPreciousShopItem();
if (flag)
{
XSingleton<UiUtility>.singleton.ShowModalDialog(XStringDefineProxy.GetString("YYMallPreciousTip"), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.DoRefreshShop));
}
else
{
this.DoRefreshShop(null);
}
return true;
}
private bool DoRefreshShop(IXUIButton button)
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
bool flag = !specificDocument.IsMoneyOrItemEnough((int)this.GetMoneyId(), (int)this.GetRefreshCost());
bool result;
if (flag)
{
specificDocument.ProcessItemOrMoneyNotEnough((int)this.GetMoneyId());
result = false;
}
else
{
RpcC2G_QueryShopItem rpcC2G_QueryShopItem = new RpcC2G_QueryShopItem();
rpcC2G_QueryShopItem.oArg.isrefresh = true;
rpcC2G_QueryShopItem.oArg.type = specificDocument.GetShopId(XSysDefine.XSys_Welfare_YyMall);
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_QueryShopItem);
this.PlayRefreshEffect();
result = true;
}
return result;
}
private uint GetRefreshCost()
{
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
ShopTypeTable.RowData shopTypeData = specificDocument.GetShopTypeData(XSysDefine.XSys_Welfare_YyMall);
bool flag = shopTypeData == null;
uint result;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog(string.Format("ShopTypeTable not find this systenId = {0}", XSysDefine.XSys_Welfare_YyMall), null, null, null, null, null);
result = 0u;
}
else
{
uint num = 0u;
uint rereshCount = specificDocument.RereshCount;
SeqRef<uint> refreshCount = shopTypeData.RefreshCount;
SeqListRef<uint> refreshCost = shopTypeData.RefreshCost;
bool flag2 = rereshCount >= refreshCount[0];
if (flag2)
{
int index = (int)Mathf.Min(rereshCount - refreshCount[0], (float)(refreshCost.count - 1));
num = refreshCost[index, 1];
}
result = num;
}
return result;
}
private uint GetMoneyId()
{
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
ShopTypeTable.RowData shopTypeData = specificDocument.GetShopTypeData(XSysDefine.XSys_Welfare_YyMall);
bool flag = shopTypeData == null;
uint result;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog(string.Format("ShopTypeTable not find this systenId = {0}", XSysDefine.XSys_Welfare_YyMall), null, null, null, null, null);
result = 0u;
}
else
{
uint rereshCount = specificDocument.RereshCount;
uint num = 0u;
SeqRef<uint> refreshCount = shopTypeData.RefreshCount;
SeqListRef<uint> refreshCost = shopTypeData.RefreshCost;
bool flag2 = rereshCount >= refreshCount[0];
if (flag2)
{
int num2 = (int)Mathf.Min(rereshCount - refreshCount[0], refreshCount[1] - 1u);
bool flag3 = num2 >= refreshCost.Count;
if (flag3)
{
num2 = refreshCost.Count - 1;
}
num = refreshCost[num2, 0];
}
result = num;
}
return result;
}
}
}
|