summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XShowGetItemDocument.cs
blob: 2cb315a52b10cce341c674f2ffa3c8e168ec6da4 (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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

		public bool bBlock
		{
			get
			{
				return this.m_bBlock;
			}
			set
			{
				this.m_bBlock = value;
				bool flag = !this.m_bBlock;
				if (flag)
				{
					this.CheckScene();
				}
				else
				{
					XSingleton<XTimerMgr>.singleton.KillTimer(this.ShowItemToken);
					this.ShowItemToken = 0u;
				}
			}
		}

		public bool bIgonre
		{
			get
			{
				return this.m_bIgnore;
			}
			set
			{
				this.m_bIgnore = value;
			}
		}

		public bool IsForbidGetItemUI
		{
			get
			{
				bool flag = XSuperRiskDocument.Doc.GameViewHandler != null;
				return flag && XSuperRiskDocument.Doc.GameViewHandler.IsVisible();
			}
		}

		public bool IsForbidByLua
		{
			get
			{
				return this._ForbidByLua;
			}
			set
			{
				XSingleton<XDebug>.singleton.AddErrorLog("set fordie lua  " + value.ToString(), null, null, null, null, null);
				this._ForbidByLua = value;
			}
		}

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

		public Queue<XItem> ItemQueue = new Queue<XItem>();

		public static Queue<List<XItem>> ItemUIQueue = new Queue<List<XItem>>();

		public List<ItemBrief> ItemFlashList = new List<ItemBrief>();

		private Queue<StringTip> StringQueue = new Queue<StringTip>();

		private uint StringQueueID;

		private bool QueueIsFull = false;

		private int ExceedCount = 0;

		private uint ShowItemToken;

		private bool _ForbidByLua = false;

		private bool m_bBlock;

		private bool m_bIgnore;

		private bool m_bDirty = false;

		private List<XItem> m_ItemList = null;

		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this.ItemQueue.Clear();
			this.StringQueue.Clear();
			this.StringQueueID = 0u;
			this.ItemFlashList.Clear();
		}

		protected override void EventSubscribe()
		{
			base.EventSubscribe();
			base.RegisterEvent(XEventDefine.XEvent_AddItem, new XComponent.XEventHandler(this.OnAddItem));
			base.RegisterEvent(XEventDefine.XEvent_VirtualItemChanged, new XComponent.XEventHandler(this.OnAddVirtualItem));
			base.RegisterEvent(XEventDefine.XEvent_ItemNumChanged, new XComponent.XEventHandler(this.OnNumChange));
			base.RegisterEvent(XEventDefine.XEvent_ItemChangeFinished, new XComponent.XEventHandler(this.OnChangeFinished));
		}

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

		public override void OnEnterSceneFinally()
		{
			base.OnEnterSceneFinally();
			this.m_bBlock = false;
			this.m_bIgnore = false;
			this.CheckScene();
		}

		public override void OnLeaveScene()
		{
			base.OnLeaveScene();
			XSingleton<XTimerMgr>.singleton.KillTimer(this.ShowItemToken);
			this.ShowItemToken = 0u;
			bool flag = DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetVisible(false, true);
			}
		}

		private bool CampareItems(XEventArgs args)
		{
			XAddItemEventArgs xaddItemEventArgs = args as XAddItemEventArgs;
			int i = 0;
			while (i < xaddItemEventArgs.items.Count)
			{
				ItemList.RowData itemConf = XBagDocument.GetItemConf(xaddItemEventArgs.items[i].itemID);
				bool flag = itemConf != null;
				if (flag)
				{
					bool flag2 = !XBagDocument.ItemCanShowTips((uint)xaddItemEventArgs.items[i].itemID);
					if (!flag2)
					{
						bool flag3 = xaddItemEventArgs.items[i].itemCount >= itemConf.OverCnt;
						if (flag3)
						{
							return true;
						}
					}
				}
				IL_77:
				i++;
				continue;
				goto IL_77;
			}
			return false;
		}

		private bool DealwithFlashItems(XAddItemEventArgs arg)
		{
			bool flag = false;
			XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
			for (int i = 0; i < arg.items.Count; i++)
			{
				bool flag2 = specificDocument.IsGiftBagItem(arg.items[i].itemID);
				if (flag2)
				{
					flag = true;
					break;
				}
			}
			bool flag3 = flag;
			if (flag3)
			{
				int j = 0;
				while (j < arg.items.Count)
				{
					bool flag4 = XBagDocument.GetItemConf(arg.items[j].itemID) != null;
					if (flag4)
					{
						bool flag5 = !XBagDocument.ItemCanShowTips((uint)arg.items[j].itemID);
						if (!flag5)
						{
							ItemBrief itemBrief = new ItemBrief();
							itemBrief.itemID = (uint)arg.items[j].itemID;
							itemBrief.itemCount = (uint)arg.items[j].itemCount;
							this.ItemFlashList.Add(itemBrief);
						}
					}
					IL_EE:
					j++;
					continue;
					goto IL_EE;
				}
			}
			return flag;
		}

		protected bool OnAddItem(XEventArgs args)
		{
			bool bIgnore = this.m_bIgnore;
			bool result;
			if (bIgnore)
			{
				result = false;
			}
			else
			{
				XAddItemEventArgs xaddItemEventArgs = args as XAddItemEventArgs;
				bool flag = !xaddItemEventArgs.bNew;
				if (flag)
				{
					result = true;
				}
				else
				{
					bool flag2 = this.DealwithFlashItems(xaddItemEventArgs);
					if (flag2)
					{
						this.m_bDirty = true;
						result = true;
					}
					else
					{
						bool flag3 = !this.CampareItems(args);
						if (flag3)
						{
							int i = 0;
							while (i < xaddItemEventArgs.items.Count)
							{
								bool flag4 = XBagDocument.GetItemConf(xaddItemEventArgs.items[i].itemID) != null;
								if (flag4)
								{
									bool flag5 = !XBagDocument.ItemCanShowTips((uint)xaddItemEventArgs.items[i].itemID);
									if (!flag5)
									{
										bool flag6 = !this.QueueIsFull;
										if (flag6)
										{
											XItem item = new XNormalItem
											{
												itemID = xaddItemEventArgs.items[i].itemID,
												itemCount = xaddItemEventArgs.items[i].itemCount
											};
											this.ItemQueue.Enqueue(item);
											bool flag7 = this.ItemQueue.Count >= 10;
											if (flag7)
											{
												this.QueueIsFull = true;
											}
										}
										else
										{
											this.ExceedCount++;
										}
									}
								}
								IL_138:
								i++;
								continue;
								goto IL_138;
							}
						}
						else
						{
							bool flag8 = this.m_ItemList == null;
							if (flag8)
							{
								this.m_ItemList = new List<XItem>();
							}
							for (int j = 0; j < xaddItemEventArgs.items.Count; j++)
							{
								bool flag9 = !XBagDocument.ItemCanShowTips((uint)xaddItemEventArgs.items[j].itemID);
								if (!flag9)
								{
									XItem item2 = new XNormalItem
									{
										itemID = xaddItemEventArgs.items[j].itemID,
										itemCount = xaddItemEventArgs.items[j].itemCount
									};
									this.m_ItemList.Add(item2);
								}
							}
						}
						this.m_bDirty = true;
						result = true;
					}
				}
			}
			return result;
		}

		public void ClearItemQueue()
		{
			this.ItemQueue.Clear();
			XShowGetItemDocument.ItemUIQueue.Clear();
			this.StringQueue.Clear();
			this.QueueIsFull = false;
			DlgBase<XShowGetItemUIView, XShowGetItemUIBehaviour>.singleton.isPlaying = false;
		}

		protected bool OnAddVirtualItem(XEventArgs args)
		{
			bool bIgnore = this.m_bIgnore;
			bool result;
			if (bIgnore)
			{
				result = false;
			}
			else
			{
				XVirtualItemChangedEventArgs xvirtualItemChangedEventArgs = args as XVirtualItemChangedEventArgs;
				bool flag = !XBagDocument.ItemCanShowTips((uint)xvirtualItemChangedEventArgs.itemID);
				if (flag)
				{
					result = true;
				}
				else
				{
					XItem xitem = new XNormalItem();
					xitem.itemID = xvirtualItemChangedEventArgs.itemID;
					bool flag2 = xvirtualItemChangedEventArgs.itemID != 4;
					if (flag2)
					{
						xitem.itemCount = (int)(xvirtualItemChangedEventArgs.newValue - xvirtualItemChangedEventArgs.oldValue);
					}
					else
					{
						xitem.itemCount = (int)xvirtualItemChangedEventArgs.newValue;
					}
					bool flag3 = xitem.itemCount <= 0;
					if (flag3)
					{
						result = true;
					}
					else
					{
						ItemList.RowData itemConf = XBagDocument.GetItemConf(xitem.itemID);
						bool flag4 = xitem.itemCount < itemConf.OverCnt;
						if (flag4)
						{
							bool flag5 = XBagDocument.GetItemConf(xitem.itemID) != null;
							if (flag5)
							{
								bool flag6 = !this.QueueIsFull;
								if (flag6)
								{
									this.ItemQueue.Enqueue(xitem);
									bool flag7 = this.ItemQueue.Count >= 10;
									if (flag7)
									{
										this.QueueIsFull = true;
									}
								}
								else
								{
									this.ExceedCount++;
								}
							}
						}
						else
						{
							bool flag8 = this.m_ItemList == null;
							if (flag8)
							{
								this.m_ItemList = new List<XItem>();
							}
							this.m_ItemList.Add(xitem);
						}
						this.m_bDirty = true;
						result = true;
					}
				}
			}
			return result;
		}

		protected bool OnNumChange(XEventArgs args)
		{
			bool bIgnore = this.m_bIgnore;
			bool result;
			if (bIgnore)
			{
				result = false;
			}
			else
			{
				XItemNumChangedEventArgs xitemNumChangedEventArgs = args as XItemNumChangedEventArgs;
				bool flag = !XBagDocument.ItemCanShowTips((uint)xitemNumChangedEventArgs.item.itemID);
				if (flag)
				{
					result = true;
				}
				else
				{
					bool flag2 = xitemNumChangedEventArgs.item.itemCount <= xitemNumChangedEventArgs.oldCount;
					if (flag2)
					{
						result = true;
					}
					else
					{
						bool flag3 = !xitemNumChangedEventArgs.bNew;
						if (flag3)
						{
							result = true;
						}
						else
						{
							XItem xitem = new XNormalItem();
							xitem.itemID = xitemNumChangedEventArgs.item.itemID;
							xitem.itemCount = xitemNumChangedEventArgs.item.itemCount - xitemNumChangedEventArgs.oldCount;
							ItemList.RowData itemConf = XBagDocument.GetItemConf(xitem.itemID);
							bool flag4 = xitem.itemCount < itemConf.OverCnt;
							if (flag4)
							{
								bool flag5 = XBagDocument.GetItemConf(xitem.itemID) != null;
								if (flag5)
								{
									bool flag6 = !this.QueueIsFull;
									if (flag6)
									{
										this.ItemQueue.Enqueue(xitem);
										bool flag7 = this.ItemQueue.Count >= 10;
										if (flag7)
										{
											this.QueueIsFull = true;
										}
									}
									else
									{
										this.ExceedCount++;
									}
								}
							}
							else
							{
								bool flag8 = this.m_ItemList == null;
								if (flag8)
								{
									this.m_ItemList = new List<XItem>();
								}
								this.m_ItemList.Add(xitem);
							}
							this.m_bDirty = true;
							result = true;
						}
					}
				}
			}
			return result;
		}

		protected bool OnChangeFinished(XEventArgs args)
		{
			bool bDirty = this.m_bDirty;
			if (bDirty)
			{
				bool flag = this.m_ItemList != null && this.m_ItemList.Count > 0;
				if (flag)
				{
					bool flag2 = true;
					for (int i = 0; i < this.m_ItemList.Count; i++)
					{
						bool flag3 = XBagDocument.GetItemConf(this.m_ItemList[i].itemID) == null;
						if (flag3)
						{
							flag2 = false;
							break;
						}
					}
					bool flag4 = flag2;
					if (flag4)
					{
						XShowGetItemDocument.ItemUIQueue.Enqueue(this.m_ItemList);
					}
					this.m_ItemList = null;
				}
				this.CheckScene();
				this.m_bDirty = false;
			}
			return true;
		}

		private void CheckScene()
		{
			bool bBlock = this.m_bBlock;
			if (!bBlock)
			{
				bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && this.ItemQueue.Count > 0 && this.ShowItemToken == 0u;
				if (flag)
				{
					DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetVisible(true, true);
					this.ShowItemToken = XSingleton<XTimerMgr>.singleton.SetTimer(0.4f, new XTimerMgr.ElapsedEventHandler(this.CheckQueueItem), null);
				}
				bool flag2 = this.StringQueue.Count > 0 && this.ShowItemToken == 0u;
				if (flag2)
				{
					DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetVisible(true, true);
					this.ShowItemToken = XSingleton<XTimerMgr>.singleton.SetTimer(0.4f, new XTimerMgr.ElapsedEventHandler(this.CheckQueueItem), null);
				}
				this.CheckUIScene();
				this.CheckFlashItemScene();
			}
		}

		private void CheckUIScene(IXUITweenTool tween)
		{
			this.CheckUIScene();
		}

		private void CheckUIScene()
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				bool flag2 = XShowGetItemDocument.ItemUIQueue.Count > 0 && !DlgBase<XShowGetItemUIView, XShowGetItemUIBehaviour>.singleton.isPlaying;
				if (flag2)
				{
					List<XItem> list = XShowGetItemDocument.ItemUIQueue.Peek();
					bool flag3 = list != null && list.Count > 0;
					if (flag3)
					{
						DlgBase<XShowGetItemUIView, XShowGetItemUIBehaviour>.singleton.ShowItems(list, new OnTweenFinishEventHandler(this.CheckUIScene));
					}
					else
					{
						XSingleton<XDebug>.singleton.AddErrorLog("list is null", null, null, null, null, null);
					}
					bool flag4 = XShowGetItemDocument.ItemUIQueue.Count > 0;
					if (flag4)
					{
						XShowGetItemDocument.ItemUIQueue.Dequeue();
					}
				}
			}
		}

		private void CheckFlashItemScene()
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				bool flag2 = this.ItemFlashList.Count > 0 && !DlgBase<RewdAnimDlg, RewdAnimBehaviour>.singleton.IsVisible();
				if (flag2)
				{
					bool inTutorial = XSingleton<XTutorialMgr>.singleton.InTutorial;
					if (inTutorial)
					{
						List<XItem> list = new List<XItem>();
						for (int i = 0; i < this.ItemFlashList.Count; i++)
						{
							list.Add(new XNormalItem
							{
								itemID = (int)this.ItemFlashList[i].itemID,
								itemCount = (int)this.ItemFlashList[i].itemCount
							});
						}
						XShowGetItemDocument.ItemUIQueue.Enqueue(list);
						this.ItemFlashList.Clear();
						this.CheckUIScene();
					}
					else
					{
						DlgBase<RewdAnimDlg, RewdAnimBehaviour>.singleton.Show(this.ItemFlashList, new Action(this.CheckFlashItemScene));
						this.ItemFlashList.Clear();
					}
				}
			}
		}

		public void CheckQueueItem(object o = null)
		{
			bool flag = this.ItemQueue.Count != 0 && XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				bool flag2 = !this.m_bBlock;
				if (flag2)
				{
					DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetAlpha(1f);
					DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.ShowItem(this.ItemQueue.Dequeue());
				}
			}
			else
			{
				bool flag3 = this.QueueIsFull && XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
				if (flag3)
				{
					this.QueueIsFull = false;
					bool flag4 = this.ExceedCount > 0;
					if (flag4)
					{
						bool flag5 = DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.IsVisible();
						if (flag5)
						{
							DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetAlpha(1f);
						}
						DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.ShowFullTip(this.ExceedCount);
					}
					this.ExceedCount = 0;
				}
				else
				{
					bool flag6 = this.StringQueue.Count != 0;
					if (flag6)
					{
						DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.SetAlpha(1f);
						StringTip stringTip = this.StringQueue.Dequeue();
						DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.ShowString(stringTip.str, stringTip.id);
					}
				}
			}
			XSingleton<XTimerMgr>.singleton.KillTimer(this.ShowItemToken);
			this.ShowItemToken = 0u;
			bool flag7 = !this.m_bBlock && DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.IsVisible();
			if (flag7)
			{
				this.ShowItemToken = XSingleton<XTimerMgr>.singleton.SetTimer(0.4f, new XTimerMgr.ElapsedEventHandler(this.CheckQueueItem), null);
			}
		}

		public uint AddTip(string str)
		{
			this.StringQueueID += 1u;
			StringTip item = default(StringTip);
			item.str = str;
			item.id = this.StringQueueID;
			this.StringQueue.Enqueue(item);
			this.CheckScene();
			return this.StringQueueID;
		}

		public void EditTip(string str, uint id)
		{
			bool flag = !DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<XShowGetItemView, XShowGetItemBehaviour>.singleton.EditString(str, id);
			}
		}

		public void StopShowItem()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.ShowItemToken);
			this.ShowItemToken = 0u;
		}

		public void SetForbidByLua(bool bFlag)
		{
			this._ForbidByLua = bFlag;
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}