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
|
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XUtliPoolLib;
namespace XMainClient
{
internal class XGuildSignInDocument : XDocComponent, ILogSource
{
public override uint ID
{
get
{
return XGuildSignInDocument.uuID;
}
}
public XGuildSignInView GuildSignInView { get; set; }
public uint TotalCount { get; set; }
public uint CurrentCount { get; set; }
public uint SignInSelection
{
get
{
return this._SignInSelection;
}
set
{
this._SignInSelection = value;
this._CheckCanSignIn();
}
}
public uint Progress
{
get
{
return this._Progress;
}
}
public int CanSignInSelection
{
get
{
return this._CanSignInSelection;
}
}
public bool bHasAvailableChest
{
get
{
return this._bHasAvailableChest;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("GuildSignInDocument");
public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
private static GuildCheckinTable m_SignInTable = new GuildCheckinTable();
private static GuildCheckinBoxTable m_BoxTable = new GuildCheckinBoxTable();
private List<ILogData> m_LogList = new List<ILogData>();
private uint _SignInSelection;
private uint _Progress;
private int _CanSignInSelection;
private bool _bHasAvailableChest;
private uint _BoxState;
public List<ILogData> GetLogList()
{
return this.m_LogList;
}
public void SetChestStateAndProgress(uint progress, uint chest)
{
this._BoxState = chest;
this._Progress = progress;
bool flag = this.CheckAvailableChest();
if (flag)
{
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
}
bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag2)
{
this.GuildSignInView.RefreshProgress();
}
}
public int _CheckCanSignIn()
{
this._CanSignInSelection = 0;
bool flag = this.SignInSelection == 0u;
if (flag)
{
for (int i = XGuildSignInDocument.m_SignInTable.Table.Length - 1; i >= 0; i--)
{
GuildCheckinTable.RowData rowData = XGuildSignInDocument.m_SignInTable.Table[i];
ulong virtualItemCount = XSingleton<XGame>.singleton.Doc.XBagDoc.GetVirtualItemCount((ItemEnum)rowData.consume[0]);
bool flag2 = virtualItemCount >= (ulong)rowData.consume[1];
if (flag2)
{
this._CanSignInSelection = i + 1;
break;
}
}
}
return this._CanSignInSelection;
}
private bool CheckAvailableChest()
{
this._bHasAvailableChest = false;
for (int i = 0; i < XGuildSignInDocument.m_BoxTable.Table.Length; i++)
{
bool flag = XGuildSignInDocument.m_BoxTable.Table[i].process <= this._Progress && !this.IsBoxOpen(i);
if (flag)
{
this._bHasAvailableChest = true;
break;
}
}
return this._bHasAvailableChest;
}
public bool IsBoxOpen(int index)
{
return ((ulong)this._BoxState & (ulong)(1L << (index & 31))) > 0UL;
}
public void SetBoxOpen(int index)
{
this._BoxState |= 1u << index;
}
public static void Execute(OnLoadedCallback callback = null)
{
XGuildSignInDocument.AsyncLoader.AddTask("Table/GuildCheckin", XGuildSignInDocument.m_SignInTable, false);
XGuildSignInDocument.AsyncLoader.AddTask("Table/GuildCheckinBox", XGuildSignInDocument.m_BoxTable, false);
XGuildSignInDocument.AsyncLoader.Execute(callback);
}
public static GuildCheckinTable.RowData[] GetSignInTableData()
{
return XGuildSignInDocument.m_SignInTable.Table;
}
public static GuildCheckinBoxTable.RowData[] GetBoxTableData()
{
return XGuildSignInDocument.m_BoxTable.Table;
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._Progress = 0u;
this._BoxState = 0u;
this._bHasAvailableChest = false;
this.SignInSelection = 100u;
}
protected override void EventSubscribe()
{
base.EventSubscribe();
base.RegisterEvent(XEventDefine.XEvent_InGuildStateChanged, new XComponent.XEventHandler(this.OnInGuildStateChanged));
base.RegisterEvent(XEventDefine.XEvent_VirtualItemChanged, new XComponent.XEventHandler(this.OnVirtualItemChanged));
}
protected bool OnVirtualItemChanged(XEventArgs args)
{
bool flag = this.SignInSelection > 0u;
bool result;
if (flag)
{
result = true;
}
else
{
this._CheckCanSignIn();
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
result = true;
}
return result;
}
protected bool OnInGuildStateChanged(XEventArgs args)
{
XInGuildStateChangedEventArgs xinGuildStateChangedEventArgs = args as XInGuildStateChangedEventArgs;
bool flag = !xinGuildStateChangedEventArgs.bIsEnter;
if (flag)
{
this.SignInSelection = 100u;
this._bHasAvailableChest = false;
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
}
return true;
}
protected override void OnReconnected(XReconnectedEventArgs arg)
{
bool flag = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag)
{
this.ReqAllInfo();
}
}
public void ReqAllInfo()
{
RpcC2M_QueryGuildCheckinNew rpc = new RpcC2M_QueryGuildCheckinNew();
XSingleton<XClientNetwork>.singleton.Send(rpc);
}
public void OnGetAllInfo(QueryGuildCheckinRes oRes)
{
this.SignInSelection = oRes.checkin;
this.CurrentCount = oRes.checkincount;
this.TotalCount = oRes.allcount;
this._BoxState = oRes.boxmask;
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
bool flag = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag)
{
this.GuildSignInView.Refresh();
}
}
public void ReqFetchBox(uint index)
{
RpcC2G_GetGuildCheckinBox rpcC2G_GetGuildCheckinBox = new RpcC2G_GetGuildCheckinBox();
rpcC2G_GetGuildCheckinBox.oArg.index = index;
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_GetGuildCheckinBox);
}
public void OnFetchBox(GetGuildCheckinBoxArg oArg, GetGuildCheckinBoxRes oRes)
{
bool flag = oRes.errorcode > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.errorcode, "fece00");
}
else
{
this.SetBoxOpen((int)oArg.index);
bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag2)
{
this.GuildSignInView.OpenBox((int)oArg.index);
}
bool flag3 = !this.CheckAvailableChest();
if (flag3)
{
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
}
}
}
public void ReqSignIn(uint index)
{
RpcC2M_GuildCheckinNew rpcC2M_GuildCheckinNew = new RpcC2M_GuildCheckinNew();
rpcC2M_GuildCheckinNew.oArg.type = index;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GuildCheckinNew);
}
public void OnSignIn(GuildCheckinArg oArg, GuildCheckinRes oRes)
{
bool flag = oRes.errorcode > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.errorcode, "fece00");
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_SIGNIN_SUCCESS"), "fece00");
this.SignInSelection = oArg.type;
uint currentCount = this.CurrentCount + 1u;
this.CurrentCount = currentCount;
bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag2)
{
this.GuildSignInView.Refresh();
}
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true);
}
}
public void ReqLogList()
{
RpcC2M_GetGuildCheckinRecordsNew rpc = new RpcC2M_GetGuildCheckinRecordsNew();
XSingleton<XClientNetwork>.singleton.Send(rpc);
}
public void onGetLogList(GetGuildCheckinRecordsRes oRes)
{
int num = oRes.name.Count - this.m_LogList.Count;
for (int i = 0; i < num; i++)
{
this.m_LogList.Add(new XGuildSignInLog());
}
bool flag = num < 0;
if (flag)
{
this.m_LogList.RemoveRange(this.m_LogList.Count + num, -num);
}
for (int j = 0; j < this.m_LogList.Count; j++)
{
XGuildSignInLog xguildSignInLog = this.m_LogList[this.m_LogList.Count - j - 1] as XGuildSignInLog;
xguildSignInLog.name = oRes.name[j];
xguildSignInLog.uid = oRes.roleid[j];
xguildSignInLog.type = oRes.type[j];
xguildSignInLog.time = (int)oRes.timestamp[j];
}
bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible();
if (flag2)
{
this.GuildSignInView.LogView.Refresh();
}
}
}
}
|