diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/ParabolaFx.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/ParabolaFx.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/ParabolaFx.cs b/Client/Assets/Scripts/XMainClient/ParabolaFx.cs new file mode 100644 index 00000000..afb74a1f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ParabolaFx.cs @@ -0,0 +1,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);
+ }
+ }
+}
|