summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XShowGetAchivementTipDocument.cs
blob: 3d14f4807a2bf9cdba2000e10dc1915f72d2f154 (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
using System;
using System.Collections.Generic;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

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

		private Queue<AchivementTable.RowData> AchivementQueue = new Queue<AchivementTable.RowData>();

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

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

		public override void OnEnterSceneFinally()
		{
			base.OnEnterSceneFinally();
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.queue.Count > 0;
			if (flag)
			{
				DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.ShowUI();
			}
		}

		public override void OnLeaveScene()
		{
			base.OnLeaveScene();
			bool flag = DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.SetVisible(false, true);
			}
		}

		public void AddAchivement(uint AchivementID, uint state)
		{
			bool flag = state != 1u;
			if (!flag)
			{
				AchivementTable.RowData achivementData = XDocuments.GetSpecificDocument<XAchievementDocument>(XAchievementDocument.uuID).GetAchivementData(AchivementID);
				bool flag2 = achivementData == null;
				if (!flag2)
				{
					bool flag3 = achivementData.ShowAchivementTip == 0;
					if (!flag3)
					{
						this.AchivementQueue.Enqueue(achivementData);
						this.CheckScene();
					}
				}
			}
		}

		public void ShowAchivementTip(object o = null)
		{
			bool flag = this.AchivementQueue.Count > 0 && !DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.IsVisible();
			if (flag)
			{
				bool flag2 = DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.IsVisible();
				if (flag2)
				{
					DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.SetAlpha(1f);
				}
				DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.SetVisible(true, true);
				DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.ShowTip(this.AchivementQueue.Dequeue());
			}
		}

		private void CheckScene()
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall && !DlgBase<XShowGetAchivementTipView, XShowGetAchivementTipBehaviour>.singleton.IsVisible();
			if (flag)
			{
				this.ShowAchivementTip(null);
			}
		}

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