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

namespace XMainClient
{
	internal class ParabolaFx
	{
		private Vector3 _startPos;

		private Vector3 _endPos;

		private float _speedY;

		private float _speedAddY;

		private float _duration;

		private float _startTime;

		private XFx _fx;

		public ParabolaFx(string fxPath, float duration, float speedY, Vector3 startPos, Vector3 endPos)
		{
			this._fx = XSingleton<XFxMgr>.singleton.CreateFx(fxPath, null, true);
			this._fx.Play(startPos, Quaternion.identity, Vector3.one, 1f);
			this._duration = duration;
			this._startTime = Time.time;
			this._startPos = startPos;
			this._endPos = endPos;
			this._speedY = speedY;
			this._speedAddY = -speedY * 2f / duration;
		}

		public bool Update()
		{
			float num = Time.time - this._startTime;
			bool flag = num > this._duration;
			bool result;
			if (flag)
			{
				this.Destroy();
				result = false;
			}
			else
			{
				Vector3 position = Vector3.Lerp(this._startPos, this._endPos, num / this._duration);
				position.y = this._startPos.y + this._speedY * num + this._speedAddY * num * num / 2f;
				this._fx.Position = position;
				result = true;
			}
			return result;
		}

		public void Destroy()
		{
			XSingleton<XFxMgr>.singleton.DestroyFx(this._fx, true);
		}
	}
}