summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XCommandForceClick.cs
blob: 0a81c43970597363dc83b765cbcd1d1f64f9a87e (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
using System;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XCommandForceClick : XBaseCommand
	{
		private GameObject _finger;

		private GameObject _clickGo;

		private GameObject _cloneGo;

		private int orgWidth1;

		private int orgHeight1;

		private int orgWidth2;

		private int orgHeight2;

		private uint _time = 0u;

		public override bool Execute()
		{
			bool flag = this._cmd.param2 == "_canvas/SkillFrame/Skill1";
			if (flag)
			{
				bool flag2 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded();
				if (flag2)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.AlwaysHot(1, true);
				}
				XSingleton<XEntityMgr>.singleton.Player.Skill.EndSkill(true, false);
			}
			else
			{
				bool flag3 = this._cmd.param2 == "_canvas/SkillFrame/Skill3";
				if (flag3)
				{
					bool flag4 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded();
					if (flag4)
					{
						DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.AlwaysHot(3, true);
					}
					XSingleton<XEntityMgr>.singleton.Player.Skill.EndSkill(true, false);
				}
			}
			base.publicModule();
			return this._execute(this._cmd.param1, this._cmd.param2, true);
		}

		public override void Update()
		{
		}

		public override void OnFinish()
		{
			this._execute(this._cmd.param1, this._cmd.param2, false);
			bool flag = this._cmd.param2 == "_canvas/SkillFrame/Skill1" && XSingleton<XEntityMgr>.singleton.Player != null;
			if (flag)
			{
				Vector3 forward = XSingleton<XEntityMgr>.singleton.Player.EngineObject.Forward;
				bool flag2 = Vector3.Angle(forward, XSingleton<XEntityMgr>.singleton.Boss.EngineObject.Forward) > 135f;
				if (flag2)
				{
					XSingleton<XEntityMgr>.singleton.Player.Net.ReportRotateAction(XSingleton<XCommon>.singleton.HorizontalRotateVetor3(forward, (float)(XSingleton<XCommon>.singleton.Clockwise(forward, XSingleton<XEntityMgr>.singleton.Boss.EngineObject.Forward) ? 90 : -90), true));
				}
			}
			base.OnFinish();
		}

		protected bool _execute(string param1, string param2, bool bExculsive)
		{
			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._clickGo = transform2.gameObject;
					bool flag4 = this._cmd.interalDelay > 0f;
					if (flag4)
					{
						base.SetOverlay();
					}
					if (bExculsive)
					{
						this._time = XSingleton<XTimerMgr>.singleton.SetTimer(this._cmd.interalDelay, new XTimerMgr.ElapsedEventHandler(this.ShowFinger), null);
					}
					else
					{
						this.Stop();
					}
					result = true;
				}
			}
			return result;
		}

		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)
			{
				bool flag3 = this._cmd.param3 != null;
				if (flag3)
				{
					IXUISprite ixuisprite = this._finger.transform.Find("Quan1").GetComponent("XUISprite") as IXUISprite;
					ixuisprite.spriteWidth = this.orgWidth1;
					ixuisprite.spriteHeight = this.orgHeight1;
				}
				bool flag4 = this._cmd.param4 != null;
				if (flag4)
				{
					IXUISprite ixuisprite2 = this._finger.transform.Find("Quan2").GetComponent("XUISprite") as IXUISprite;
					ixuisprite2.spriteWidth = this.orgWidth2;
					ixuisprite2.spriteHeight = this.orgHeight2;
				}
				XResourceLoaderMgr.SafeDestroy(ref this._finger, false);
			}
			base.DestroyText();
			bool flag5 = this._cloneGo != null;
			if (flag5)
			{
				this._cloneGo.transform.parent = null;
				UnityEngine.Object.Destroy(this._cloneGo);
			}
			base.DestroyAilin();
			base.DestroyOverlay();
			bool flag6 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded();
			if (flag6)
			{
				bool flag7 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler != null;
				if (flag7)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.AlwaysHot(1, false);
				}
				bool flag8 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler != null;
				if (flag8)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.AlwaysHot(3, false);
				}
			}
			XSingleton<XShell>.singleton.Pause = false;
			XSingleton<XTutorialMgr>.singleton.Exculsive = false;
		}

		protected void ShowFinger(object o)
		{
			bool flag = this._finger == null;
			if (flag)
			{
				this._finger = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/Quan", true, false) as GameObject);
			}
			this._finger.SetActive(false);
			bool flag2 = this._cmd.param3 != null;
			if (flag2)
			{
				float num = float.Parse(this._cmd.param3);
				bool flag3 = num >= 0f;
				if (flag3)
				{
					IXUISprite ixuisprite = this._finger.transform.Find("Quan1").GetComponent("XUISprite") as IXUISprite;
					this.orgWidth1 = ixuisprite.spriteWidth;
					this.orgHeight1 = ixuisprite.spriteHeight;
					ixuisprite.spriteWidth = (int)((float)ixuisprite.spriteWidth * num);
					ixuisprite.spriteHeight = (int)((float)ixuisprite.spriteHeight * num);
				}
			}
			bool flag4 = this._cmd.param4 != null;
			if (flag4)
			{
				float num2 = float.Parse(this._cmd.param4);
				bool flag5 = num2 >= 0f;
				if (flag5)
				{
					IXUISprite ixuisprite2 = this._finger.transform.Find("Quan2").GetComponent("XUISprite") as IXUISprite;
					this.orgWidth2 = ixuisprite2.spriteWidth;
					this.orgHeight2 = ixuisprite2.spriteHeight;
					ixuisprite2.spriteWidth = (int)((float)ixuisprite2.spriteWidth * num2);
					ixuisprite2.spriteHeight = (int)((float)ixuisprite2.spriteHeight * num2);
				}
			}
			base.SetOverlay();
			this._cloneGo = XCommon.Instantiate<GameObject>(this._clickGo.gameObject);
			this.SetupCloneButton(this._clickGo.gameObject, this._cloneGo);
			base.SetTutorialText(this._cmd.textPos, this._cloneGo.transform);
			base.SetAilin();
			bool pause = this._cmd.pause;
			if (pause)
			{
				XSingleton<XShell>.singleton.Pause = true;
			}
			XSingleton<XTutorialMgr>.singleton.Exculsive = true;
		}

		protected void SetupCloneButton(GameObject targetGo, GameObject cloneGo)
		{
			XSingleton<UiUtility>.singleton.AddChild(cloneGo.transform, this._finger.transform);
			bool flag = this._cmd.param5 == null;
			if (flag)
			{
				this._cmd.param5 = "0";
			}
			bool flag2 = this._cmd.param6 == null;
			if (flag2)
			{
				this._cmd.param6 = "0";
			}
			this._finger.transform.localPosition += new Vector3(float.Parse(this._cmd.param5), float.Parse(this._cmd.param6), 0f);
			cloneGo.name = targetGo.name;
			IXUIObject ixuiobject = cloneGo.GetComponent("XUIObject") as IXUIObject;
			bool flag3 = ixuiobject == null;
			if (flag3)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("XUIObject No Find", null, null, null, null, null);
			}
			ixuiobject.Exculsive = true;
			cloneGo.transform.parent = XBaseCommand._Overlay.transform;
			XSingleton<XGameUI>.singleton.m_uiTool.MarkParentAsChanged(cloneGo);
			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;
			IXUICheckBox ixuicheckBox = targetGo.GetComponent("XUICheckBox") as IXUICheckBox;
			bool flag4 = ixuicheckBox != null;
			if (flag4)
			{
				IXUICheckBox ixuicheckBox2 = cloneGo.GetComponent("XUICheckBox") as IXUICheckBox;
				ixuicheckBox2.ID = ixuicheckBox.ID;
				ixuicheckBox2.ForceSetFlag(false);
				ixuicheckBox2.RegisterOnCheckEventHandler(ixuicheckBox.GetCheckEventHandler());
			}
			IXUIButton ixuibutton = targetGo.GetComponent("XUIButton") as IXUIButton;
			bool flag5 = ixuibutton != null;
			if (flag5)
			{
				IXUIButton ixuibutton2 = cloneGo.GetComponent("XUIButton") as IXUIButton;
				ixuibutton2.ID = ixuibutton.ID;
				ixuibutton2.RegisterClickEventHandler(ixuibutton.GetClickEventHandler());
				ixuibutton2.RegisterPressEventHandler(ixuibutton.GetPressEventHandler());
				ixuibutton2.SetClickCD(2f);
				ixuibutton2.CloseScrollView();
				this._finger.SetActive(true);
			}
			else
			{
				IXUISprite ixuisprite = targetGo.GetComponent("XUISprite") as IXUISprite;
				bool flag6 = ixuisprite != null;
				if (flag6)
				{
					IXUISprite ixuisprite2 = cloneGo.GetComponent("XUISprite") as IXUISprite;
					ixuisprite2.ID = ixuisprite.ID;
					ixuisprite2.RegisterSpriteClickEventHandler(ixuisprite.GetSpriteClickHandler());
					ixuisprite2.RegisterSpritePressEventHandler(ixuisprite.GetSpritePressHandler());
					ixuisprite2.SetClickCD(2f);
					ixuisprite2.CloseScrollView();
					this._finger.SetActive(true);
				}
				else
				{
					IXUITexture ixuitexture = targetGo.GetComponent("XUITexture") as IXUITexture;
					bool flag7 = ixuitexture != null;
					if (flag7)
					{
						IXUITexture ixuitexture2 = cloneGo.GetComponent("XUITexture") as IXUITexture;
						ixuitexture2.ID = ixuitexture.ID;
						ixuitexture2.RegisterLabelClickEventHandler(ixuitexture.GetTextureClickHandler());
						ixuitexture2.SetClickCD(2f);
						ixuitexture2.CloseScrollView();
						this._finger.SetActive(true);
					}
				}
			}
		}
	}
}