summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/FirstPassDocument.cs
blob: b84a5a5bca7abadf47cb46e1b94db9fdd041e26f (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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

		public int NeedPassTeamCount
		{
			get
			{
				return XSingleton<XGlobalConfig>.singleton.GetInt("PassTeamCount");
			}
		}

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

		public FirstPassMainHandler View { get; set; }

		public List<FirstPassAuxData> FirstPassData
		{
			get
			{
				bool flag = this.m_FirstPassData == null;
				if (flag)
				{
					this.m_FirstPassData = new List<FirstPassAuxData>();
					for (int i = 0; i < FirstPassDocument.sFirstPassTable.Table.Length; i++)
					{
						FirstPassAuxData item = new FirstPassAuxData(FirstPassDocument.sFirstPassTable.Table[i]);
						this.m_FirstPassData.Add(item);
					}
				}
				return this.m_FirstPassData;
			}
		}

		public bool IsHadOutRedDot
		{
			get
			{
				return this.m_isHadOutRedDot;
			}
			set
			{
				bool flag = this.m_isHadOutRedDot != value;
				if (flag)
				{
					this.m_isHadOutRedDot = value;
					XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_OperatingActivity, true);
					bool flag2 = DlgBase<XOperatingActivityView, XOperatingActivityBehaviour>.singleton.IsVisible();
					if (flag2)
					{
						DlgBase<XOperatingActivityView, XOperatingActivityBehaviour>.singleton.RefreshRedpoint();
					}
				}
			}
		}

		public FirstPassAuxData CurData { get; set; }

		public FirstPassRankList RankList
		{
			get
			{
				return this.m_rankList;
			}
		}

		public bool IsHadNextData
		{
			get
			{
				int index = this.GetIndex();
				bool flag = index == this.FirstPassData.Count - 1;
				return !flag && this.FirstPassData[index + 1].IsOpen();
			}
		}

		public bool IsHadLastData
		{
			get
			{
				int index = this.GetIndex();
				bool flag = index == 0;
				return !flag && this.FirstPassData[index - 1].IsOpen();
			}
		}

		public FirstPassAuxData AutoSelectFirstPassData
		{
			get
			{
				bool flag = this.FirstPassData.Count == 0;
				FirstPassAuxData result;
				if (flag)
				{
					result = null;
				}
				else
				{
					bool flag2 = this.FirstPassData.Count == 1;
					if (flag2)
					{
						result = this.FirstPassData[0];
					}
					else
					{
						for (int i = 0; i < this.FirstPassData.Count; i++)
						{
							bool flag3 = i == 0;
							if (flag3)
							{
								bool flag4 = !this.FirstPassData[i].IsOpen();
								if (flag4)
								{
									return this.FirstPassData[i];
								}
							}
							bool flag5 = i == this.FirstPassData.Count - 1;
							if (flag5)
							{
								return this.FirstPassData[i];
							}
							bool flag6 = this.FirstPassData[i].PassTeamCount < this.NeedPassTeamCount;
							if (flag6)
							{
								return this.FirstPassData[i];
							}
							bool flag7 = !this.FirstPassData[i + 1].IsOpen();
							if (flag7)
							{
								return this.FirstPassData[i];
							}
						}
						result = this.FirstPassData[0];
					}
				}
				return result;
			}
		}

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

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		public static FirstPassTable sFirstPassTable = new FirstPassTable();

		public static FirstPassReward sFirstPassReward = new FirstPassReward();

		public static readonly int MaxAvata = 6;

		private List<FirstPassAuxData> m_FirstPassData = null;

		private bool m_isHadOutRedDot = false;

		private FirstPassRankList m_rankList = null;

		public static void Execute(OnLoadedCallback callback = null)
		{
			FirstPassDocument.AsyncLoader.AddTask("Table/FirstPass", FirstPassDocument.sFirstPassTable, false);
			FirstPassDocument.AsyncLoader.AddTask("Table/FirstPassReward", FirstPassDocument.sFirstPassReward, false);
			FirstPassDocument.AsyncLoader.Execute(callback);
		}

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

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

		public override void OnDetachFromHost()
		{
			base.OnDetachFromHost();
			bool flag = this.m_FirstPassData != null;
			if (flag)
			{
				for (int i = 0; i < this.m_FirstPassData.Count; i++)
				{
					this.m_FirstPassData[i] = null;
				}
				this.m_FirstPassData.Clear();
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
			bool flag = DlgBase<FirstPassRankView, FitstpassRankBehaviour>.singleton.IsVisible();
			if (flag)
			{
				this.ReqRankList(this.CurData.Id);
			}
			else
			{
				bool flag2 = this.View != null && this.View.IsVisible();
				if (flag2)
				{
					bool flag3 = this.View.TeamInfoHandler != null && this.View.TeamInfoHandler.IsVisible();
					if (flag3)
					{
						this.ReqFirstPassTopRoleInfo(this.CurData.Id);
					}
					else
					{
						this.ReqFirstPassInfo();
					}
				}
			}
		}

		public override void OnEnterSceneFinally()
		{
			base.OnEnterSceneFinally();
		}

		public void SetCurDataByNestType(int nestType)
		{
			bool flag = this.FirstPassData.Count <= 0;
			if (!flag)
			{
				for (int i = 0; i < this.FirstPassData.Count; i++)
				{
					bool flag2 = this.FirstPassData[i] != null;
					if (flag2)
					{
						bool flag3 = (ulong)this.FirstPassData[i].FirstPassRow.NestType == (ulong)((long)nestType);
						if (flag3)
						{
							this.CurData = this.FirstPassData[i];
							return;
						}
					}
				}
				this.CurData = this.FirstPassData[0];
			}
		}

		public FirstPassAuxData GetNextFirstPassData()
		{
			int index = this.GetIndex();
			bool flag = index == this.FirstPassData.Count - 1;
			FirstPassAuxData result;
			if (flag)
			{
				result = this.CurData;
			}
			else
			{
				bool flag2 = !this.FirstPassData[index + 1].IsOpen();
				if (flag2)
				{
					result = this.CurData;
				}
				else
				{
					result = this.FirstPassData[index + 1];
				}
			}
			return result;
		}

		public FirstPassAuxData GetLastFirstPassData()
		{
			int index = this.GetIndex();
			bool flag = index == 0;
			FirstPassAuxData result;
			if (flag)
			{
				result = this.CurData;
			}
			else
			{
				bool flag2 = !this.FirstPassData[index - 1].IsOpen();
				if (flag2)
				{
					result = this.CurData;
				}
				else
				{
					result = this.FirstPassData[index - 1];
				}
			}
			return result;
		}

		private int GetIndex()
		{
			for (int i = 0; i < this.FirstPassData.Count; i++)
			{
				bool flag = this.FirstPassData[i].Id == this.CurData.Id;
				if (flag)
				{
					return i;
				}
			}
			return 0;
		}

		public bool MainArrowRedDot(ArrowDirection direction)
		{
			bool flag = this.CurData == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				int index = this.GetIndex();
				if (direction != ArrowDirection.Left)
				{
					if (direction == ArrowDirection.Right)
					{
						for (int i = index + 1; i < this.FirstPassData.Count; i++)
						{
							bool flag2 = this.FirstPassData[i].IsCanPrise | this.FirstPassData[i].IsHadReward;
							if (flag2)
							{
								return true;
							}
						}
					}
				}
				else
				{
					for (int j = 0; j < index; j++)
					{
						bool flag3 = this.FirstPassData[j].IsCanPrise | this.FirstPassData[j].IsHadReward;
						if (flag3)
						{
							return true;
						}
					}
				}
				result = false;
			}
			return result;
		}

		public bool InfoArrowRedDot(ArrowDirection direction)
		{
			bool flag = this.CurData == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				int index = this.GetIndex();
				if (direction != ArrowDirection.Left)
				{
					if (direction == ArrowDirection.Right)
					{
						for (int i = index + 1; i < this.FirstPassData.Count; i++)
						{
							bool isCanPrise = this.FirstPassData[i].IsCanPrise;
							if (isCanPrise)
							{
								return true;
							}
						}
					}
				}
				else
				{
					for (int j = 0; j < index; j++)
					{
						bool isCanPrise2 = this.FirstPassData[j].IsCanPrise;
						if (isCanPrise2)
						{
							return true;
						}
					}
				}
				result = false;
			}
			return result;
		}

		public void ReqFirstPassInfo()
		{
			RpcC2G_FirstPassInfoReq rpc = new RpcC2G_FirstPassInfoReq();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		public void ReqFirstPassReward(int firstPassId)
		{
			RpcC2G_GetFirstPassReward rpcC2G_GetFirstPassReward = new RpcC2G_GetFirstPassReward();
			rpcC2G_GetFirstPassReward.oArg.firstPassID = firstPassId;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_GetFirstPassReward);
		}

		public void ReqCommendFirstPass(int firstPassId)
		{
			RpcC2G_CommendFirstPass rpcC2G_CommendFirstPass = new RpcC2G_CommendFirstPass();
			rpcC2G_CommendFirstPass.oArg.firstPassID = firstPassId;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_CommendFirstPass);
		}

		public void ReqFirstPassTopRoleInfo(int firstPassId)
		{
			RpcC2G_FirstPassGetTopRoleInfo rpcC2G_FirstPassGetTopRoleInfo = new RpcC2G_FirstPassGetTopRoleInfo();
			rpcC2G_FirstPassGetTopRoleInfo.oArg.firstPassID = firstPassId;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_FirstPassGetTopRoleInfo);
		}

		public void ReqRankList(int firstPassId)
		{
			RpcC2M_ClientQueryRankListNtf rpcC2M_ClientQueryRankListNtf = new RpcC2M_ClientQueryRankListNtf();
			rpcC2M_ClientQueryRankListNtf.oArg.RankType = (uint)XFastEnumIntEqualityComparer<RankeType>.ToInt(RankeType.FirstPassRank);
			rpcC2M_ClientQueryRankListNtf.oArg.firstPassID = firstPassId;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2M_ClientQueryRankListNtf);
		}

		public void RefreshOutRedDot(bool priseReward, bool passReward)
		{
			this.IsHadOutRedDot = true;
		}

		public void OnGetFirstPassInfo(FirstPassInfoReqRes oRes)
		{
			bool flag = oRes.error > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.error, "fece00");
			}
			else
			{
				for (int i = 0; i < oRes.stageInfos.Count; i++)
				{
					this.RefreshFirstPassData(oRes.stageInfos[i]);
				}
				bool flag2 = this.View != null && this.View.IsVisible();
				if (flag2)
				{
					this.View.RefreshUI();
				}
			}
		}

		public void OnGetFirstPassTopRoleInfo(FirstPassGetTopRoleInfoRes oRes)
		{
			bool flag = oRes.error > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.error, "fece00");
			}
			else
			{
				bool flag2 = this.CurData != null;
				if (flag2)
				{
					this.CurData.SetTeamInfoListData(oRes.infos);
					this.CurData.PriseTotalNum = (uint)oRes.commendNum;
					this.CurData.SetPassTime((uint)oRes.time);
					bool flag3 = this.CurData.FirstPassRow.NestType > 0u;
					if (flag3)
					{
						this.CurData.SetStar(oRes.starLevel);
					}
				}
				bool flag4 = this.View != null && this.View.IsVisible();
				if (flag4)
				{
					bool flag5 = this.View.TeamInfoHandler != null && this.View.TeamInfoHandler.IsVisible();
					if (flag5)
					{
						this.View.TeamInfoHandler.FillAvata();
					}
				}
			}
		}

		public void OnGetFirstPassReward(GetFirstPassRewardRes oRes)
		{
			bool flag = oRes.error > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.error, "fece00");
			}
			else
			{
				bool flag2 = this.CurData != null;
				if (flag2)
				{
					this.CurData.IsGetedReward = true;
				}
				this.SetOutRedDotStatue();
				bool flag3 = this.View != null && this.View.IsVisible();
				if (flag3)
				{
					this.View.RefreshUI();
				}
			}
		}

		public void OnGetCommendFirstPass(CommendFirstPassRes oRes)
		{
			bool flag = oRes.error > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.error, "fece00");
			}
			else
			{
				bool flag2 = this.CurData != null;
				if (flag2)
				{
					this.CurData.IsGivedPrise = true;
				}
				bool flag3 = this.CurData != null;
				if (flag3)
				{
					this.CurData.PriseTotalNum = (uint)oRes.commendNum;
				}
				this.SetOutRedDotStatue();
				bool flag4 = this.View != null && this.View.IsVisible();
				if (flag4)
				{
					bool flag5 = this.View.TeamInfoHandler != null && this.View.TeamInfoHandler.IsVisible();
					if (flag5)
					{
						this.View.TeamInfoHandler.RefreshUI();
					}
				}
			}
		}

		public void OnGetRankList(ClientQueryRankListRes oRes)
		{
			bool flag = oRes.ErrorCode > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.ErrorCode, "fece00");
			}
			else
			{
				this.m_rankList = new FirstPassRankList(oRes, true);
				bool flag2 = DlgBase<FirstPassRankView, FitstpassRankBehaviour>.singleton.IsVisible();
				if (flag2)
				{
					DlgBase<FirstPassRankView, FitstpassRankBehaviour>.singleton.FillContent();
				}
			}
		}

		private void SetOutRedDotStatue()
		{
			bool flag = false;
			for (int i = 0; i < this.FirstPassData.Count; i++)
			{
				flag |= this.FirstPassData[i].IsCanPrise;
				flag |= this.FirstPassData[i].IsHadReward;
			}
			this.IsHadOutRedDot = flag;
		}

		private void RefreshFirstPassData(FirstPassStageInfo2Client info)
		{
			bool flag = info == null;
			if (!flag)
			{
				for (int i = 0; i < this.FirstPassData.Count; i++)
				{
					bool flag2 = this.FirstPassData[i].Id == info.firstPassID;
					if (flag2)
					{
						this.FirstPassData[i].CurRank = info.myRank;
						this.FirstPassData[i].IsGivedPrise = info.hasCommended;
						this.FirstPassData[i].IsGetedReward = info.isGetReward;
						this.FirstPassData[i].PassTeamCount = info.totalRank;
						break;
					}
				}
			}
		}
	}
}