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
|
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XGameMallDocument : XDocComponent
{
public override uint ID
{
get
{
return XGameMallDocument.uuID;
}
}
public bool isNewVIP
{
get
{
return this.hotGoods.Count > 0;
}
}
public CIBShop currCIBShop
{
get
{
for (int i = 0; i < this.mallItemlist.Count; i++)
{
bool flag = (ulong)this.mallItemlist[i].row.itemid == (ulong)((long)this.currItemID);
if (flag)
{
return this.mallItemlist[i];
}
}
return null;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XGameMallDocument");
private static IBShop _IBShopTable = new IBShop();
public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
public int currItemID = 0;
public bool isNewWeekly = true;
public List<uint> hotGoods = new List<uint>();
public List<uint> tabNews = new List<uint>();
public List<XSysDefine> shopRedPoint = new List<XSysDefine>();
public bool vipTabshow = false;
public bool presentStatus = true;
public bool isBuying = false;
public bool isQuerying = false;
public List<IBGiftHistItem> presentList;
public List<IBGiftHistItem> recvList;
public List<CIBShop> mallItemlist = new List<CIBShop>();
public List<CUIIBShop> mallItemUIList = new List<CUIIBShop>();
public List<XSysDefine> ShopSystems = new List<XSysDefine>();
protected override void OnReconnected(XReconnectedEventArgs arg)
{
bool flag = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.IsVisible();
if (flag)
{
this.SendQueryItems(DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.mallType);
}
}
public static void Execute(OnLoadedCallback callback = null)
{
XGameMallDocument.AsyncLoader.AddTask("Table/IBShop", XGameMallDocument._IBShopTable, false);
XGameMallDocument.AsyncLoader.Execute(callback);
}
public override void OnAttachToHost(XObject host)
{
this.ShopSystems.Clear();
List<int> intList = XSingleton<XGlobalConfig>.singleton.GetIntList("ShopShowingIconList");
for (int i = 0; i < intList.Count; i++)
{
this.ShopSystems.Add((XSysDefine)intList[i]);
}
}
public void SendQueryItems(MallType type)
{
RpcC2G_QueryIBItem rpcC2G_QueryIBItem = new RpcC2G_QueryIBItem();
rpcC2G_QueryIBItem.oArg.type = (uint)this.GetCoinItemid();
rpcC2G_QueryIBItem.oArg.subtype = (uint)type;
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_QueryIBItem);
}
public void RespItems(IBQueryItemReq oArg, IBQueryItemRes oRes)
{
uint coinItemid = (uint)this.GetCoinItemid();
bool flag = coinItemid == oArg.type;
uint mallType = (uint)DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.mallType;
this.vipTabshow = oRes.viptab;
this.tabNews = oRes.newproducts;
bool flag2 = this.GetCoinItemid() == (int)oArg.type && DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.mallType == (MallType)oArg.subtype;
if (flag2)
{
this.MergeIBShop(oRes.iteminfo, this.GetItemsFromTable());
bool flag3 = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.IsVisible();
if (flag3)
{
DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.Refresh();
}
}
else
{
XSingleton<XDebug>.singleton.AddLog("mall tab has changed!", null, null, null, null, null, XDebugColor.XDebug_None);
}
this.isBuying = false;
}
public void UpdateItemBuyCnt(uint goodsid, uint cnt)
{
GameItemsMallHander gameItemsMallHander = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton._gameItemsMallHander;
GameDescMallHander gameDescMallHander = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton._gameDescMallHander;
bool flag = gameDescMallHander != null && gameItemsMallHander != null && DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.IsVisible() && this.currCIBShop != null && this.currCIBShop.sinfo != null && goodsid == this.currCIBShop.sinfo.goodsid;
if (flag)
{
for (int i = 0; i < this.mallItemlist.Count; i++)
{
bool flag2 = this.mallItemlist[i].sinfo.goodsid == this.currCIBShop.sinfo.goodsid;
if (flag2)
{
this.mallItemlist[i].sinfo.nbuycount = cnt;
this.mallItemlist[i].finish = this.IsFinish(this.mallItemlist[i].sinfo, this.mallItemlist[i].row);
gameDescMallHander.Refresh();
gameItemsMallHander.Refresh();
break;
}
}
}
}
public void SendBuyItem(uint goodsid, uint count)
{
bool flag = !this.isBuying;
if (flag)
{
this.isBuying = true;
RpcC2G_BuyIBItem rpcC2G_BuyIBItem = new RpcC2G_BuyIBItem();
rpcC2G_BuyIBItem.oArg.goodsid = goodsid;
rpcC2G_BuyIBItem.oArg.count = count;
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_BuyIBItem);
}
}
public CIBShop SearchIBShop(int itemid)
{
for (int i = 0; i < this.mallItemlist.Count; i++)
{
bool flag = (ulong)this.mallItemlist[i].row.itemid == (ulong)((long)itemid);
if (flag)
{
return this.mallItemlist[i];
}
}
return null;
}
public void OnResBuyItem(IBBuyItemReq oArg, IBBuyItemRes res)
{
uint goodsid = oArg.goodsid;
uint itemid = XGameMallDocument._IBShopTable.GetByid(goodsid).itemid;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemid);
string text = XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0u);
this.SendQueryItems(DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.mallType);
}
private void MergeIBShop(List<IBShopItemInfo> server_list, Dictionary<uint, IBShop.RowData> dicTable)
{
this.mallItemlist.Clear();
this.mallItemUIList.Clear();
for (int i = 0; i < server_list.Count; i++)
{
bool flag = dicTable.ContainsKey(server_list[i].goodsid);
if (flag)
{
CIBShop cibshop = new CIBShop();
cibshop.row = dicTable[server_list[i].goodsid];
cibshop.sinfo = server_list[i];
cibshop.finish = this.IsFinish(server_list[i], cibshop.row);
this.mallItemlist.Add(cibshop);
}
}
this.mallItemlist.Sort(new Comparison<CIBShop>(this.SortData));
bool flag2 = !this.Search((uint)this.currItemID);
if (flag2)
{
this.currItemID = (int)((this.mallItemlist.Count > 0) ? this.mallItemlist[0].row.itemid : 0u);
}
int count = this.mallItemlist.Count;
for (int j = 0; j < count; j += 2)
{
CUIIBShop item = default(CUIIBShop);
item.item1 = this.mallItemlist[j];
bool flag3 = this.mallItemlist.Count > j + 1;
if (flag3)
{
item.item2 = this.mallItemlist[j + 1];
}
else
{
item.item2 = null;
}
this.mallItemUIList.Add(item);
}
}
private bool IsFinish(IBShopItemInfo info, IBShop.RowData row)
{
bool flag = info.itemid == DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.privilegeID;
bool result;
if (flag)
{
XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
float num = 0f;
bool flag2 = specificDocument.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Commerce);
if (flag2)
{
PayMemberTable.RowData memberPrivilegeConfig = specificDocument.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Commerce);
num = ((memberPrivilegeConfig != null) ? ((float)memberPrivilegeConfig.BuyGreenAgateLimit / 100f) : 0f);
}
int num2 = 0;
PayMemberPrivilege payMemberPrivilege = specificDocument.PayMemberPrivilege;
bool flag3 = payMemberPrivilege != null;
if (flag3)
{
List<PayPrivilegeShop> usedPrivilegeShop = payMemberPrivilege.usedPrivilegeShop;
for (int i = 0; i < usedPrivilegeShop.Count; i++)
{
bool flag4 = (long)usedPrivilegeShop[i].goodsID == (long)((ulong)info.goodsid);
if (flag4)
{
num2 = usedPrivilegeShop[i].usedCount;
break;
}
}
}
result = (info.nlimitcount > 0u && info.nlimitcount + row.buycount * num <= (float)((ulong)info.nbuycount + (ulong)((long)num2)));
}
else
{
result = (info.nlimitcount > 0u && info.nlimitcount <= info.nbuycount);
}
return result;
}
private Dictionary<uint, IBShop.RowData> GetItemsFromTable()
{
Dictionary<uint, IBShop.RowData> dictionary = new Dictionary<uint, IBShop.RowData>();
IBShop.RowData[] table = XGameMallDocument._IBShopTable.Table;
for (int i = 0; i < table.Length; i++)
{
bool flag = table[i].currencytype == (uint)this.GetCoinItemid() && table[i].type == (uint)DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.mallType;
if (flag)
{
dictionary.Add(table[i].id, table[i]);
}
}
return dictionary;
}
public void FindItem(int itemid, out uint currency, out uint type)
{
currency = (type = 0u);
IBShop.RowData[] table = XGameMallDocument._IBShopTable.Table;
for (int i = 0; i < table.Length; i++)
{
bool flag = (ulong)table[i].itemid == (ulong)((long)itemid);
if (flag)
{
currency = table[i].currencytype;
type = table[i].type;
break;
}
}
}
public uint FindItemPrice(uint itemId, uint currencytype)
{
IBShop.RowData[] table = XGameMallDocument._IBShopTable.Table;
for (int i = 0; i < table.Length; i++)
{
bool flag = table[i].itemid == itemId && table[i].currencytype == currencytype;
if (flag)
{
return table[i].currencycount;
}
}
return 0u;
}
private int ChangeLimtSort(CIBShop limit)
{
return (limit.sinfo.nlimittime > 0u) ? 1 : 0;
}
private int ChangeDiscount(CIBShop discount)
{
return (int)((discount.row.discount == 0u) ? 100u : discount.row.discount);
}
private int ChangeFashion(CIBShop shop)
{
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)shop.row.itemid);
bool flag = itemConf.ItemType == 2 || itemConf.ItemType == 5;
int result;
if (flag)
{
result = (int)itemConf.ItemType;
}
else
{
result = 0;
}
return result;
}
private int SortData(CIBShop x, CIBShop y)
{
bool flag = x.row.sortid != y.row.sortid;
int result;
if (flag)
{
result = x.row.sortid - y.row.sortid;
}
else
{
result = (int)(x.row.id - y.row.id);
}
return result;
}
public int GetCoinItemid()
{
bool flag = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.currSys == XSysDefine.XSys_GameMall_Diamond;
int result;
if (flag)
{
result = XFastEnumIntEqualityComparer<ItemEnum>.ToInt(ItemEnum.DIAMOND);
}
else
{
bool flag2 = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.currSys == XSysDefine.XSys_GameMall_Dragon;
if (flag2)
{
result = XFastEnumIntEqualityComparer<ItemEnum>.ToInt(ItemEnum.DRAGON_COIN);
}
else
{
result = XFastEnumIntEqualityComparer<ItemEnum>.ToInt(ItemEnum.DIAMOND);
}
}
return result;
}
private bool Search(uint itemid)
{
bool flag = this.mallItemlist != null;
if (flag)
{
for (int i = 0; i < this.mallItemlist.Count; i++)
{
bool flag2 = this.mallItemlist[i].row.itemid == itemid;
if (flag2)
{
return true;
}
}
}
return false;
}
public ShopTypeTable.RowData GetShopTypeData(XSysDefine shop)
{
XNormalShopDocument specificDocument = XDocuments.GetSpecificDocument<XNormalShopDocument>(XNormalShopDocument.uuID);
return specificDocument.GetShopTypeData(shop);
}
public void RefreshShopRedPoint(XSysDefine sys, bool isredon)
{
List<XSysDefine> list = new List<XSysDefine>(this.ShopSystems);
bool flag = !list.Contains(sys);
if (!flag)
{
if (isredon)
{
bool flag2 = !this.shopRedPoint.Contains(sys);
if (flag2)
{
this.shopRedPoint.Add(sys);
}
}
else
{
bool flag3 = this.shopRedPoint.Contains(sys);
if (flag3)
{
this.shopRedPoint.Remove(sys);
}
}
DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.RefreshShopRedPoint();
}
}
public void SendQueryGiftItems(uint type)
{
RpcC2M_IbGiftHistReq rpcC2M_IbGiftHistReq = new RpcC2M_IbGiftHistReq();
rpcC2M_IbGiftHistReq.oArg.type = type;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_IbGiftHistReq);
}
public void HandleGiftItems(uint type, List<IBGiftHistItem> list)
{
bool flag = type == 0u;
if (flag)
{
this.presentList = list;
}
else
{
this.recvList = list;
}
bool flag2 = DlgBase<GiftboxDlg, GiftboxBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<GiftboxDlg, GiftboxBehaviour>.singleton.Refresh();
}
}
public void ClearGiftItems()
{
bool flag = this.presentList != null;
if (flag)
{
this.presentList.Clear();
}
bool flag2 = this.recvList != null;
if (flag2)
{
this.recvList.Clear();
}
this.presentList = null;
this.recvList = null;
}
}
}
|