summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/BattleTargetHandler.cs
blob: 2ed6e6abd28dcf89a7949033f81f3dff42dcf2f2 (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
using System;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class BattleTargetHandler : DlgHandlerBase
	{
		public GameObject TargetFx;

		public GameObject PretargetFx;

		protected override void Init()
		{
			base.Init();
			this.TargetFx = base.PanelObject.transform.Find("Taget2").gameObject;
			this.PretargetFx = base.PanelObject.transform.Find("Taget1").gameObject;
			this.TargetFx.transform.localPosition = XGameUI.Far_Far_Away;
			this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away;
		}

		public void ShowTargetFx(bool show, XEntity e)
		{
			bool flag = !show;
			if (flag)
			{
				this.TargetFx.transform.localPosition = XGameUI.Far_Far_Away;
			}
			bool flag2 = !XEntity.ValideEntity(e);
			if (!flag2)
			{
				XSingleton<XTutorialHelper>.singleton.HasTarget = true;
				this.TargetFx.transform.position = this.EntityOnUI(e);
				Vector3 localPosition = this.TargetFx.transform.localPosition;
				localPosition.x = (float)Mathf.FloorToInt(localPosition.x);
				localPosition.y = (float)Mathf.FloorToInt(localPosition.y);
				localPosition.z = 0f;
				this.TargetFx.transform.localPosition = localPosition;
			}
		}

		public void ShowPretargetFx(bool show, XEntity e)
		{
			bool flag = !show;
			if (flag)
			{
				this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away;
			}
			bool flag2 = !XEntity.ValideEntity(e);
			if (!flag2)
			{
				this.PretargetFx.transform.position = this.EntityOnUI(e);
				bool flag3 = this.PretargetFx.transform.position.z < 0f;
				if (flag3)
				{
					this.PretargetFx.transform.localPosition = XGameUI.Far_Far_Away;
				}
				else
				{
					Vector3 localPosition = this.PretargetFx.transform.localPosition;
					localPosition.x = (float)Mathf.FloorToInt(localPosition.x);
					localPosition.y = (float)Mathf.FloorToInt(localPosition.y);
					localPosition.z = 0f;
					this.PretargetFx.transform.localPosition = localPosition;
				}
			}
		}

		protected Vector3 EntityOnUI(XEntity e)
		{
			Vector3 vector = e.EngineObject.Position + new Vector3(0f, e.Height / 2f, 0f);
			Vector3 vector2 = XSingleton<XScene>.singleton.GameCamera.UnityCamera.WorldToViewportPoint(vector);
			return XSingleton<XGameUI>.singleton.UICamera.ViewportToWorldPoint(vector2);
		}
	}
}