Beispiel #1
0
        private float GetSmoothTime()
        {
            switch (_easingMode)
            {
            case EasingMode.Linear:
                return(Easings.Linear(_progress));

            // Quadratic
            case EasingMode.QuadraticIn:
                return(Easings.Quadratic.In(_progress));

            case EasingMode.QuadraticOut:
                return(Easings.Quadratic.Out(_progress));

            case EasingMode.QuadraticInOut:
                return(Easings.Quadratic.InOut(_progress));

            // Cubic
            case EasingMode.CubicIn:
                return(Easings.Cubic.In(_progress));

            case EasingMode.CubicOut:
                return(Easings.Cubic.Out(_progress));

            case EasingMode.CubicInOut:
                return(Easings.Cubic.InOut(_progress));

            // Quartic
            case EasingMode.QuarticIn:
                return(Easings.Quartic.In(_progress));

            case EasingMode.QuarticOut:
                return(Easings.Quartic.Out(_progress));

            case EasingMode.QuarticInOut:
                return(Easings.Quartic.InOut(_progress));

            // Quintic
            case EasingMode.QuinticIn:
                return(Easings.Quintic.In(_progress));

            case EasingMode.QuinticOut:
                return(Easings.Quintic.Out(_progress));

            case EasingMode.QuinticInOut:
                return(Easings.Quintic.InOut(_progress));

            // Bounce
            case EasingMode.BounceIn:
                return(Easings.Bounce.In(_progress));

            case EasingMode.BounceOut:
                return(Easings.Bounce.Out(_progress));

            case EasingMode.BounceInOut:
                return(Easings.Bounce.InOut(_progress));

            // Back
            case EasingMode.BackIn:
                return(Easings.Back.In(_progress));

            case EasingMode.BackOut:
                return(Easings.Back.Out(_progress));

            case EasingMode.BackInOut:
                return(Easings.Back.InOut(_progress));

            // Custom
            case EasingMode.CustomCurve:
                return(_customCurve.Evaluate(_progress));
            }
            throw new NotImplementedException("Easing [" + _easingMode + "] not implemented");
        }
        [Test] // TODO: Simplify and split this into at least some categories
        public void CheckAllEasings()
        {
            const float progress = 0.25f;

            _tween.start    = 0f;
            _tween.end      = 1f;
            _tween.progress = progress;

            _tween.easingMode = EasingMode.Linear;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Linear(progress), _tween.value));

            // Quadratic
            _tween.easingMode = EasingMode.QuadraticIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quadratic.In(progress), _tween.value));

            _tween.easingMode = EasingMode.QuadraticOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quadratic.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.QuadraticInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quadratic.InOut(progress), _tween.value));

            // Cubic
            _tween.easingMode = EasingMode.CubicIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Cubic.In(progress), _tween.value));

            _tween.easingMode = EasingMode.CubicOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Cubic.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.CubicInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Cubic.InOut(progress), _tween.value));

            // Quartic
            _tween.easingMode = EasingMode.QuarticIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quartic.In(progress), _tween.value));

            _tween.easingMode = EasingMode.QuarticOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quartic.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.QuarticInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quartic.InOut(progress), _tween.value));

            // Quintic
            _tween.easingMode = EasingMode.QuinticIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quintic.In(progress), _tween.value));

            _tween.easingMode = EasingMode.QuinticOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quintic.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.QuinticInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Quintic.InOut(progress), _tween.value));

            // Bounce
            _tween.easingMode = EasingMode.BounceIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Bounce.In(progress), _tween.value));

            _tween.easingMode = EasingMode.BounceOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Bounce.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.BounceInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Bounce.InOut(progress), _tween.value));

            // Back
            _tween.easingMode = EasingMode.BackIn;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Back.In(progress), _tween.value));

            _tween.easingMode = EasingMode.BackOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Back.Out(progress), _tween.value));

            _tween.easingMode = EasingMode.BackInOut;
            _tween.Apply();
            Assert.IsTrue(Mathf.Approximately(Easings.Back.InOut(progress), _tween.value));
        }