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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XNormalShopView : DlgHandlerBase
{
protected XUIPool m_ShopItemPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
protected List<GameObject> m_ShopItemList = new List<GameObject>();
private XNormalShopDocument _doc = null;
public XSysDefine m_SysShop = XSysDefine.XSys_Mall_Mall;
public IXUIScrollView m_ScrollView;
private IXUIButton m_RefreshBtn;
private int m_RefreshedTime = 0;
private IXUILabel m_RefreshLabel;
private GameObject m_partnerInfoGo;
private IXUIButton m_refreshBtn;
private IXUILabel m_refreshTipLab;
private PartnerShopRecordsHandler m_partnerShopRecordsHandler;
private DragonGuildShopRecordsHandler m_dragonguildShopRecordsHandler;
protected override void Init()
{
base.Init();
this._doc = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
this.m_ShopItemPool.SetupPool(base.PanelObject.transform.Find("Panel").gameObject, base.PanelObject.transform.Find("Panel/ShopItemTpl").gameObject, 6u, false);
this.m_ScrollView = (base.PanelObject.transform.Find("Panel").GetComponent("XUIScrollView") as IXUIScrollView);
this.m_RefreshBtn = (base.PanelObject.transform.Find("RefreshInfo/BtnRefresh").GetComponent("XUIButton") as IXUIButton);
this.m_RefreshBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshShop));
this.m_RefreshLabel = (base.PanelObject.transform.Find("RefreshInfo/RefreshLabel").GetComponent("XUILabel") as IXUILabel);
this.m_partnerInfoGo = base.PanelObject.transform.Find("PartnerInfo").gameObject;
this.m_refreshBtn = (this.m_partnerInfoGo.transform.Find("RecordBtn").GetComponent("XUIButton") as IXUIButton);
this.m_refreshBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickrRecordBtn));
this.m_refreshTipLab = (this.m_partnerInfoGo.transform.Find("Tips").GetComponent("XUILabel") as IXUILabel);
this.m_refreshTipLab.SetText(XSingleton<XStringTable>.singleton.GetString("PartnerShopRefreshTip"));
DlgHandlerBase.EnsureCreate<PartnerShopRecordsHandler>(ref this.m_partnerShopRecordsHandler, base.PanelObject.transform, false, this);
DlgHandlerBase.EnsureCreate<DragonGuildShopRecordsHandler>(ref this.m_dragonguildShopRecordsHandler, base.PanelObject.transform, false, this);
}
protected override void OnShow()
{
base.OnShow();
this.OnRefreshData();
}
public override void OnUnload()
{
DlgHandlerBase.EnsureUnload<PartnerShopRecordsHandler>(ref this.m_partnerShopRecordsHandler);
DlgHandlerBase.EnsureUnload<DragonGuildShopRecordsHandler>(ref this.m_dragonguildShopRecordsHandler);
base.OnUnload();
}
public override void StackRefresh()
{
bool flag = this._doc != null;
if (flag)
{
this._doc.ReqGoodsList(this.m_SysShop);
}
}
public override void LeaveStackTop()
{
base.LeaveStackTop();
}
public void SetShopType(XSysDefine sys)
{
this.m_SysShop = sys;
}
public void OnRefreshData()
{
this._doc.ReqGoodsList(this.m_SysShop);
this.m_RefreshLabel.SetText(XSingleton<XStringTable>.singleton.GetString("PartnerShopRefreshTip"));
this.m_partnerInfoGo.gameObject.SetActive(this.m_SysShop == XSysDefine.XSys_Mall_Partner || this.m_SysShop == XSysDefine.XSys_DragonGuildShop);
this.m_refreshBtn.ID = (ulong)((long)this.m_SysShop);
this.RefreshShopInfo();
}
public void SetRefreshedTime(int times)
{
this.m_RefreshedTime = times;
}
private void RefreshShopInfo()
{
ShopTypeTable.RowData shopTypeData = this._doc.GetShopTypeData(this.m_SysShop);
string text = "";
bool flag = shopTypeData != null;
if (flag)
{
bool flag2 = shopTypeData.ShopCycle == null || shopTypeData.ShopCycle.Length == 0;
if (flag2)
{
this.m_RefreshLabel.SetText("");
}
else
{
bool flag3 = shopTypeData.ShopCycle.Length == 1 && shopTypeData.ShopCycle[0] == 0u;
if (flag3)
{
this.m_RefreshLabel.SetText("");
}
else
{
for (int i = 0; i < shopTypeData.ShopCycle.Length; i++)
{
int num = (int)(shopTypeData.ShopCycle[i] / 100u);
int num2 = (int)(shopTypeData.ShopCycle[i] % 100u);
bool flag4 = i != shopTypeData.ShopCycle.Length - 1;
if (flag4)
{
text += string.Format("{0:D2}:{1:D2}", num, num2);
}
else
{
text += string.Format("{0:D2}:{1:D2}", num, num2);
}
}
this.m_RefreshLabel.SetText(string.Format(XStringDefineProxy.GetString("SHOP_REFRESH_TIME"), text));
}
}
bool flag5 = shopTypeData.RefreshCost.Count == 0;
if (flag5)
{
this.m_RefreshBtn.SetVisible(false);
}
else
{
this.m_RefreshBtn.SetVisible(true);
}
}
else
{
this.m_RefreshBtn.SetVisible(false);
}
this.m_ShopItemPool.ReturnAll(false);
DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton.SetSys = this.m_SysShop;
XMainInterfaceDocument specificDocument = XDocuments.GetSpecificDocument<XMainInterfaceDocument>(XMainInterfaceDocument.uuID);
specificDocument.OnTopUIRefreshed(DlgBase<MallSystemDlg, MallSystemBehaviour>.singleton);
}
public void RefreshGoodsList()
{
List<XNormalShopGoods> goodsList = this._doc.GoodsList;
this.m_ShopItemPool.ReturnAll(false);
this.m_ShopItemList.Clear();
int num = 0;
for (int i = 0; i < goodsList.Count; i++)
{
XNormalShopGoods xnormalShopGoods = goodsList[i];
ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)xnormalShopGoods.item.uid);
bool flag = this.CheckGoodsShowing(dataById);
if (flag)
{
GameObject showProductGo = this.GetShowProductGo();
IXUIButton ixuibutton = showProductGo.transform.Find("BtnBuy").GetComponent("XUIButton") as IXUIButton;
IXUISprite ixuisprite = showProductGo.transform.Find("Item/Icon").GetComponent("XUISprite") as IXUISprite;
ixuibutton.ID = (ulong)((long)i);
ixuisprite.ID = (ulong)((long)i);
ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnItemBuyClicked));
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemIconClicked));
ixuibutton.SetAudioClip("");
this.UpdateGoodsInfo(xnormalShopGoods, showProductGo);
showProductGo.transform.localPosition = new Vector3(this.m_ShopItemPool.TplPos.x + (float)(num % 2 * this.m_ShopItemPool.TplWidth), this.m_ShopItemPool.TplPos.y - (float)(num / 2 * this.m_ShopItemPool.TplHeight), this.m_ShopItemPool.TplPos.z);
num++;
}
}
this.m_ScrollView.ResetPosition();
}
protected virtual bool CheckGoodsShowing(ShopTable.RowData shopGoods)
{
bool flag = shopGoods == null;
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = this.m_SysShop != XSysDefine.XSys_Mall_Partner;
if (flag2)
{
bool flag3 = shopGoods.LevelShow[0] != 0u || shopGoods.LevelShow[1] > 0u;
if (flag3)
{
bool flag4 = XSingleton<XAttributeMgr>.singleton.XPlayerData.Level < shopGoods.LevelShow[0] || XSingleton<XAttributeMgr>.singleton.XPlayerData.Level > shopGoods.LevelShow[1];
if (flag4)
{
return false;
}
}
}
result = true;
}
return result;
}
private GameObject GetShowProductGo()
{
GameObject gameObject = this.m_ShopItemPool.FetchGameObject(false);
this.m_ShopItemList.Add(gameObject);
return gameObject;
}
private void UpdateGoodsInfo(XNormalShopGoods goods, GameObject shopItem)
{
XSingleton<XItemDrawerMgr>.singleton.DrawItem(shopItem.transform.Find("Item").gameObject, goods.item);
IXUILabel ixuilabel = shopItem.transform.Find("MoneyCost").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite = shopItem.transform.Find("MoneyCost/Icon").GetComponent("XUISprite") as IXUISprite;
IXUISprite ixuisprite2 = shopItem.transform.Find("Cover").GetComponent("XUISprite") as IXUISprite;
IXUIButton ixuibutton = shopItem.transform.Find("BtnBuy").GetComponent("XUIButton") as IXUIButton;
IXUISprite ixuisprite3 = shopItem.transform.GetComponent("XUISprite") as IXUISprite;
ixuisprite3.ID = goods.item.uid;
IXUISprite ixuisprite4 = shopItem.transform.Find("Item/limit").GetComponent("XUISprite") as IXUISprite;
IXUILabel ixuilabel2 = shopItem.transform.Find("Item/limit/num").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite5 = shopItem.transform.Find("sale").GetComponent("XUISprite") as IXUISprite;
ixuisprite5.SetVisible(false);
IXUILabel ixuilabel3 = shopItem.transform.Find("sale/T").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite6 = shopItem.transform.Find("sale2").GetComponent("XUISprite") as IXUISprite;
ixuisprite6.SetVisible(false);
IXUISprite ixuisprite7 = shopItem.transform.Find("sale3").GetComponent("XUISprite") as IXUISprite;
ixuisprite7.SetVisible(false);
IXUISprite ixuisprite8 = shopItem.transform.Find("Item/limit1").GetComponent("XUISprite") as IXUISprite;
ixuisprite8.SetVisible(false);
IXUILabel ixuilabel4 = shopItem.transform.Find("Item/limit1/num").GetComponent("XUILabel") as IXUILabel;
IXUILabel ixuilabel5 = shopItem.transform.Find("T1").GetComponent("XUILabel") as IXUILabel;
ixuilabel5.SetVisible(false);
IXUILabel ixuilabel6 = shopItem.transform.Find("T2").GetComponent("XUILabel") as IXUILabel;
ixuilabel6.SetVisible(false);
IXUILabel ixuilabel7 = shopItem.transform.Find("T3").GetComponent("XUILabel") as IXUILabel;
ixuilabel7.SetVisible(false);
ShopTable.RowData dataById = XNormalShopDocument.GetDataById((uint)goods.item.uid);
ixuilabel.SetText(goods.priceValue.ToString());
bool flag = dataById.Benefit[0] == 1u;
if (flag)
{
ixuisprite6.SetVisible(true);
}
else
{
bool flag2 = dataById.Benefit[0] == 2u;
if (flag2)
{
ixuisprite8.SetVisible(true);
ixuilabel5.SetVisible(true);
ixuilabel5.SetText("[s]" + goods.priceValue.ToString());
uint num = dataById.Benefit[1];
bool flag3 = num % 10u == 0u;
if (flag3)
{
num = dataById.Benefit[1] / 10u;
}
ixuilabel4.SetText("[b]" + num.ToString());
ixuilabel.SetText(((int)((long)goods.priceValue * (long)((ulong)dataById.Benefit[1])) / 100).ToString());
}
}
ShopTable.RowData dataById2 = XNormalShopDocument.GetDataById((uint)goods.item.uid);
uint dailyCountCondition = (uint)dataById2.DailyCountCondition;
int weekCountCondition = (int)dataById2.WeekCountCondition;
int num2 = 0;
bool flag4 = dataById2.CountCondition > 0u;
if (flag4)
{
num2 = goods.totalSoldNum;
}
else
{
bool flag5 = dailyCountCondition > 0u;
if (flag5)
{
num2 = goods.soldNum;
}
else
{
bool flag6 = weekCountCondition != 0;
if (flag6)
{
num2 = (int)goods.weeklyBuyCount;
}
}
}
int countCondition = (int)dataById2.CountCondition;
bool flag7 = dailyCountCondition == 0u && countCondition == 0 && weekCountCondition == 0;
if (flag7)
{
ixuisprite4.SetVisible(false);
ixuisprite2.SetVisible(false);
ixuibutton.SetEnable(true, false);
}
else
{
bool flag8 = countCondition != 0;
if (flag8)
{
bool flag9 = num2 >= countCondition;
if (flag9)
{
ixuibutton.SetEnable(false, false);
ixuisprite2.SetVisible(true);
}
else
{
ixuibutton.SetEnable(true, false);
ixuisprite2.SetVisible(false);
}
}
else
{
bool flag10 = dailyCountCondition != 0u && (long)num2 >= (long)((ulong)dailyCountCondition);
if (flag10)
{
ixuibutton.SetEnable(false, false);
ixuisprite2.SetVisible(true);
}
else
{
bool flag11 = weekCountCondition != 0 && num2 >= weekCountCondition;
if (flag11)
{
ixuibutton.SetEnable(false, false);
ixuisprite2.SetVisible(false);
}
else
{
ixuibutton.SetEnable(true, false);
ixuisprite2.SetVisible(false);
}
}
}
ixuisprite4.SetVisible(false);
ixuilabel2.SetVisible(false);
ixuilabel6.SetVisible(true);
bool flag12 = countCondition != 0;
if (flag12)
{
ixuilabel6.SetText(string.Format(XStringDefineProxy.GetString("SHOP_TOTAL_CAN_BUY"), ((countCondition - num2 > 0) ? (countCondition - num2) : 0).ToString()));
}
else
{
bool flag13 = dailyCountCondition > 0u;
if (flag13)
{
ixuilabel6.SetText(string.Format(XStringDefineProxy.GetString("SHOP_TODAY_CAN_BUY"), ((long)(((ulong)dailyCountCondition - (ulong)((long)num2) > 0UL) ? ((ulong)dailyCountCondition - (ulong)((long)num2)) : 0UL)).ToString()));
}
else
{
bool flag14 = weekCountCondition != 0;
if (flag14)
{
ixuilabel6.SetText(string.Format(XStringDefineProxy.GetString("SHOP_Weekly_CAN_BUY"), ((weekCountCondition - num2 > 0) ? (weekCountCondition - num2) : 0).ToString()));
}
}
}
}
string itemSmallIcon = XBagDocument.GetItemSmallIcon(goods.priceType, 0u);
ixuisprite.SetSprite(itemSmallIcon);
}
private void OnItemIconClicked(IXUISprite iSp)
{
List<XNormalShopGoods> goodsList = this._doc.GoodsList;
bool flag = goodsList.Count <= (int)iSp.ID;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog("goodsList.Count <= (int)iSp.ID", null, null, null, null, null);
}
else
{
XNormalShopGoods xnormalShopGoods = goodsList[(int)iSp.ID];
XItem mainItem = XBagDocument.MakeXItem(xnormalShopGoods.item.itemID, false);
XSingleton<UiUtility>.singleton.ShowTooltipDialogWithSearchingCompare(mainItem, iSp, false, 0u);
}
}
public void UpdateShopItemInfo(XNormalShopGoods item)
{
for (int i = 0; i < this.m_ShopItemList.Count; i++)
{
IXUISprite ixuisprite = this.m_ShopItemList[i].transform.GetComponent("XUISprite") as IXUISprite;
bool flag = ixuisprite.ID == item.item.uid;
if (flag)
{
this.UpdateGoodsInfo(item, this.m_ShopItemList[i]);
break;
}
}
}
private bool OnItemBuyClicked(IXUIButton btn)
{
this._doc.ReqBuyPanel((int)btn.ID);
return true;
}
private uint GetRefreshCost()
{
ShopTypeTable.RowData shopTypeData = this._doc.GetShopTypeData(this.m_SysShop);
bool flag = shopTypeData == null;
uint result;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog(string.Format("ShopTypeTable not find this systenId = {0}", this.m_SysShop), null, null, null, null, null);
result = 0u;
}
else
{
uint rereshCount = this._doc.RereshCount;
bool flag2 = (ulong)rereshCount < (ulong)((long)shopTypeData.RefreshCost.Count);
if (flag2)
{
result = shopTypeData.RefreshCost[(int)rereshCount, 1];
}
else
{
result = shopTypeData.RefreshCost[shopTypeData.RefreshCost.Count - 1, 1];
}
}
return result;
}
private string GetMoneyName()
{
ShopTypeTable.RowData shopTypeData = this._doc.GetShopTypeData(this.m_SysShop);
bool flag = shopTypeData == null;
string result;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog(string.Format("ShopTypeTable not find this systenId = {0}", this.m_SysShop), null, null, null, null, null);
result = "";
}
else
{
bool flag2 = (ulong)this._doc.RereshCount < (ulong)((long)shopTypeData.RefreshCost.Count);
uint itemID;
if (flag2)
{
itemID = shopTypeData.RefreshCost[(int)this._doc.RereshCount, 0];
}
else
{
itemID = shopTypeData.RefreshCost[shopTypeData.RefreshCost.Count - 1, 0];
}
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemID);
result = itemConf.ItemName[0];
}
return result;
}
private bool OnRefreshShop(IXUIButton btn)
{
string label = string.Format(XStringDefineProxy.GetString("NORMALSHOP_REFRESH"), this.GetRefreshCost().ToString(), this.GetMoneyName());
XSingleton<UiUtility>.singleton.ShowModalDialog(label, XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.DoRefreshShop));
return true;
}
private bool OnClickrRecordBtn(IXUIButton btn)
{
XSysDefine xsysDefine = (XSysDefine)btn.ID;
XSysDefine xsysDefine2 = xsysDefine;
bool result;
if (xsysDefine2 != XSysDefine.XSys_Mall_Partner)
{
if (xsysDefine2 != XSysDefine.XSys_DragonGuildShop)
{
XSingleton<XDebug>.singleton.AddErrorLog("ThisButton is not correct init", null, null, null, null, null);
result = false;
}
else
{
this.m_dragonguildShopRecordsHandler.SetVisible(true);
result = true;
}
}
else
{
this.m_partnerShopRecordsHandler.SetVisible(true);
result = true;
}
return result;
}
private bool DoRefreshShop(IXUIButton btn)
{
bool flag = !this._doc.IsMoneyOrItemEnough(7, (int)this.GetRefreshCost());
bool result;
if (flag)
{
this._doc.ProcessItemOrMoneyNotEnough(7);
result = false;
}
else
{
RpcC2G_QueryShopItem rpcC2G_QueryShopItem = new RpcC2G_QueryShopItem();
rpcC2G_QueryShopItem.oArg.isrefresh = true;
rpcC2G_QueryShopItem.oArg.type = this._doc.GetShopId(this.m_SysShop);
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_QueryShopItem);
XSingleton<UiUtility>.singleton.CloseModalDlg();
result = true;
}
return result;
}
protected override void OnHide()
{
bool flag = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.Refresh(false);
DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.SetVisible(true, true);
}
XNormalShopDocument.ShopDoc.ToSelectShopItemID = 0UL;
base.OnHide();
}
}
}
|