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
|
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XNPCFavorDramaExchange : DlgHandlerBase
{
private XNPCFavorDrama operate
{
get
{
return XNPCFavorDocument.IsNpcDialogVisible();
}
}
protected override string FileName
{
get
{
return "GameSystem/NpcBlessing/NpcChangePresent";
}
}
private XNPCFavorDocument doc;
private IXUIButton exchangeBtn = null;
private Transform npcReturnItem = null;
private Transform myItem = null;
private IXUIButton closeBtn = null;
private ItemBrief role2npc = null;
private ItemBrief npc2role = null;
protected override void Init()
{
base.Init();
this.doc = XDocuments.GetSpecificDocument<XNPCFavorDocument>(XNPCFavorDocument.uuID);
this.exchangeBtn = (base.transform.Find("Bg/OK").GetComponent("XUIButton") as IXUIButton);
this.npcReturnItem = base.transform.Find("Bg/ItemNpc");
this.myItem = base.transform.Find("Bg/ItemPlayer");
this.closeBtn = (base.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton);
}
protected override void OnShow()
{
this.RefreshData();
}
public override void RegisterEvent()
{
base.RegisterEvent();
this.exchangeBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickExchange));
this.closeBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickClose));
}
public override void OnUnload()
{
this.doc = null;
this.role2npc = null;
this.npc2role = null;
}
public override void RefreshData()
{
XNPCFavorDrama xnpcfavorDrama = XNPCFavorDocument.IsNpcDialogVisible();
bool flag = xnpcfavorDrama != null;
if (flag)
{
List<ItemBrief> exchangeInfoByXId = this.doc.GetExchangeInfoByXId(xnpcfavorDrama.GetXNpcId());
bool flag2 = exchangeInfoByXId != null;
if (flag2)
{
bool flag3 = this.doc.Role2NPC != null && this.doc.NPC2Role != null && this.doc.ExchangeNPCID == XNPCFavorDocument.GetNpcIdByXId(xnpcfavorDrama.GetXNpcId());
if (flag3)
{
this.role2npc = this.doc.Role2NPC;
this.npc2role = this.doc.NPC2Role;
}
else
{
bool flag4 = exchangeInfoByXId != null && exchangeInfoByXId.Count > 0 && exchangeInfoByXId.Count % 2 == 0;
if (flag4)
{
int num = exchangeInfoByXId.Count - 1;
this.role2npc = exchangeInfoByXId[num - 1];
this.npc2role = exchangeInfoByXId[num];
}
}
bool flag5 = this.role2npc == null || this.npc2role == null;
if (!flag5)
{
this.DrawItem(this.myItem, (int)this.role2npc.itemID, (int)this.role2npc.itemCount);
this.DrawItem(this.npcReturnItem, (int)this.npc2role.itemID, (int)this.npc2role.itemCount);
}
}
}
}
private bool OnClickExchange(IXUIButton btn)
{
bool flag = this.role2npc == null;
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = this.role2npc != null;
if (flag2)
{
ulong itemCount = XBagDocument.BagDoc.GetItemCount((int)this.role2npc.itemID);
bool flag3 = itemCount < (ulong)this.role2npc.itemCount;
if (flag3)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NPCExchangeItemNotEnough"), "fece00");
return true;
}
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)this.role2npc.itemID);
string arg = (itemConf == null) ? string.Empty : itemConf.ItemName[0];
XSingleton<UiUtility>.singleton.ShowModalDialog(string.Format(XStringDefineProxy.GetString("NPCExchangeHint"), this.role2npc.itemCount, arg), new ButtonClickEventHandler(this.ConfirmExchange));
}
result = true;
}
return result;
}
private bool OnClickClose(IXUIButton btn)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.SetVisible(false, true);
return true;
}
private bool ConfirmExchange(IXUIButton btn)
{
XNPCFavorDrama xnpcfavorDrama = XNPCFavorDocument.IsNpcDialogVisible();
bool flag = xnpcfavorDrama != null && this.role2npc != null && this.npc2role != null;
if (flag)
{
this.doc.ReqSrvExchangeGift(XNPCFavorDocument.GetNpcIdByXId(xnpcfavorDrama.GetXNpcId()), this.role2npc, this.npc2role);
}
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
return true;
}
private void DrawItem(Transform item, int itemId, int itemNum)
{
XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(item.gameObject, itemId, itemNum, true);
IXUISprite ixuisprite = item.Find("Icon").GetComponent("XUISprite") as IXUISprite;
ixuisprite.ID = (ulong)((long)itemId);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
IXUILabel ixuilabel = item.Find("Name").GetComponent("XUILabel") as IXUILabel;
ItemList.RowData itemConf = XBagDocument.GetItemConf(itemId);
ixuilabel.SetText((itemConf != null) ? itemConf.ItemName[0] : string.Empty);
}
}
}
|