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
|
using System;
using System.Collections.Generic;
using System.Text;
using KKSG;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XNPCUnionMemSubHandler : DlgHandlerBase
{
private XNPCUnionHandler _parentHandler = null;
private XNPCFavorDocument m_doc;
private IXUIScrollView m_ScrollView;
private IXUIWrapContent m_WrapContent;
private IXUIScrollView m_GroupEffectScrollView;
private IXUIWrapContent m_GroupEffecWrapContent;
private IXUIList m_AttrGrid;
private XUIPool m_AttrPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private IXUIButton m_NextLevelBtn;
private IXUIButton m_ActiveBtn;
private GameObject m_ActiveRedPoint;
private List<uint> m_NpcIds = new List<uint>();
private uint SelectedUnionId = 0u;
private IXUILabel m_ActiveCondition;
private const int GROUP_NUM = 5;
public void SetParentHandler(XNPCUnionHandler handler = null)
{
this._parentHandler = handler;
}
protected override void Init()
{
base.Init();
this.m_doc = XDocuments.GetSpecificDocument<XNPCFavorDocument>(XNPCFavorDocument.uuID);
this.m_ScrollView = (base.transform.Find("ScrollView").GetComponent("XUIScrollView") as IXUIScrollView);
this.m_WrapContent = (base.transform.Find("ScrollView/Grid").GetComponent("XUIWrapContent") as IXUIWrapContent);
this.m_GroupEffectScrollView = (base.transform.Find("GroupEffect/ScrollView").GetComponent("XUIScrollView") as IXUIScrollView);
this.m_GroupEffecWrapContent = (base.transform.Find("GroupEffect/ScrollView/Grid").GetComponent("XUIWrapContent") as IXUIWrapContent);
this.m_AttrGrid = (base.transform.Find("AttrGrid").GetComponent("XUIList") as IXUIList);
Transform transform = base.transform.Find("AttrGrid/Tpl");
this.m_AttrPool.SetupPool(this.m_AttrGrid.gameObject, transform.gameObject, 4u, false);
this.m_NextLevelBtn = (base.transform.Find("NextLevelBtn").GetComponent("XUIButton") as IXUIButton);
this.m_ActiveBtn = (base.transform.Find("ActiveBtn").GetComponent("XUIButton") as IXUIButton);
this.m_ActiveRedPoint = base.transform.Find("ActiveBtn/RedPoint").gameObject;
this.m_ActiveRedPoint.SetActive(false);
this.m_ActiveCondition = (base.transform.Find("Tips").GetComponent("XUILabel") as IXUILabel);
}
protected override void OnShow()
{
this.RefreshData();
}
public override void RegisterEvent()
{
this.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.WrapListUpdate));
this.m_GroupEffecWrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.GroupEffectUpdate));
this.m_NextLevelBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickNextLevelBtn));
this.m_ActiveBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickActiveBtn));
}
public override void RefreshData()
{
this.SetUpItems();
this.SetUpEffects();
this.RefreshAttr();
}
public override void OnUnload()
{
this._parentHandler = null;
this.SelectedUnionId = 0u;
}
private void WrapListUpdate(Transform item, int index)
{
bool flag = index >= this.m_NpcIds.Count;
if (flag)
{
this.DrawItem(item, 0u, true);
}
else
{
uint npcid = this.m_NpcIds[index];
this.DrawItem(item, npcid, false);
}
}
private void SetUpItems()
{
this.m_NpcIds.Clear();
this.SelectedUnionId = this._parentHandler.SelectedUnionID;
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
NpcUniteAttr.RowData unionTableInfoByUnionId = XNPCFavorDocument.GetUnionTableInfoByUnionId(this.SelectedUnionId, (activeUniteInfo == null) ? 0u : activeUniteInfo.level);
bool flag2 = unionTableInfoByUnionId != null;
if (flag2)
{
int i = 0;
int num = unionTableInfoByUnionId.npcId.Length;
while (i < num)
{
this.m_NpcIds.Add(unionTableInfoByUnionId.npcId[i]);
i++;
}
}
this.m_WrapContent.SetContentCount(this.m_NpcIds.Count, false);
this.m_ScrollView.ResetPosition();
}
}
private void DrawItem(Transform item, uint npcid, bool isHide = false)
{
IXUISprite ixuisprite = item.Find("rt/Icon").GetComponent("XUISprite") as IXUISprite;
IXUILabel ixuilabel = item.Find("rt/EquipLevel").GetComponent("XUILabel") as IXUILabel;
IXUILabel ixuilabel2 = item.Find("rt/wjh").GetComponent("XUILabel") as IXUILabel;
Transform transform = item.Find("rt");
if (isHide)
{
transform.gameObject.SetActive(false);
}
else
{
transform.gameObject.SetActive(true);
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(npcid);
NpcFeeling.RowData npcTableInfoById = XNPCFavorDocument.GetNpcTableInfoById(npcid);
bool flag = npcTableInfoById != null;
if (flag)
{
ixuisprite.SetSprite(npcTableInfoById.relicsIcon);
}
ixuilabel2.SetText((oneNpc != null) ? string.Empty : XStringDefineProxy.GetString("NPCNotActive2"));
ixuilabel.SetText((oneNpc != null) ? string.Format("Lv.{0}", oneNpc.level) : string.Empty);
ixuisprite.ID = (ulong)npcid;
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickNpc));
}
}
private void SetUpEffects()
{
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
uint num = (activeUniteInfo == null) ? 0u : XNPCFavorDocument.GetUnionEffectLev(this.SelectedUnionId, activeUniteInfo.level);
uint num2 = num / 5u;
this.m_GroupEffecWrapContent.SetContentCount((int)(num2 + 5u), false);
this.m_GroupEffectScrollView.ResetPosition();
}
}
private void GroupEffectUpdate(Transform item, int index)
{
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
uint num = (activeUniteInfo == null) ? 0u : XNPCFavorDocument.GetUnionEffectLev(this.SelectedUnionId, activeUniteInfo.level);
uint num2 = num / 5u;
uint num3 = num % 5u;
uint num4 = 5u - num3;
bool flag2 = index < (int)(num2 + 5u);
if (flag2)
{
bool flag3 = (long)index < (long)((ulong)num2);
if (flag3)
{
this.DrawEffect(item, 2);
}
else
{
bool flag4 = index < (int)(num2 + num3);
if (flag4)
{
this.DrawEffect(item, 1);
}
else
{
bool flag5 = index < (int)(num2 + num3 + num4);
if (flag5)
{
this.DrawEffect(item, 0);
}
}
}
}
else
{
this.DrawEffect(item, -1);
}
}
}
private void DrawEffect(Transform item, int num)
{
IXUISprite ixuisprite = item.Find("rt/Icon").GetComponent("XUISprite") as IXUISprite;
Transform transform = item.Find("rt");
switch (num)
{
case -1:
transform.gameObject.SetActive(false);
break;
case 0:
transform.gameObject.SetActive(true);
ixuisprite.SetAlpha(0f);
break;
case 1:
transform.gameObject.SetActive(true);
ixuisprite.SetAlpha(1f);
ixuisprite.SetSprite("Group_0_0");
break;
case 2:
transform.gameObject.SetActive(true);
ixuisprite.SetAlpha(1f);
ixuisprite.SetSprite("Group_0_1");
break;
}
}
private void RefreshAttr()
{
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
this.m_AttrPool.FakeReturnAll();
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
NpcUniteAttr.RowData unionTableInfoByUnionId = XNPCFavorDocument.GetUnionTableInfoByUnionId(this.SelectedUnionId, (activeUniteInfo == null) ? 0u : activeUniteInfo.level);
SeqListRef<uint> attr = unionTableInfoByUnionId.Attr;
for (int i = 0; i < attr.Count; i++)
{
GameObject gameObject = this.m_AttrPool.FetchGameObject(false);
gameObject.transform.parent = this.m_AttrGrid.gameObject.transform;
gameObject.transform.localScale = Vector3.one;
uint attrValue = (activeUniteInfo == null) ? 0u : attr[i, 1];
this.DrawAttr(gameObject.transform, attr[i, 0], attrValue);
}
this.m_AttrPool.ActualReturnAll(false);
this.m_AttrGrid.Refresh();
NpcUniteAttr.RowData nextUnionDataByUnionId = XNPCFavorDocument.GetNextUnionDataByUnionId(this.SelectedUnionId, (activeUniteInfo == null) ? 0u : activeUniteInfo.level);
bool flag2 = nextUnionDataByUnionId != null;
if (flag2)
{
this.m_ActiveCondition.SetText(string.Format(XStringDefineProxy.GetString("NPCUnionActiveCondition"), nextUnionDataByUnionId.level));
}
this.m_ActiveRedPoint.SetActive(this.m_doc.IsUnionCanActiveNextLevel(this.SelectedUnionId));
}
}
private void DrawAttr(Transform item, uint attrId, uint attrValue)
{
IXUILabel ixuilabel = item.Find("Name").GetComponent("XUILabel") as IXUILabel;
IXUILabel ixuilabel2 = item.Find("Value").GetComponent("XUILabel") as IXUILabel;
ixuilabel.SetText(XAttributeCommon.GetAttrStr((int)attrId));
ixuilabel2.SetText(XAttributeCommon.GetAttrValueStr(attrId, attrValue, true));
}
private void OnClickNpc(IXUISprite sp)
{
uint npcId = (uint)sp.ID;
bool flag = this.m_doc.View.IsVisible();
if (flag)
{
this.m_doc.View.SkipToNpc(npcId);
}
}
private bool OnClickNextLevelBtn(IXUIButton btn)
{
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
NpcUniteAttr.RowData nextUnionDataByUnionId = XNPCFavorDocument.GetNextUnionDataByUnionId(this.SelectedUnionId, (activeUniteInfo == null) ? 0u : activeUniteInfo.level);
bool flag2 = nextUnionDataByUnionId != null;
if (flag2)
{
string @string = XStringDefineProxy.GetString("NPCNextAddition");
SeqListRef<uint> attr = nextUnionDataByUnionId.Attr;
StringBuilder sb = XNPCFavorDocument.sb;
sb.Length = 0;
for (int i = 0; i < attr.Count; i++)
{
uint attrid = attr[i, 0];
uint attrValue = attr[i, 1];
bool flag3 = i != 0;
if (flag3)
{
sb.Append("\n");
}
sb.Append(string.Format("{0}{1}", XAttributeCommon.GetAttrStr((int)attrid), XAttributeCommon.GetAttrValueStr(attrid, attrValue, true)));
}
string label = sb.ToString();
XSingleton<UiUtility>.singleton.ShowModalDialogWithTitle(@string, label, XStringDefineProxy.GetString(XStringDefine.COMMON_OK), null, 50);
}
}
return true;
}
private bool OnClickActiveBtn(IXUIButton btn)
{
bool flag = this.SelectedUnionId > 0u;
if (flag)
{
bool flag2 = this.m_doc.IsUnionCanActiveNextLevel(this.SelectedUnionId);
if (flag2)
{
NpcFeelingUnite activeUniteInfo = this.m_doc.GetActiveUniteInfo(this.SelectedUnionId);
NpcUniteAttr.RowData nextUnionDataByUnionId = XNPCFavorDocument.GetNextUnionDataByUnionId(this.SelectedUnionId, (activeUniteInfo == null) ? 0u : activeUniteInfo.level);
bool flag3 = nextUnionDataByUnionId != null;
if (flag3)
{
this.m_doc.ReqSrvActiveUnionLevel(this.SelectedUnionId, nextUnionDataByUnionId.level);
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCUnionNotReachActive"), "fece00");
}
}
return true;
}
}
}
|