summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Tutorial/Command/XCommandNote.cs
blob: cc9a2c95ad1cea46f6d3fab738a4698fe660d442 (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
using System;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient.Tutorial.Command
{
	internal class XCommandNote : XBaseCommand
	{
		private GameObject _finger;

		private int orgWidth;

		private int orgHeight;

		private GameObject _cloneGo;

		private GameObject _clickGo;

		private uint _time = 0u;

		public override bool Execute()
		{
			Transform transform = XSingleton<XGameUI>.singleton.UIRoot.Find(this._cmd.param1 + "(Clone)");
			bool flag = !transform || !transform.gameObject.activeInHierarchy;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				Transform transform2 = XSingleton<UiUtility>.singleton.FindChild(transform, this._cmd.param2);
				bool flag2 = transform2 == null || !transform2.gameObject.activeInHierarchy;
				if (flag2)
				{
					bool flag3 = transform2 == null && this._cmd.isOutError;
					if (flag3)
					{
						this._cmd.isOutError = false;
						XSingleton<XDebug>.singleton.AddErrorLog(string.Concat(new object[]
						{
							"TutorialId:",
							this._cmd.TutorialID,
							" Configuration File Path Error! tag:",
							this._cmd.tag,
							"\nPath:",
							this._cmd.param1,
							"(Clone)/",
							this._cmd.param2
						}), null, null, null, null, null);
					}
					result = false;
				}
				else
				{
					this._startTime = Time.time;
					this._clickGo = transform2.gameObject;
					bool flag4 = this._cmd.interalDelay > 0f;
					if (flag4)
					{
						base.SetOverlay();
					}
					this._time = XSingleton<XTimerMgr>.singleton.SetTimer(this._cmd.interalDelay, new XTimerMgr.ElapsedEventHandler(this.ShowFinger), null);
					base.publicModule();
					result = true;
				}
			}
			return result;
		}

		protected void ShowFinger(object o)
		{
			bool flag = this._finger == null;
			if (flag)
			{
				this._finger = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/TutorialK", true, false) as GameObject);
			}
			this._finger.SetActive(false);
			string param = this._cmd.param3;
			string[] array = param.Split(XGlobalConfig.AllSeparators);
			float num = float.Parse(array[0]);
			float num2 = (array.Length > 1) ? float.Parse(array[1]) : num;
			float num3 = (array.Length > 2) ? float.Parse(array[2]) : 0f;
			float num4 = (array.Length > 3) ? float.Parse(array[3]) : 0f;
			bool flag2 = num > 0f;
			if (flag2)
			{
				IXUISprite ixuisprite = this._finger.transform.Find("Quan").GetComponent("XUISprite") as IXUISprite;
				this.orgWidth = ixuisprite.spriteWidth;
				this.orgHeight = ixuisprite.spriteHeight;
				ixuisprite.spriteWidth = (int)((float)ixuisprite.spriteWidth * num);
				ixuisprite.spriteHeight = (int)((float)ixuisprite.spriteHeight * num2);
				ixuisprite.gameObject.transform.localPosition = new Vector3(num3, num4, 0f);
			}
			base.SetOverlay();
			this._cloneGo = XCommon.Instantiate<GameObject>(this._clickGo);
			this.SetupCloneButton(this._clickGo, this._cloneGo);
			base.SetTutorialText(this._cmd.textPos, this._cloneGo.transform);
			this._finger.SetActive(false);
			this._finger.SetActive(true);
			base.SetAilin();
			bool pause = this._cmd.pause;
			if (pause)
			{
				XSingleton<XShell>.singleton.Pause = true;
			}
		}

		public override void Update()
		{
			base.Update();
			bool flag = this._cloneGo != null && this._clickGo != null;
			if (flag)
			{
				Vector3 position = this._clickGo.transform.position;
				Vector3 localPosition = XBaseCommand._Overlay.transform.InverseTransformPoint(position);
				localPosition.z = 0f;
				this._cloneGo.transform.localPosition = localPosition;
			}
		}

		protected void SetupCloneButton(GameObject targetGo, GameObject cloneGo)
		{
			XSingleton<UiUtility>.singleton.AddChild(cloneGo.transform, this._finger.transform);
			cloneGo.name = targetGo.name;
			cloneGo.transform.parent = XBaseCommand._Overlay.transform;
			Vector3 position = targetGo.transform.position;
			Vector3 localPosition = XBaseCommand._Overlay.transform.InverseTransformPoint(position);
			localPosition.z = 0f;
			cloneGo.transform.localPosition = localPosition;
			cloneGo.transform.localScale = targetGo.transform.localScale;
		}

		public override void Stop()
		{
			bool flag = this._time > 0u;
			if (flag)
			{
				XSingleton<XTimerMgr>.singleton.KillTimer(this._time);
				this._time = 0u;
			}
			bool flag2 = this._finger != null;
			if (flag2)
			{
				IXUISprite ixuisprite = this._finger.transform.Find("Quan").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.spriteWidth = this.orgWidth;
				ixuisprite.spriteHeight = this.orgHeight;
				XResourceLoaderMgr.SafeDestroy(ref this._finger, false);
			}
			base.DestroyText();
			bool flag3 = this._cloneGo != null;
			if (flag3)
			{
				this._cloneGo.transform.parent = null;
				UnityEngine.Object.Destroy(this._cloneGo);
				this._cloneGo = null;
			}
			base.DestroyAilin();
			base.DestroyOverlay();
			XSingleton<XShell>.singleton.Pause = false;
			XSingleton<XTutorialMgr>.singleton.NoforceClick = false;
		}
	}
}