diff --git a/Data/LeanTweenHelper.cs b/Data/LeanTweenHelper.cs index 76e58f9..17062b2 100644 --- a/Data/LeanTweenHelper.cs +++ b/Data/LeanTweenHelper.cs @@ -3,10 +3,12 @@ namespace TrombLoader.Data; +[Serializable] public class LeanTweenHelper:MonoBehaviour { public LeanTweenHelperType tweenType; - public Vector3 targetValue; + public Vector3 vector3Value; + public float floatValue; public float time; public LeanTweenType easeType = LeanTweenType.linear; public LeanTweenType loopType = LeanTweenType.clamp; @@ -14,29 +16,52 @@ public class LeanTweenHelper:MonoBehaviour public bool runOnStart = false; public LeanTweenHelper invokeOnComplete; - - private Action tweenAction; - - public void Start() + public Action tweenAction; + + + public void SetTweenType() { switch (tweenType) { case LeanTweenHelperType.MOVELOCAL: - tweenAction = () => LeanTween.moveLocal(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween()); + tweenAction = () => LeanTween.moveLocal(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); break; case LeanTweenHelperType.MOVEGLOBAL: - tweenAction = () => LeanTween.move(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween()); + tweenAction = () => LeanTween.move(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); break; case LeanTweenHelperType.ROTATELOCAL: - tweenAction = () => LeanTween.rotateLocal(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween()); + tweenAction = () => LeanTween.rotateLocal(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); break; case LeanTweenHelperType.ROTATEGLOBAL: - tweenAction = () => LeanTween.rotate(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween()); + tweenAction = () => LeanTween.rotate(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); break; case LeanTweenHelperType.SCALE: - tweenAction = () => LeanTween.scale(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween()); + tweenAction = () => LeanTween.scale(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVEX: + tweenAction = () => LeanTween.moveX(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVEY: + tweenAction = () => LeanTween.moveY(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVEZ: + tweenAction = () => LeanTween.moveZ(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVELOCALX: + tweenAction = () => LeanTween.moveLocalX(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVELOCALY: + tweenAction = () => LeanTween.moveLocalY(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); + break; + case LeanTweenHelperType.MOVELOCALZ: + tweenAction = () => LeanTween.moveLocalZ(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween()); break; } + } + + public void Start() + { + SetTweenType(); if (runOnStart) DoTween(); } @@ -45,13 +70,20 @@ public void DoTween() tweenAction.Invoke(); } + public enum LeanTweenHelperType { MOVELOCAL=0, MOVEGLOBAL=1, ROTATELOCAL=2, ROTATEGLOBAL=3, - SCALE =4 + MOVEX=4, + MOVEY=5, + MOVEZ=6, + MOVELOCALX=7, + MOVELOCALY=8, + MOVELOCALZ=9, + SCALE=10 } } diff --git a/Data/TromboneEventManager.cs b/Data/TromboneEventManager.cs index c99e363..7488322 100644 --- a/Data/TromboneEventManager.cs +++ b/Data/TromboneEventManager.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reflection; using UnityEngine; using UnityEngine.Events;