summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XAbyssPartyDocument.cs
blob: dfc168c34419c4b34fcc538d273a16f569585ff0 (plain)
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
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XAbyssPartyDocument : XDocComponent
	{
		public override uint ID
		{
			get
			{
				return XAbyssPartyDocument.uuID;
			}
		}

		public static XAbyssPartyDocument Doc
		{
			get
			{
				return XSingleton<XGame>.singleton.Doc.GetXComponent(XAbyssPartyDocument.uuID) as XAbyssPartyDocument;
			}
		}

		public int CurSelectedID
		{
			get
			{
				bool flag = this.m_CurID <= 0;
				if (flag)
				{
					this.SetDefaultID();
				}
				return this.m_CurID;
			}
		}

		public int CurSelectedType
		{
			get
			{
				bool flag = this.m_CurType <= 0;
				if (flag)
				{
					this.SetDefaultType();
				}
				return this.m_CurType;
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("AbyssPartyDocument");

		public AbyssPartyEntranceView View = null;

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		private static AbyssPartyListTable _AbyssPartyListTable = new AbyssPartyListTable();

		private static AbyssPartyTypeTable _AbyssPartyTypeTable = new AbyssPartyTypeTable();

		private List<uint> m_AbyssIndex = new List<uint>();

		private int m_CurID = -1;

		private int m_CurType = -1;

		private static List<AbyssPartyListTable.RowData> CurAbyssPartyList = new List<AbyssPartyListTable.RowData>();

		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this.ResetAbyssIndex();
		}

		public override void OnEnterSceneFinally()
		{
			bool flag = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_ABYSS_PARTY;
			if (flag)
			{
				XSingleton<XUICacheMgr>.singleton.CacheUI(XSysDefine.XSys_AbyssParty, EXStage.Hall);
			}
		}

		protected override void EventSubscribe()
		{
			base.EventSubscribe();
		}

		public override void Update(float fDeltaT)
		{
			base.Update(fDeltaT);
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
			bool flag = arg.PlayerInfo.Stages.absparty != null;
			if (flag)
			{
				this.SetAbyssIndex(arg.PlayerInfo.Stages.absparty.aby);
			}
			bool flag2 = DlgBase<AbyssPartyEntranceView, AbyssPartyEntranceBehaviour>.singleton.IsVisible();
			if (flag2)
			{
				DlgBase<AbyssPartyEntranceView, AbyssPartyEntranceBehaviour>.singleton.RefreshPage();
			}
		}

		public static void Execute(OnLoadedCallback callback = null)
		{
			XAbyssPartyDocument.AsyncLoader.AddTask("Table/AbyssPartyList", XAbyssPartyDocument._AbyssPartyListTable, false);
			XAbyssPartyDocument.AsyncLoader.AddTask("Table/AbyssPartyType", XAbyssPartyDocument._AbyssPartyTypeTable, false);
			XAbyssPartyDocument.AsyncLoader.Execute(callback);
		}

		public static int GetAbyssPartyTypeCount()
		{
			return XAbyssPartyDocument._AbyssPartyTypeTable.Table.Length;
		}

		public static AbyssPartyTypeTable.RowData GetAbyssPartyTypeLine(int line)
		{
			bool flag = line >= XAbyssPartyDocument._AbyssPartyTypeTable.Table.Length;
			AbyssPartyTypeTable.RowData result;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("GetAbyssPartyTypeLine No Find!\nline:" + line, null, null, null, null, null);
				result = null;
			}
			else
			{
				result = XAbyssPartyDocument._AbyssPartyTypeTable.Table[line];
			}
			return result;
		}

		public AbyssPartyTypeTable.RowData GetAbyssPartyType()
		{
			return XAbyssPartyDocument.GetAbyssPartyType(this.CurSelectedType);
		}

		public static AbyssPartyTypeTable.RowData GetAbyssPartyType(int TypeID)
		{
			AbyssPartyTypeTable.RowData byAbyssPartyId = XAbyssPartyDocument._AbyssPartyTypeTable.GetByAbyssPartyId(TypeID);
			bool flag = byAbyssPartyId == null;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("GetAbyssPartyList No Find!\nTypeID:" + TypeID, null, null, null, null, null);
			}
			return byAbyssPartyId;
		}

		public static List<AbyssPartyListTable.RowData> RefreshAbyssPartyListList(int TypeID)
		{
			XAbyssPartyDocument.CurAbyssPartyList.Clear();
			for (int i = 0; i < XAbyssPartyDocument._AbyssPartyListTable.Table.Length; i++)
			{
				bool flag = XAbyssPartyDocument._AbyssPartyListTable.Table[i].AbyssPartyId == TypeID;
				if (flag)
				{
					XAbyssPartyDocument.CurAbyssPartyList.Add(XAbyssPartyDocument._AbyssPartyListTable.Table[i]);
				}
			}
			return XAbyssPartyDocument.CurAbyssPartyList;
		}

		public AbyssPartyListTable.RowData GetAbyssPartyList()
		{
			return XAbyssPartyDocument.GetAbyssPartyList(this.CurSelectedID);
		}

		public static AbyssPartyListTable.RowData GetAbyssPartyList(int key)
		{
			AbyssPartyListTable.RowData byID = XAbyssPartyDocument._AbyssPartyListTable.GetByID(key);
			bool flag = byID == null;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("GetAbyssPartyList No Find!\nkey:" + key, null, null, null, null, null);
			}
			return byID;
		}

		public void SetDefaultType()
		{
			this.m_CurType = 1;
			for (int i = 0; i < XAbyssPartyDocument._AbyssPartyTypeTable.Table.Length; i++)
			{
				bool flag = (ulong)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level < (ulong)((long)XAbyssPartyDocument._AbyssPartyTypeTable.Table[i].OpenLevel);
				if (flag)
				{
					break;
				}
				this.m_CurType = XAbyssPartyDocument._AbyssPartyTypeTable.Table[i].AbyssPartyId;
			}
		}

		public bool SetSelectedType(int type)
		{
			bool flag = type < 0;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.m_CurType = type;
				this.SetDefaultID();
				result = true;
			}
			return result;
		}

		public void SetDefaultID()
		{
			this.m_CurID = 0;
			int abyssIndex = (int)this.GetAbyssIndex(this.CurSelectedType);
			for (int i = 0; i < XAbyssPartyDocument._AbyssPartyListTable.Table.Length; i++)
			{
				bool flag = XAbyssPartyDocument._AbyssPartyListTable.Table[i].AbyssPartyId == this.CurSelectedType && XAbyssPartyDocument._AbyssPartyListTable.Table[i].Index <= abyssIndex;
				if (flag)
				{
					this.m_CurID = XAbyssPartyDocument._AbyssPartyListTable.Table[i].ID;
				}
			}
			bool flag2 = this.m_CurID == 0;
			if (flag2)
			{
				XSingleton<XDebug>.singleton.AddErrorLog(string.Concat(new object[]
				{
					"m_CurID No Find!\nCurSelectedType:",
					this.CurSelectedType,
					"m_CurIndex:",
					abyssIndex
				}), null, null, null, null, null);
			}
		}

		public bool SetSelectedID(int id)
		{
			bool flag = id < 0;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.m_CurID = id;
				result = true;
			}
			return result;
		}

		public void SetAbyssIndex(List<AbsPartyBase> data)
		{
			for (int i = 0; i < data.Count; i++)
			{
				this.SetAbyssIndex(data[i].type, data[i].diff);
			}
		}

		private void ResetAbyssIndex()
		{
			this.m_AbyssIndex.Clear();
			for (int i = 0; i < XAbyssPartyDocument._AbyssPartyTypeTable.Table.Length + 1; i++)
			{
				this.m_AbyssIndex.Add(0u);
			}
		}

		public void SetAbyssIndex(uint type, uint index)
		{
			bool flag = (ulong)type >= (ulong)((long)this.m_AbyssIndex.Count);
			if (!flag)
			{
				this.m_AbyssIndex[(int)type] = index;
				XSingleton<XDebug>.singleton.AddGreenLog(string.Concat(new object[]
				{
					"[AbyssParty]type:",
					type,
					"  index:",
					index
				}), null, null, null, null, null);
			}
		}

		public uint GetAbyssIndex(int type)
		{
			bool flag = type >= this.m_AbyssIndex.Count;
			uint result;
			if (flag)
			{
				result = 0u;
			}
			else
			{
				result = this.m_AbyssIndex[type];
			}
			return result;
		}

		public void AbyssPartyEnter(int apID)
		{
			RpcC2G_AbsEnterScene rpcC2G_AbsEnterScene = new RpcC2G_AbsEnterScene();
			rpcC2G_AbsEnterScene.oArg.id = (uint)apID;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_AbsEnterScene);
			XSingleton<XDebug>.singleton.AddGreenLog("AbyssParty Enter ID:" + apID, null, null, null, null, null);
		}

		public int CanUseCostMAXNum()
		{
			bool flag = false;
			int num = 0;
			for (int i = 0; i < XAbyssPartyDocument._AbyssPartyTypeTable.Table.Length; i++)
			{
				bool flag2 = XAbyssPartyDocument._AbyssPartyTypeTable.Table[i].AbyssPartyId == this.CurSelectedType;
				if (flag2)
				{
					flag = true;
				}
				bool flag3 = flag;
				if (flag3)
				{
					int[] titanItemID = XAbyssPartyDocument._AbyssPartyTypeTable.Table[i].TitanItemID;
					bool flag4 = titanItemID != null && titanItemID.Length != 0;
					if (flag4)
					{
						num += (int)XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemCount(titanItemID[0]);
					}
				}
			}
			XSingleton<XDebug>.singleton.AddGreenLog("CanUseCostMAXNum:" + num, null, null, null, null, null);
			return num;
		}
	}
}