From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/ParabolaFx.cs | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/ParabolaFx.cs (limited to 'Client/Assets/Scripts/XMainClient/ParabolaFx.cs') 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.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.singleton.DestroyFx(this._fx, true); + } + } +} -- cgit v1.1-26-g67d0