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
|
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class GamePayDragonMallHander : DlgHandlerBase
{
private XPurchaseDocument _doc = null;
private uint nextRecoverTimer = 0u;
public static FatigueRecoverTime _fatigueTime = new FatigueRecoverTime();
public ItemEnum _showItem = ItemEnum.VIRTUAL_ITEM_MAX;
public IXUILabel m_Title;
public IXUILabel m_BuyNumLeft;
public IXUILabel m_BuyNumError;
public IXUILabelSymbol m_BuyNum;
public IXUILabel m_Time;
public IXUILabel m_Tips;
public IXUIButton m_QuickBuyDiamond;
public IXUIButton m_QuickBuyDragonCoin;
public IXUILabelSymbol m_QuickBuyCost;
protected override void Init()
{
this._doc = XDocuments.GetSpecificDocument<XPurchaseDocument>(XPurchaseDocument.uuID);
this.m_QuickBuyDiamond = (base.transform.Find("bg/BuyFrame/UseDiamond").GetComponent("XUIButton") as IXUIButton);
this.m_QuickBuyDragonCoin = (base.transform.Find("bg/BuyFrame/UseDragonCoin").GetComponent("XUIButton") as IXUIButton);
this.m_QuickBuyCost = (base.transform.Find("bg/BuyFrame/num2").GetComponent("XUILabelSymbol") as IXUILabelSymbol);
this.m_Tips = (base.transform.Find("bg/BuyFrame/tips").GetComponent("XUILabel") as IXUILabel);
this.m_Title = (base.transform.Find("bg/BuyFrame/title").GetComponent("XUILabel") as IXUILabel);
this.m_BuyNumLeft = (base.transform.Find("bg/BuyFrame/timesleft").GetComponent("XUILabel") as IXUILabel);
this.m_BuyNum = (base.transform.Find("bg/BuyFrame/num1").GetComponent("XUILabelSymbol") as IXUILabelSymbol);
this.m_BuyNumError = (base.transform.Find("bg/BuyFrame/error").GetComponent("XUILabel") as IXUILabel);
this.m_Time = (base.transform.Find("bg/BuyFrame/time").GetComponent("XUILabel") as IXUILabel);
}
public override void RegisterEvent()
{
this.m_QuickBuyDiamond.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoPurchaseDiamond));
this.m_QuickBuyDragonCoin.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoPurchageDC));
}
public void ReceiveFatigueTime(PtcG2C_FatigueRecoverTimeNotify times)
{
GamePayDragonMallHander._fatigueTime.timeleft = times.Data.timeleft;
GamePayDragonMallHander._fatigueTime.fatigueid = times.Data.fatigueID;
GamePayDragonMallHander._fatigueTime.updatetime = DateTime.Now;
}
protected override void OnShow()
{
base.OnShow();
this.ShowBorad(DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.item);
}
public void ShowBorad(ItemEnum type)
{
this._showItem = type;
this.SetupPanel();
this.RefreshBoard();
bool flag = this._showItem == ItemEnum.FATIGUE;
if (flag)
{
bool flag2 = this.nextRecoverTimer > 0u;
if (flag2)
{
XSingleton<XTimerMgr>.singleton.KillTimer(this.nextRecoverTimer);
}
this.nextRecoverTimer = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.UpdateTimer), null);
}
}
public void RefreshBoard()
{
int level = (int)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
XRechargeDocument specificDocument = XDocuments.GetSpecificDocument<XRechargeDocument>(XRechargeDocument.uuID);
int vipLevel = (int)specificDocument.VipLevel;
XPurchaseInfo purchaseInfo = this._doc.GetPurchaseInfo(level, vipLevel, this._showItem);
this.m_BuyNumLeft.SetText(XStringDefineProxy.GetString("SYS_PURCHASE_TIMES") + (purchaseInfo.totalBuyNum - purchaseInfo.curBuyNum).ToString() + "/" + purchaseInfo.totalBuyNum.ToString());
this.m_BuyNum.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.GetCount, this._showItem);
bool flag = this._showItem == ItemEnum.DRAGON_COIN;
if (flag)
{
this.m_QuickBuyCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.diamondCost, ItemEnum.DIAMOND);
}
else
{
this.m_QuickBuyCost.InputText = XLabelSymbolHelper.FormatCostWithIcon(purchaseInfo.dragoncoinCost, ItemEnum.DRAGON_COIN);
}
}
protected void SetupPanel()
{
bool flag = this._showItem == ItemEnum.VIRTUAL_ITEM_MAX;
if (!flag)
{
this.m_Time.gameObject.SetActive(false);
this.m_BuyNumError.gameObject.SetActive(false);
ItemEnum showItem = this._showItem;
if (showItem != ItemEnum.GOLD)
{
if (showItem != ItemEnum.FATIGUE)
{
if (showItem == ItemEnum.DRAGON_COIN)
{
this.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEDC"));
this.m_QuickBuyDiamond.gameObject.SetActive(true);
this.m_QuickBuyDragonCoin.gameObject.SetActive(false);
this.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips2"));
Vector3 localPosition = this.m_QuickBuyDiamond.gameObject.transform.localPosition;
this.m_QuickBuyDiamond.gameObject.transform.localPosition = new Vector3(0f, localPosition.y);
}
}
else
{
this.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEFAT"));
this.m_QuickBuyDiamond.gameObject.SetActive(false);
this.m_QuickBuyDragonCoin.gameObject.SetActive(true);
this.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips3"));
Vector3 localPosition2 = this.m_QuickBuyDiamond.gameObject.transform.localPosition;
this.m_QuickBuyDragonCoin.gameObject.transform.localPosition = new Vector3(0f, localPosition2.y);
}
}
else
{
this.m_Title.SetText(XStringDefineProxy.GetString("PURCHASEGOLD"));
this.m_QuickBuyDiamond.gameObject.SetActive(false);
this.m_QuickBuyDragonCoin.gameObject.SetActive(true);
this.m_Tips.SetText(XStringDefineProxy.GetString("Quick_Purchase_Tips1"));
Vector3 localPosition3 = this.m_QuickBuyDiamond.gameObject.transform.localPosition;
this.m_QuickBuyDragonCoin.gameObject.transform.localPosition = new Vector3(0f, localPosition3.y);
}
}
}
public void ShowErrorCode(ErrorCode err)
{
bool flag = this.m_BuyNum != null;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString(err), "fece00");
}
}
public string FormatTime(uint time)
{
bool flag = time >= 3600u;
string result;
if (flag)
{
result = string.Format(string.Format("{0:D2}:{1:D2}:{2:D2}", (int)(time / 3600u), (int)(time % 3600u / 60u), time % 60u), new object[0]);
}
else
{
result = string.Format(string.Format("{0:D2}:{1:D2}", (int)(time % 3600u / 60u), time % 60u), new object[0]);
}
return result;
}
public uint GetTimeLeft(ItemEnum itemid)
{
uint num = 0u;
for (int i = 0; i < GamePayDragonMallHander._fatigueTime.fatigueid.Count; i++)
{
bool flag = GamePayDragonMallHander._fatigueTime.fatigueid[i] == (uint)this._showItem;
if (flag)
{
num = GamePayDragonMallHander._fatigueTime.timeleft[i] / 1000u;
}
}
double totalSeconds = (DateTime.Now - GamePayDragonMallHander._fatigueTime.updatetime).TotalSeconds;
num -= (uint)totalSeconds;
return (num > 0u) ? num : 0u;
}
public void UpdateTimer(object param)
{
uint num = 0u;
for (int i = 0; i < GamePayDragonMallHander._fatigueTime.fatigueid.Count; i++)
{
bool flag = GamePayDragonMallHander._fatigueTime.fatigueid[i] == (uint)this._showItem;
if (flag)
{
num = GamePayDragonMallHander._fatigueTime.timeleft[i];
}
}
bool flag2 = num == 0u;
if (flag2)
{
this.m_Time.SetText("");
}
else
{
double totalSeconds = (DateTime.Now - GamePayDragonMallHander._fatigueTime.updatetime).TotalSeconds;
num -= (uint)totalSeconds;
bool flag3 = num <= 0u;
if (flag3)
{
this.m_Time.SetText("");
}
else
{
this.m_Time.SetText("");
bool flag4 = this.nextRecoverTimer > 0u;
if (flag4)
{
XSingleton<XTimerMgr>.singleton.KillTimer(this.nextRecoverTimer);
}
this.nextRecoverTimer = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.UpdateTimer), null);
}
}
}
public bool DoPurchaseDiamond(IXUIButton sp)
{
this._doc.CommonQuickBuy(this._showItem, ItemEnum.DIAMOND, 1u);
return true;
}
public bool DoPurchageDC(IXUIButton sp)
{
this._doc.CommonQuickBuy(this._showItem, ItemEnum.DRAGON_COIN, 1u);
return true;
}
public void ReqQuickCommonPurchase(ItemEnum itemid = ItemEnum.FATIGUE)
{
this.ShowBorad(itemid);
}
public void UpdatePlayerBuyInfo(BuyGoldFatInfo buyInfo)
{
bool flag = this._doc == null;
if (!flag)
{
this._doc.InitPurchaseInfo(buyInfo);
this.RefreshBoard();
}
}
}
}
|