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
|
using System;
using System.Collections.Generic;
using System.Text;
using KKSG;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XNPCSendSubHandler : DlgHandlerBase
{
private XNPCFavorHandler _parentHandler = null;
private XNPCFavorDocument m_doc;
private IXUIScrollView m_ScrollView;
private Transform _items;
protected XUIPool _itemPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private IXUISprite _RelicsSpr;
private IXUILabel _RelicsName;
private IXUILabel _RelicsLevel;
private IXUILabel _RelicsDesc;
private IXUILabel _RelicsAddition;
private IXUILabel _curAttr;
private IXUIButton _NextLevel;
private IXUIButton _LevelUpBtn;
private GameObject _LevelUpRedPoint;
private IXUIButton _SendBtn;
public void SetParentHandler(XNPCFavorHandler handler = null)
{
this._parentHandler = handler;
}
protected override void Init()
{
base.Init();
this.m_doc = XDocuments.GetSpecificDocument<XNPCFavorDocument>(XNPCFavorDocument.uuID);
this._items = null;
this._items = base.transform.Find("Panel/Items");
this.m_ScrollView = (this._items.GetComponent("XUIScrollView") as IXUIScrollView);
this._itemPool.SetupPool(this._items.gameObject, this._items.Find("Item").gameObject, 4u, false);
this._RelicsSpr = (base.transform.Find("EquipItem").GetComponent("XUISprite") as IXUISprite);
this._RelicsName = (base.transform.Find("Title/EquipName").GetComponent("XUILabel") as IXUILabel);
this._RelicsLevel = (base.transform.Find("Title/Level").GetComponent("XUILabel") as IXUILabel);
this._RelicsDesc = (base.transform.Find("Title/Tips").GetComponent("XUILabel") as IXUILabel);
this._RelicsAddition = (base.transform.Find("EquipEffect/Value").GetComponent("XUILabel") as IXUILabel);
this._curAttr = (base.transform.Find("EquipEffect/AttrValue").GetComponent("XUILabel") as IXUILabel);
this._NextLevel = (base.transform.Find("NextLevelBtn").GetComponent("XUIButton") as IXUIButton);
this._LevelUpBtn = (base.transform.Find("LevelUpBtn").GetComponent("XUIButton") as IXUIButton);
this._LevelUpRedPoint = base.transform.Find("LevelUpBtn/RedPoint").gameObject;
this._LevelUpRedPoint.SetActive(false);
this._SendBtn = (base.transform.Find("GoBtn").GetComponent("XUIButton") as IXUIButton);
}
protected override void OnShow()
{
this.RefreshData();
}
public override void RefreshData()
{
this.RefreshRelics();
this.RefreshItems();
}
public override void RegisterEvent()
{
this._NextLevel.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickNextAdditionBtn));
this._LevelUpBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickLevelUpBtn));
this._SendBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickSendBtn));
}
public override void OnUnload()
{
this.m_doc = null;
this._parentHandler = null;
}
private void RefreshRelics()
{
bool flag = this._parentHandler._selectedNPCID == 0u;
if (!flag)
{
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(this._parentHandler._selectedNPCID);
NpcFeeling.RowData npcTableInfoById = XNPCFavorDocument.GetNpcTableInfoById(this._parentHandler._selectedNPCID);
this._RelicsSpr.SetSprite(npcTableInfoById.relicsIcon);
this._RelicsName.SetText(npcTableInfoById.relicsName);
this._RelicsLevel.SetText(string.Format("Lv.{0}", (oneNpc == null) ? 0u : oneNpc.level));
this._RelicsDesc.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(npcTableInfoById.relicsDesc));
uint lev = (oneNpc != null) ? oneNpc.level : 0u;
NpcFeelingAttr.RowData attrDataByLevel = XNPCFavorDocument.GetAttrDataByLevel(npcTableInfoById.npcId, lev);
bool flag2 = attrDataByLevel != null;
if (flag2)
{
StringBuilder sb = XNPCFavorDocument.sb;
sb.Length = 0;
int i = 0;
int count = attrDataByLevel.Attr.Count;
while (i < count)
{
uint attrid = attrDataByLevel.Attr[i, 0];
uint attrValue = attrDataByLevel.Attr[i, 1];
bool flag3 = i != 0;
if (flag3)
{
sb.Append(" ");
}
sb.Append(string.Format("{0}{1}", XAttributeCommon.GetAttrStr((int)attrid), (oneNpc != null) ? XAttributeCommon.GetAttrValueStr(attrid, attrValue, true) : "+0"));
i++;
}
this._curAttr.SetText(sb.ToString());
}
else
{
this._curAttr.SetText(string.Empty);
}
NpcFeelingAttr.RowData npcAttrByIdLev = XNPCFavorDocument.GetNpcAttrByIdLev(npcTableInfoById.npcId, (oneNpc == null) ? 0u : oneNpc.level);
bool flag4 = npcAttrByIdLev != null;
if (flag4)
{
this._RelicsAddition.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(npcAttrByIdLev.RelicsDesc));
}
else
{
this._RelicsAddition.SetText(string.Empty);
}
this._LevelUpRedPoint.SetActive(this.m_doc.IsCanLevelUp(oneNpc));
}
}
private void RefreshItems()
{
this._itemPool.ReturnAll(false);
bool flag = this._parentHandler._selectedNPCID > 0u;
if (flag)
{
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(this._parentHandler._selectedNPCID);
bool flag2 = oneNpc != null;
if (flag2)
{
List<NpcLikeItem> likeitem = oneNpc.likeitem;
bool flag3 = likeitem != null;
if (flag3)
{
for (int i = 0; i < likeitem.Count; i++)
{
this.DrawItem((int)likeitem[i].itemid, (int)likeitem[i].itemcount, i);
}
}
}
else
{
NpcFeeling.RowData npcTableInfoById = XNPCFavorDocument.GetNpcTableInfoById(this._parentHandler._selectedNPCID);
SeqListRef<uint> clientItem = npcTableInfoById.clientItem;
for (int j = 0; j < clientItem.Count; j++)
{
this.DrawItem((int)clientItem[j, 0], (int)clientItem[j, 1], j);
}
}
}
this.m_ScrollView.ResetPosition();
}
private void DrawItem(int itemId, int itemNum, int i)
{
Transform transform = this.DrawItem(itemId, itemNum, this._items, i);
IXUILabel ixuilabel = transform.transform.Find("Num").GetComponent("XUILabel") as IXUILabel;
ulong itemCount = XBagDocument.BagDoc.GetItemCount(itemId);
string text = itemCount + "/" + itemNum;
bool flag = itemCount < (ulong)((long)itemNum);
if (flag)
{
text = string.Concat(new object[]
{
"[ff0000]",
itemCount,
"/",
itemNum,
"[-]"
});
}
ixuilabel.SetText(text);
}
private Transform DrawItem(int itemID, int num, Transform parent, int index)
{
GameObject gameObject = this._itemPool.FetchGameObject(false);
gameObject.transform.parent = parent;
gameObject.transform.localPosition = new Vector3((float)(index * this._itemPool.TplWidth), 0f, 0f);
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, itemID, num, true);
IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite.ID = (ulong)((long)itemID);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
return gameObject.transform;
}
private bool OnClickSendBtn(IXUIButton btn)
{
bool flag = this._parentHandler._selectedNPCID == 0u;
bool result;
if (flag)
{
result = true;
}
else
{
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(this._parentHandler._selectedNPCID);
bool flag2 = oneNpc != null;
if (flag2)
{
uint npcXIdById = XNPCFavorDocument.GetNpcXIdById(this._parentHandler._selectedNPCID);
XSingleton<UiUtility>.singleton.CloseModalDlg();
XSingleton<XInput>.singleton.LastNpc = XSingleton<XEntityMgr>.singleton.GetNpc(npcXIdById);
bool flag3 = XSingleton<XInput>.singleton.LastNpc != null;
if (flag3)
{
this.m_doc.View.Close(true);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCNotInScene"), "fece00");
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCNotActive"), "fece00");
}
result = true;
}
return result;
}
private bool OnClickLevelUpBtn(IXUIButton btn)
{
bool flag = this._parentHandler._selectedNPCID == 0u;
bool result;
if (flag)
{
result = true;
}
else
{
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(this._parentHandler._selectedNPCID);
bool flag2 = oneNpc != null;
if (flag2)
{
bool flag3 = this.m_doc.IsCanLevelUp(oneNpc);
if (flag3)
{
this.m_doc.ReqSrvLevelUp(this._parentHandler._selectedNPCID);
}
else
{
bool flag4 = oneNpc.level == this.m_doc.NpcFlLevTop;
if (flag4)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_NPCFL_NPC_LEVEL_MAX"), "fece00");
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCLessEXP"), "fece00");
}
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCNotActive"), "fece00");
}
result = true;
}
return result;
}
private bool OnClickNextAdditionBtn(IXUIButton btn)
{
bool flag = this._parentHandler._selectedNPCID == 0u;
bool result;
if (flag)
{
result = true;
}
else
{
NpcFeelingOneNpc oneNpc = this.m_doc.GetOneNpc(this._parentHandler._selectedNPCID);
bool flag2 = oneNpc != null;
if (flag2)
{
uint selectedNPCID = this._parentHandler._selectedNPCID;
NpcFeelingAttr.RowData attrDataByLevel = XNPCFavorDocument.GetAttrDataByLevel(selectedNPCID, oneNpc.level + 1u);
bool flag3 = attrDataByLevel != null;
if (flag3)
{
string @string = XStringDefineProxy.GetString("NPCNextAddition");
SeqListRef<uint> attr = attrDataByLevel.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 flag4 = i != 0;
if (flag4)
{
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);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCRelicsLevelMAX"), "fece00");
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCNotActive"), "fece00");
}
result = true;
}
return result;
}
}
}
|