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
|
using System;
using KKSG;
using UILib;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XNPCFavorDrama
{
private XFavorParam _param;
private XNPCFavorDocument doc;
private uint npcId = 0u;
public bool BDeprecated = true;
public void ShowNpc(XNpc npc)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.SetVisible(true, true);
this.doc = XDocuments.GetSpecificDocument<XNPCFavorDocument>(XNPCFavorDocument.uuID);
this._param = XDataPool<XFavorParam>.GetData();
this._param.Npc = npc;
this.npcId = npc.TypeID;
XNPCFavorDocument.ShowNPCDrama(npc.TypeID);
}
public uint GetXNpcId()
{
return this.npcId;
}
public void RefreshOperateStatus(bool isfirst = false, string text = null)
{
bool flag = this._param == null;
if (!flag)
{
EFavorState state = this.doc.GetState(this.GetXNpcId());
bool bRecycled = this._param.bRecycled;
if (bRecycled)
{
this._param = XDataPool<XFavorParam>.GetData();
}
switch (state)
{
case EFavorState.CanSend:
this._param.Text = ((text == null) ? this.GetRandomGiveWords() : text);
this._param.isShowSend = !this.IsSendDialogOpen();
this._param.isShowExchange = false;
this._param.sendCallback = new ButtonClickEventHandler(this.ToSend);
break;
case EFavorState.SendWithExchange:
case EFavorState.Exchange:
this._param.Text = ((text == null) ? this.GetRandomGiveWords() : text);
this._param.isShowSend = (!this.IsSendDialogOpen() && !this.IsChangeDialogOpen());
this._param.isShowExchange = !this.IsChangeDialogOpen();
this._param.isShowExchangeRedpoint = true;
this._param.sendCallback = new ButtonClickEventHandler(this.ToSend);
this._param.exchangeCallback = new ButtonClickEventHandler(this.ToExchange);
break;
}
this._FireEvent(this._param);
}
}
private bool IsSendDialogOpen()
{
return DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible() && DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsSendDilogVisible();
}
private bool IsChangeDialogOpen()
{
return DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible() && DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsChangeDialogVisible();
}
private void _FireEvent(XFavorParam param)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.SetUpFavorParam(param);
param.Recycle();
}
private bool ToSend(IXUIButton button)
{
bool flag = DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible();
if (flag)
{
NpcFeelingOneNpc oneNpcByXId = this.doc.GetOneNpcByXId(this.GetXNpcId());
bool flag2 = oneNpcByXId != null && this.doc.IsCanSend();
if (flag2)
{
bool flag3 = this.doc.IsCanLevelUp(oneNpcByXId);
if (flag3)
{
NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId());
XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("NPCFavorisFull"), npcTableInfoByXId.name), "fece00");
}
else
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.ShowNPCFavorSend();
this.RefreshOperateStatus(false, this.GetRandomGiveWords());
this._FireEvent(this._param);
}
}
}
return true;
}
private bool ToExchange(IXUIButton button)
{
bool flag = DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.ShowNPCFavorExchnage();
this.RefreshOperateStatus(false, this.GetRandomExchangeWords());
this._FireEvent(this._param);
}
return true;
}
private bool ToConfirmSend()
{
XSingleton<UiUtility>.singleton.CloseModalDlg();
return true;
}
private string GetRandomGiveWords()
{
NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId());
return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveWords);
}
private string GetSendSuccessWords()
{
NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId());
return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveSuccessWords);
}
private string GetRandomExchangeWords()
{
NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId());
return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.exchangeWords);
}
private string GetExchangeSuccessWords()
{
NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId());
return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveSuccessWords);
}
private string GetRandomStr(string[] content)
{
bool flag = content != null && content.Length != 0;
string result;
if (flag)
{
result = content[XSingleton<XCommon>.singleton.RandomInt(content.Length)];
}
else
{
result = string.Empty;
}
return result;
}
public void SendSuccess()
{
bool flag = DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.NtfSendDramaRefresh();
this.RefreshOperateStatus(false, this.GetSendSuccessWords());
this._FireEvent(this._param);
}
this.doc.PlaySendSuccessFx(this.GetXNpcId());
}
public void ExchangeSuccess()
{
bool flag = DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.NtfExchangeDlgClose();
this.RefreshOperateStatus(false, this.GetExchangeSuccessWords());
this._FireEvent(this._param);
}
this.doc.PlayExchangeSuccessFx(this.GetXNpcId());
}
}
}
|