Esempio n. 1
0
        //====================================================================== HELPERS

        private void Tween(T startValue, T endValue, HiraTweenEaseType easeType, Action callback)
        {
            Stop();

            CurrentTracker = new HiraTween(duration,
                                           f => Target.Invoke(InterpolationFunction(startValue, endValue, f)),
                                           type, easeType, callback).Start();
        }
Esempio n. 2
0
 // Generic Constructor
 public HiraTween(float time,
                  Action <float> onIteration,
                  HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear,
                  HiraTweenEaseType easeType         = HiraTweenEaseType.EaseIn,
                  Action onCompletion = null)
 {
     Time         = time;
     OnIteration  = onIteration;
     TweenType    = tweenType;
     EaseType     = easeType;
     OnCompletion = onCompletion;
 }
        internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType)
        {
            // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
            switch (easeType)
            {
            case HiraTweenEaseType.EaseIn: return(EaseIn);

            case HiraTweenEaseType.EaseOut: return(EaseOut);

            case HiraTweenEaseType.EaseInOut: return(EaseInOut);

            default: throw new ArgumentOutOfRangeException(nameof(easeType), easeType, null);
            }
        }
Esempio n. 4
0
 // Vector2 Tween Constructor
 public HiraTween(Action <Vector2> setter,
                  Vector2 a,
                  Vector2 b,
                  float time,
                  HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear,
                  HiraTweenEaseType easeType         = HiraTweenEaseType.EaseIn,
                  Action onCompletion = null)
 {
     Time         = time;
     OnIteration  = t => setter(Vector2.LerpUnclamped(a, b, t));
     OnCompletion = onCompletion;
     TweenType    = tweenType;
     EaseType     = easeType;
 }
Esempio n. 5
0
 // Quaternion Tween Constructor
 public HiraTween(Action <Quaternion> setter,
                  Quaternion a,
                  Quaternion b,
                  float time,
                  HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear,
                  HiraTweenEaseType easeType         = HiraTweenEaseType.EaseIn,
                  Action onCompletion = null)
 {
     Time         = time;
     OnIteration  = t => setter(Quaternion.SlerpUnclamped(a, b, t));
     OnCompletion = onCompletion;
     TweenType    = tweenType;
     EaseType     = easeType;
 }
Esempio n. 6
0
 // Euler Tween Constructor
 public HiraTween(Action <Vector3> setter,
                  Quaternion a,
                  Quaternion b,
                  float time,
                  HiraTweenterpolationType tweenType = HiraTweenterpolationType.Linear,
                  HiraTweenEaseType easeType         = HiraTweenEaseType.EaseIn,
                  Action onCompletion = null)
 {
     Time         = time;
     var(x, y)    = (a.eulerAngles, b.eulerAngles);
     OnIteration  = t => setter(Vector3.SlerpUnclamped(x, y, t));
     OnCompletion = onCompletion;
     TweenType    = tweenType;
     EaseType     = easeType;
 }
Esempio n. 7
0
        internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType)
        {
            switch (easeType)
            {
            case HiraTweenEaseType.EaseIn:
                return(EaseIn);

            case HiraTweenEaseType.EaseOut:
                return(EaseOut);

            case HiraTweenEaseType.EaseInOut:
                return(EaseInOut);

            default:
                throw new ArgumentOutOfRangeException(nameof(easeType), easeType, null);
            }
        }
 internal static Func <float, float> GetInterpolationMethod(HiraTweenEaseType easeType) => Interpolate;