summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/TowerInfo.cs
blob: 1d6e2265bc946d32099f1abc9236983f22005a08 (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
using System;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class TowerInfo
	{
		public ulong UID;

		public float WarningSqrRadius;

		public ulong TargetUID;

		public XFx Fx;

		public XEntity Entity;

		public XTargetState TargetState;

		public XFxType FxType;

		public bool bInRange;

		public TowerInfo()
		{
			this.Init();
		}

		public void Init()
		{
			this.UID = 0UL;
			this.WarningSqrRadius = 0f;
			this.TargetUID = 0UL;
			this.Fx = null;
			this.Entity = null;
			this.TargetState = XTargetState.TS_NONE;
			this.FxType = XFxType.FT_NONE;
			this.bInRange = false;
		}

		public void Destroy()
		{
			this._DestroyFx();
		}

		private void _DestroyFx()
		{
			bool flag = this.Fx != null;
			if (flag)
			{
				XSingleton<XFxMgr>.singleton.DestroyFx(this.Fx, true);
				this.Fx = null;
			}
		}

		private void _SetDistanceType(float sqrDis)
		{
			this.bInRange = (sqrDis <= this.WarningSqrRadius);
		}

		private void _SetTargetType(ulong playerUID)
		{
			bool flag = this.TargetUID == 0UL;
			if (flag)
			{
				this.TargetState = XTargetState.TS_NONE;
			}
			else
			{
				bool flag2 = this.TargetUID == playerUID;
				if (flag2)
				{
					this.TargetState = XTargetState.TS_ME;
				}
				else
				{
					this.TargetState = XTargetState.TS_OTHER;
				}
			}
		}

		private void _SetFx(XFxType newFxType, Vector3 pos)
		{
			bool flag = newFxType == this.FxType;
			if (!flag)
			{
				this.FxType = newFxType;
				this._DestroyFx();
				bool flag2 = this.FxType == XFxType.FT_NONE;
				if (!flag2)
				{
					bool flag3 = XEntity.FilterFx(pos, XFxMgr.FilterFxDis1);
					if (!flag3)
					{
						switch (this.FxType)
						{
						case XFxType.FT_WARNING:
							this.Fx = XSingleton<XFxMgr>.singleton.CreateFx(XSingleton<XGlobalConfig>.singleton.GetValue("MobaTowerFxWarning"), null, true);
							break;
						case XFxType.FT_OTHER:
							this.Fx = XSingleton<XFxMgr>.singleton.CreateFx(XSingleton<XGlobalConfig>.singleton.GetValue("MobaTowerFxOther"), null, true);
							break;
						case XFxType.FT_ME:
							this.Fx = XSingleton<XFxMgr>.singleton.CreateFx(XSingleton<XGlobalConfig>.singleton.GetValue("MobaTowerFxMe"), null, true);
							break;
						}
						bool flag4 = this.Fx != null;
						if (flag4)
						{
							this.Fx.Play(pos, Quaternion.identity, Vector3.one, 1f);
						}
					}
				}
			}
		}

		private XFxType _GetFxType()
		{
			bool flag = !this.bInRange;
			XFxType result;
			if (flag)
			{
				result = XFxType.FT_NONE;
			}
			else
			{
				switch (this.TargetState)
				{
				case XTargetState.TS_NONE:
					result = XFxType.FT_WARNING;
					break;
				case XTargetState.TS_ME:
					result = XFxType.FT_ME;
					break;
				case XTargetState.TS_OTHER:
					result = XFxType.FT_OTHER;
					break;
				default:
					result = XFxType.FT_NONE;
					break;
				}
			}
			return result;
		}

		public void Update()
		{
			bool flag = XSingleton<XEntityMgr>.singleton.Player == null;
			if (!flag)
			{
				bool flag2 = !XEntity.ValideEntity(this.Entity);
				if (!flag2)
				{
					Vector3 position = this.Entity.MoveObj.Position;
					Vector3 position2 = XSingleton<XEntityMgr>.singleton.Player.MoveObj.Position;
					float sqrMagnitude = (position - position2).sqrMagnitude;
					this._SetDistanceType(sqrMagnitude);
					this._SetTargetType(XSingleton<XEntityMgr>.singleton.Player.ID);
					XFxType newFxType = this._GetFxType();
					this._SetFx(newFxType, position);
				}
			}
		}
	}
}