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
|
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class ReceiveEnergyDlg : DlgHandlerBase
{
protected override string FileName
{
get
{
return "GameSystem/Welfare/ReceiveEnergy";
}
}
private SystemRewardTable.RowData mSupperRewardInfo;
private SystemRewardTable.RowData mDinnerRewardInfo;
private XSystemRewardData mSupperRewardData;
private XSystemRewardData mDinnerRewardData;
private XSystemRewardDocument mDoc;
public IXUIButton m_btnDo;
public ReceiveEnergyPanelModelView supperPanel = new ReceiveEnergyPanelModelView();
public ReceiveEnergyPanelModelView dinnerPanel = new ReceiveEnergyPanelModelView();
private SeqList<int> dinnerData;
private SeqList<int> supperData;
public IXUIButton m_BtnSubscribe;
public IXUIButton m_BtnCancelSubscribe;
private ulong m_rewardUid = 0UL;
private float m_fCoolTime = 0.5f;
private float m_fLastClickBtnTime = 0f;
private ulong SubscribebuttonID = 0UL;
protected override void Init()
{
this.mDoc = (XSingleton<XGame>.singleton.Doc.GetXComponent(XSystemRewardDocument.uuID) as XSystemRewardDocument);
this.mSupperRewardInfo = this.mDoc.GetTableDataByType(SystemRewardTypeMrg.GetTypeUInt(SystemRewardType.RewardSupper));
this.mDinnerRewardInfo = this.mDoc.GetTableDataByType(SystemRewardTypeMrg.GetTypeUInt(SystemRewardType.RewardDinner));
this.m_btnDo = (base.transform.Find("Bg/GetReward").GetComponent("XUIButton") as IXUIButton);
this.dinnerPanel.FindFrom(base.transform.Find("Bg/L"));
this.supperPanel.FindFrom(base.transform.Find("Bg/R"));
this.dinnerData = XSingleton<XGlobalConfig>.singleton.GetSequenceList("DinnerReward", false);
this.supperData = XSingleton<XGlobalConfig>.singleton.GetSequenceList("SupperReward", false);
this.m_BtnSubscribe = (base.transform.Find("Bg/Subscribe").GetComponent("XUIButton") as IXUIButton);
this.m_BtnCancelSubscribe = (base.transform.Find("Bg/UnSubscribe").GetComponent("XUIButton") as IXUIButton);
}
public override void RegisterEvent()
{
this.m_btnDo.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickButtonDo));
this.m_BtnSubscribe.ID = 0UL;
this.m_BtnSubscribe.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSubscribeClick));
this.m_BtnCancelSubscribe.ID = 1UL;
this.m_BtnCancelSubscribe.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSubscribeClick));
}
public override void RefreshData()
{
bool flag = !base.IsVisible();
if (!flag)
{
this.mSupperRewardData = null;
this.mDinnerRewardData = null;
List<XSystemRewardData> dataList = this.mDoc.DataList;
for (int i = 0; i < dataList.Count; i++)
{
bool flag2 = dataList[i].type == SystemRewardTypeMrg.GetTypeUInt(SystemRewardType.RewardSupper);
if (flag2)
{
this.mSupperRewardData = dataList[i];
}
else
{
bool flag3 = dataList[i].type == SystemRewardTypeMrg.GetTypeUInt(SystemRewardType.RewardDinner);
if (flag3)
{
this.mDinnerRewardData = dataList[i];
}
}
bool flag4 = this.mSupperRewardData != null && this.mDinnerRewardData != null;
if (flag4)
{
break;
}
}
bool flag5 = this.mSupperRewardData != null;
if (flag5)
{
this.supperPanel.m_sprFinish.SetVisible(this.mSupperRewardData.state == XSystemRewardState.SRS_FETCHED);
this.SetItemStatue(this.supperData, this.supperPanel);
}
else
{
this.supperPanel.m_sprFinish.SetVisible(false);
}
bool flag6 = this.mDinnerRewardData != null;
if (flag6)
{
this.dinnerPanel.m_sprFinish.SetVisible(this.mDinnerRewardData.state == XSystemRewardState.SRS_FETCHED);
this.SetItemStatue(this.dinnerData, this.dinnerPanel);
}
else
{
this.dinnerPanel.m_sprFinish.SetVisible(false);
}
this.m_btnDo.SetVisible((this.mSupperRewardData == null && this.mDinnerRewardData == null) || (this.mSupperRewardData != null && this.mSupperRewardData.state == XSystemRewardState.SRS_CAN_FETCH) || (this.mDinnerRewardData != null && this.mDinnerRewardData.state == XSystemRewardState.SRS_CAN_FETCH));
}
}
private void SetItemStatue(SeqList<int> lst, ReceiveEnergyPanelModelView go)
{
bool flag = lst.Count > 1;
if (flag)
{
int itemID = lst[0, 0];
int num = lst[0, 1];
ItemList.RowData itemConf = XBagDocument.GetItemConf(itemID);
bool flag2 = itemConf.ItemIcon1 != null && itemConf.ItemIcon1.Length != 0;
if (flag2)
{
go.m_EnerySpr.SetSprite(itemConf.ItemIcon1[0]);
go.m_lbNum.SetText(num.ToString());
}
else
{
this.dinnerPanel.m_lbNum.SetText("");
}
itemID = lst[1, 0];
num = lst[1, 1];
itemConf = XBagDocument.GetItemConf(itemID);
bool flag3 = itemConf.ItemIcon1 != null && itemConf.ItemIcon1.Length != 0;
if (flag3)
{
go.m_ItemGo.SetActive(true);
go.m_ItemIcon.SetSprite(itemConf.ItemIcon1[0]);
go.m_ItemNumLab.SetText(num.ToString());
}
else
{
go.m_ItemGo.SetActive(false);
}
}
else
{
bool flag4 = lst.Count == 1;
if (flag4)
{
int itemID2 = lst[0, 0];
int num2 = lst[0, 1];
ItemList.RowData itemConf2 = XBagDocument.GetItemConf(itemID2);
bool flag5 = itemConf2.ItemIcon1 != null && itemConf2.ItemIcon1.Length != 0;
if (flag5)
{
go.m_EnerySpr.SetSprite(itemConf2.ItemIcon1[0]);
go.m_lbNum.SetText(num2.ToString());
}
else
{
this.dinnerPanel.m_lbNum.SetText("");
}
go.m_ItemGo.SetActive(false);
}
else
{
go.m_lbNum.SetVisible(false);
}
}
}
private bool OnClickButtonDo(IXUIButton go)
{
bool flag = this.SetButtonCool(this.m_fCoolTime);
bool result;
if (flag)
{
result = true;
}
else
{
int num = (int)XBagDocument.BagDoc.GetVirtualItemCount(ItemEnum.FATIGUE);
bool flag2 = this.mSupperRewardData != null && this.mSupperRewardData.state == XSystemRewardState.SRS_CAN_FETCH;
if (flag2)
{
this.m_rewardUid = this.mSupperRewardData.uid;
bool flag3 = num + this.supperData[0, 1] > int.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("MaxFatigue"));
if (flag3)
{
XSingleton<UiUtility>.singleton.ShowFatigueSureDlg(new ButtonClickEventHandler(this.GetFatigueSure));
return true;
}
this.mDoc.ReqFetchReward(this.m_rewardUid);
}
else
{
bool flag4 = this.mDinnerRewardData != null && this.mDinnerRewardData.state == XSystemRewardState.SRS_CAN_FETCH;
if (flag4)
{
this.m_rewardUid = this.mDinnerRewardData.uid;
bool flag5 = num + this.dinnerData[0, 1] > int.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("MaxFatigue"));
if (flag5)
{
XSingleton<UiUtility>.singleton.ShowFatigueSureDlg(new ButtonClickEventHandler(this.GetFatigueSure));
return true;
}
this.mDoc.ReqFetchReward(this.m_rewardUid);
}
}
result = true;
}
return result;
}
private bool SetButtonCool(float time)
{
float num = Time.realtimeSinceStartup - this.m_fLastClickBtnTime;
bool flag = num < time;
bool result;
if (flag)
{
result = true;
}
else
{
this.m_fLastClickBtnTime = Time.realtimeSinceStartup;
result = false;
}
return result;
}
private bool GetFatigueSure(IXUIButton btn)
{
this.mDoc.ReqFetchReward(this.m_rewardUid);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
return true;
}
public override void OnUnload()
{
this.mSupperRewardInfo = null;
this.mDinnerRewardInfo = null;
this.mDoc = null;
base.OnUnload();
}
protected override void OnShow()
{
base.OnShow();
this.RefreshData();
this.RefreshSubscribe();
}
protected override void OnHide()
{
}
protected void OnHideTweenFinished(IXUITweenTool tween)
{
base.SetVisible(false);
}
private bool OnSubscribeClick(IXUIButton button)
{
this.SubscribebuttonID = button.ID;
PushSubscribeTable.RowData pushSubscribe = XPushSubscribeDocument.GetPushSubscribe(PushSubscribeOptions.ReceiveEnergy);
XSingleton<UiUtility>.singleton.ShowModalDialog((button.ID == 0UL) ? pushSubscribe.SubscribeDescription : pushSubscribe.CancelDescription, XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.ReqSubscribeChange));
return true;
}
private bool ReqSubscribeChange(IXUIButton button)
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
XPushSubscribeDocument specificDocument = XDocuments.GetSpecificDocument<XPushSubscribeDocument>(XPushSubscribeDocument.uuID);
specificDocument.ReqSetSubscribe(PushSubscribeOptions.ReceiveEnergy, this.SubscribebuttonID == 0UL);
return true;
}
public void RefreshSubscribe()
{
PushSubscribeTable.RowData pushSubscribe = XPushSubscribeDocument.GetPushSubscribe(PushSubscribeOptions.ReceiveEnergy);
XPushSubscribeDocument specificDocument = XDocuments.GetSpecificDocument<XPushSubscribeDocument>(XPushSubscribeDocument.uuID);
bool flag = XSingleton<XClientNetwork>.singleton.AccountType == LoginType.LGOIN_WECHAT_PF && pushSubscribe.IsShow && specificDocument.OptionsDefault != null && specificDocument.OptionsDefault.Count != 0;
if (flag)
{
bool curSubscribeStatus = specificDocument.GetCurSubscribeStatus(PushSubscribeOptions.ReceiveEnergy);
this.m_BtnSubscribe.gameObject.SetActive(!curSubscribeStatus);
this.m_BtnCancelSubscribe.gameObject.SetActive(curSubscribeStatus);
}
else
{
this.m_BtnSubscribe.gameObject.SetActive(false);
this.m_BtnCancelSubscribe.gameObject.SetActive(false);
}
}
}
}
|