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
|
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class CarnivalContentHander : DlgHandlerBase
{
public GameObject boxTpl;
public GameObject itemTpl;
public IXUIScrollView m_scroll;
public IXUIWrapContent m_content;
public XUIPool m_tabpool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
public List<IXUICheckBox> m_boxs = new List<IXUICheckBox>();
private List<SpActivityNode> currList = new List<SpActivityNode>();
private List<GameObject> itemspool = new List<GameObject>();
private int width = 90;
private Vector3 itempos = Vector3.zero;
protected override void Init()
{
base.Init();
this.boxTpl = base.transform.Find("Tabs/TabTpl").gameObject;
this.m_scroll = (base.transform.Find("detail").GetComponent("XUIScrollView") as IXUIScrollView);
this.m_content = (base.transform.Find("detail/WrapContent").GetComponent("XUIWrapContent") as IXUIWrapContent);
this.m_content.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.UpdateItem));
this.m_tabpool.SetupPool(this.boxTpl.transform.parent.gameObject, this.boxTpl, 2u, true);
this.itemTpl = this.m_content.gameObject.transform.Find("item_tpl/item").gameObject;
this.width = (this.itemTpl.GetComponent("XUISprite") as IXUISprite).spriteWidth;
this.itempos = this.itemTpl.transform.localPosition;
this.itemTpl.SetActive(false);
}
public void Refresh()
{
XCarnivalDocument doc = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc;
string[] childs = doc.GetSuperActivity(doc.currBelong).childs;
this.m_tabpool.ReturnAll(false);
this.m_boxs.Clear();
bool flag = childs != null;
if (flag)
{
int num = 0;
for (int i = 0; i < childs.Length; i++)
{
List<SpActivityNode> tabList = doc.GetTabList(doc.currBelong, i + 1);
bool flag2 = tabList.Count == 0;
if (!flag2)
{
GameObject gameObject = this.m_tabpool.FetchGameObject(false);
gameObject.transform.localPosition = new Vector3((float)(180 * num), 0f, 0f);
IXUICheckBox ixuicheckBox = gameObject.transform.GetComponent("XUICheckBox") as IXUICheckBox;
IXUILabel ixuilabel = ixuicheckBox.gameObject.transform.Find("TextLabel").GetComponent("XUILabel") as IXUILabel;
IXUILabel ixuilabel2 = ixuicheckBox.gameObject.transform.Find("SelectedTextLabel").GetComponent("XUILabel") as IXUILabel;
GameObject gameObject2 = ixuicheckBox.gameObject.transform.Find("RedPoint").gameObject;
gameObject2.SetActive(doc.HasRwdClaimed(doc.currBelong, i + 1) && !doc.IsActivityExpire());
ixuilabel.SetText(childs[i]);
ixuilabel2.SetText(childs[i]);
ixuicheckBox.ID = (ulong)((long)(i + 1));
ixuicheckBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnTabClick));
this.m_boxs.Add(ixuicheckBox);
num++;
}
}
}
bool flag3 = this.m_boxs.Count > 0;
if (flag3)
{
this.m_boxs[0].bChecked = true;
doc.currType = (int)this.m_boxs[0].ID;
this.RefreshList();
}
}
private bool OnTabClick(IXUICheckBox box)
{
bool bChecked = box.bChecked;
if (bChecked)
{
XCarnivalDocument doc = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc;
doc.currType = (int)box.ID;
this.RefreshList();
}
return true;
}
public void RefreshTab()
{
XCarnivalDocument doc = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc;
for (int i = 0; i < this.m_boxs.Count; i++)
{
Transform transform = this.m_boxs[i].gameObject.transform.Find("RedPoint");
bool flag = transform != null;
if (flag)
{
transform.gameObject.SetActive(doc.HasRwdClaimed(doc.currBelong, i + 1) && !doc.IsActivityExpire());
}
}
}
public void RefreshList()
{
this.currList = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc.GetCurrList();
this.currList.Sort(new Comparison<SpActivityNode>(this.SortList));
this.m_content.SetContentCount(this.currList.Count, false);
this.m_scroll.ResetPosition();
}
private int StateValue(SpActivityNode node)
{
bool flag = node.state == 1u;
int result;
if (flag)
{
result = 2;
}
else
{
bool flag2 = node.state == 0u;
if (flag2)
{
result = 1;
}
else
{
result = 0;
}
}
return result;
}
private int SortList(SpActivityNode x, SpActivityNode y)
{
bool flag = x.state != y.state;
int result;
if (flag)
{
result = this.StateValue(y) - this.StateValue(x);
}
else
{
result = (int)(x.row.taskid - y.row.taskid);
}
return result;
}
private void UpdateItem(Transform t, int index)
{
IXUIButton ixuibutton = t.Find("Get").GetComponent("XUIButton") as IXUIButton;
IXUILabel ixuilabel = t.Find("TLabel").GetComponent("XUILabel") as IXUILabel;
IXUILabel ixuilabel2 = t.Find("PLabel").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite = t.Find("Fini").GetComponent("XUISprite") as IXUISprite;
Transform transform = t.Find("items");
transform.transform.localPosition = this.itempos;
SeqListRef<uint> items = this.currList[index].row.items;
this.DestroyChilds(transform);
for (int i = 0; i < items.Count; i++)
{
GameObject gameObject = this.FetchItem();
gameObject.transform.parent = transform;
gameObject.transform.localScale = Vector3.one;
gameObject.transform.localPosition = new Vector3((float)(this.width * i), 0f, 0f);
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)items[i, 0], (int)items[i, 1], false);
IXUISprite ixuisprite2 = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite2.ID = (ulong)items[i, 0];
ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
}
SuperActivityTask.RowData row = this.currList[index].row;
ixuilabel.SetText(row.title);
ixuibutton.ID = (ulong)row.taskid;
ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtnClick));
uint state = this.currList[index].state;
ixuisprite.SetVisible(state == 2u);
ixuibutton.SetVisible(state != 2u);
XCarnivalDocument doc = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc;
bool flag = doc.IsActivityExpire();
CarnivalState carnivalState;
if (flag)
{
carnivalState = CarnivalState.Lock;
}
else
{
bool flag2 = state == 1u;
if (flag2)
{
carnivalState = CarnivalState.Rwd;
}
else
{
bool flag3 = state == 2u;
if (flag3)
{
carnivalState = CarnivalState.Clamed;
}
else
{
bool flag4 = row.jump == 0u;
if (flag4)
{
carnivalState = CarnivalState.Desc;
}
else
{
carnivalState = CarnivalState.Task;
}
}
}
}
ixuilabel2.SetVisible(row.cnt > 0 && carnivalState != CarnivalState.Clamed);
ixuilabel2.SetText(string.Format("{0}/{1}", this.currList[index].progress, row.cnt));
this.SetBtn(ixuibutton, carnivalState);
}
private void SetBtn(IXUIButton btn, CarnivalState type)
{
btn.SetEnable(type != CarnivalState.Lock && type != CarnivalState.Desc, false);
IXUILabel ixuilabel = btn.gameObject.transform.Find("MoneyCost").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite = btn.gameObject.transform.Find("RedPoint").GetComponent("XUISprite") as IXUISprite;
ixuilabel.SetText((type == CarnivalState.Task) ? XStringDefineProxy.GetString("PVPActivity_Go") : XStringDefineProxy.GetString("SRS_FETCH"));
ixuisprite.SetVisible(type == CarnivalState.Rwd);
bool flag = type == CarnivalState.Desc;
if (flag)
{
ixuilabel.SetText(XStringDefineProxy.GetString("CarnivalNone"));
}
}
private bool OnBtnClick(IXUIButton btn)
{
ulong id = btn.ID;
this.currList = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc.GetCurrList();
for (int i = 0; i < this.currList.Count; i++)
{
bool flag = (ulong)this.currList[i].row.taskid == id;
if (flag)
{
bool flag2 = this.currList[i].state == 1u;
if (flag2)
{
DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.doc.RequestClaim((uint)id);
}
else
{
SuperActivityTask.RowData row = this.currList[i].row;
bool flag3 = row.arg != null && row.arg.Length != 0;
if (flag3)
{
bool flag4 = row.arg[0] == 1;
if (flag4)
{
DlgBase<DungeonSelect, DungeonSelectBehaviour>.singleton.SelectChapter(row.arg[1], (uint)row.arg[2]);
}
else
{
bool flag5 = row.arg[0] == 2;
if (flag5)
{
DlgBase<TheExpView, TheExpBehaviour>.singleton.ShowView(row.arg[1]);
}
}
}
else
{
XSingleton<XGameSysMgr>.singleton.OpenSystem((int)row.jump);
}
}
}
}
return true;
}
private GameObject FetchItem()
{
return this.NewGameobject();
}
private void DestroyChilds(Transform pa)
{
for (int i = 0; i < pa.childCount; i++)
{
Transform child = pa.GetChild(i);
UnityEngine.Object.Destroy(child.gameObject);
}
}
private GameObject NewGameobject()
{
GameObject gameObject = XCommon.Instantiate<GameObject>(this.itemTpl);
gameObject.SetActive(true);
return gameObject;
}
}
}
|