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
|
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient.UI
{
[Hotfix]
internal class XBackFlowMallHandler : DlgHandlerBase
{
protected override string FileName
{
get
{
return "Hall/BfMallHandler";
}
}
private XUIPool m_ItemPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private IXUIList m_ShopItemList;
private IXUIButton m_RefreshBtn;
private IXUILabel m_CloseTip;
private IXUILabel m_ResetdTip;
private IXUILabel m_LeftTimes;
private int currLeftTime;
private uint _CDToken = 0u;
protected override void Init()
{
base.Init();
Transform transform = base.PanelObject.transform.Find("ShopItemList/Grid/ShopItemTpl");
this.m_ItemPool.SetupPool(transform.parent.gameObject, transform.gameObject, 6u, false);
this.m_RefreshBtn = (base.PanelObject.transform.Find("BtnRefresh").GetComponent("XUIButton") as IXUIButton);
this.m_ShopItemList = (base.PanelObject.transform.Find("ShopItemList/Grid").GetComponent("XUIList") as IXUIList);
this.m_CloseTip = (base.PanelObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel);
this.m_ResetdTip = (base.PanelObject.transform.Find("Tip").GetComponent("XUILabel") as IXUILabel);
this.m_LeftTimes = (base.PanelObject.transform.Find("Times").GetComponent("XUILabel") as IXUILabel);
}
public override void RegisterEvent()
{
base.RegisterEvent();
this.m_RefreshBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefreshBtnClicked));
}
private bool OnRefreshBtnClicked(IXUIButton sp)
{
XBackFlowDocument.Doc.SendBackFlowActivityOperation(BackFlowActOp.BackFlowAct_ShopUpdate, 0u);
return true;
}
protected override void OnShow()
{
base.OnShow();
XBackFlowDocument.Doc.SendBackFlowActivityOperation(BackFlowActOp.BackFlowAct_ShopData, 0u);
this.m_ResetdTip.SetText(XStringDefineProxy.GetString("BackFlowShopResetTip"));
}
protected override void OnHide()
{
base.OnHide();
XSingleton<XTimerMgr>.singleton.KillTimer(this._CDToken);
}
public override void RefreshData()
{
bool flag = XBackFlowDocument.Doc.BackflowShopData == null;
if (!flag)
{
this.m_ItemPool.FakeReturnAll();
for (int i = 0; i < XBackFlowDocument.Doc.BackflowShopData.goods.Count; i++)
{
GameObject gameObject = this.m_ItemPool.FetchGameObject(false);
gameObject.transform.parent = this.m_ShopItemList.gameObject.transform;
gameObject.transform.localScale = Vector3.one;
this.SetShopItemInfo(gameObject, XBackFlowDocument.Doc.BackflowShopData.goods[i]);
}
this.m_ShopItemList.Refresh();
this.m_ItemPool.ActualReturnAll(false);
int @int = XSingleton<XGlobalConfig>.singleton.GetInt("BackFlowShopFreshCount");
this.m_LeftTimes.SetText(string.Format("{0}/{1}", XBackFlowDocument.Doc.BackflowShopData.freshCount, @int));
this.currLeftTime = (int)XBackFlowDocument.Doc.ShopLeftTime;
this.SetCloseLeftTime();
}
}
private void SetCloseLeftTime()
{
XSingleton<XTimerMgr>.singleton.KillTimer(this._CDToken);
bool flag = this.currLeftTime > 0;
if (flag)
{
bool flag2 = this.currLeftTime >= 43200;
string arg;
if (flag2)
{
arg = XSingleton<UiUtility>.singleton.TimeDuarationFormatString(this.currLeftTime, 4);
}
else
{
arg = XSingleton<UiUtility>.singleton.TimeDuarationFormatString(this.currLeftTime, 5);
}
this._CDToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.LeftTimeUpdate), null);
this.m_CloseTip.SetText(string.Format(XStringDefineProxy.GetString("BackFlowShopCloseTime"), arg));
}
this.m_CloseTip.SetVisible(this.currLeftTime > 0);
}
private void LeftTimeUpdate(object o)
{
this.currLeftTime--;
this.SetCloseLeftTime();
}
private void SetShopItemInfo(GameObject shopItem, BackFlowShopGood goodsInfo)
{
BackflowShop.RowData byGoodID = XBackFlowDocument.BackflowShopTable.GetByGoodID(goodsInfo.GoodID);
bool flag = byGoodID == null;
if (!flag)
{
this.SetQualityBorder(shopItem, byGoodID.Quality);
GameObject gameObject = shopItem.transform.Find("Item").gameObject;
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)byGoodID.ItemID, (int)byGoodID.ItemCount, true);
IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite.ID = (ulong)byGoodID.ItemID;
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
IXUIButton ixuibutton = shopItem.transform.Find("BtnBuy").GetComponent("XUIButton") as IXUIButton;
ixuibutton.gameObject.SetActive(!goodsInfo.IsBuy);
ixuibutton.ID = (ulong)goodsInfo.GoodID;
ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBuyBtnClicked));
string itemSmallIcon = XBagDocument.GetItemSmallIcon((int)byGoodID.CostType, 0u);
IXUISprite ixuisprite2 = ixuibutton.gameObject.transform.Find("MoneyCost/Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite2.SetSprite(itemSmallIcon);
IXUILabel ixuilabel = ixuibutton.gameObject.transform.Find("MoneyCost").GetComponent("XUILabel") as IXUILabel;
ixuilabel.SetText(byGoodID.CostNum.ToString());
GameObject gameObject2 = shopItem.transform.Find("Empty").gameObject;
gameObject2.SetActive(goodsInfo.IsBuy);
GameObject gameObject3 = shopItem.transform.Find("limit").gameObject;
gameObject3.SetActive(byGoodID.Discount > 0u && byGoodID.Discount != 100u && !goodsInfo.IsBuy);
IXUILabel ixuilabel2 = shopItem.transform.Find("limit/num").GetComponent("XUILabel") as IXUILabel;
ixuilabel2.SetText((byGoodID.Discount / 10f).ToString());
}
}
private void SetQualityBorder(GameObject shopItem, uint quality)
{
for (int i = 0; i <= 5; i++)
{
string text = string.Format("Quality{0}", i);
Transform transform = shopItem.transform.Find(text);
bool flag = transform != null;
if (flag)
{
transform.gameObject.SetActive((long)i == (long)((ulong)quality));
}
}
}
private bool OnBuyBtnClicked(IXUIButton btn)
{
BackflowShop.RowData byGoodID = XBackFlowDocument.BackflowShopTable.GetByGoodID((uint)btn.ID);
bool flag = byGoodID == null;
bool result;
if (flag)
{
result = false;
}
else
{
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.uiBehaviour.m_OKButton.ID = btn.ID;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)byGoodID.ItemID);
bool flag2 = itemConf == null;
if (flag2)
{
result = false;
}
else
{
string text = XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0u);
string message = string.Format(XStringDefineProxy.GetString("BackFlowShopBuyTip", new object[]
{
byGoodID.ItemCount,
text
}), new object[0]);
XSingleton<UiUtility>.singleton.ShowModalDialog(message, new ButtonClickEventHandler(this.OnClickOKBtn));
result = true;
}
}
return result;
}
private bool OnClickOKBtn(IXUIButton btn)
{
XBackFlowDocument.Doc.SendBackFlowActivityOperation(BackFlowActOp.BackFlowAct_ShopBuy, (uint)btn.ID);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
return true;
}
}
}
|