예제 #1
0
            private static OperatableBase <T> EaseInOutBounce(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                if (time <= duration / 2.0f)
                {
                    return(EaseInBounce(time * 2.0f, default(OperatableBase <T>), delta, duration) * 0.5f + initial);
                }

                return(EaseOutBounce(time * 2.0f - duration, default(OperatableBase <T>), delta, duration) * 0.5f + delta * 0.5f + initial);
            }
예제 #2
0
            private static OperatableBase <T> EaseInOutCircular(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration / 2.0f;
                if (time <= 1.0f)
                {
                    return(-delta / 2.0f * (Mathf.Sqrt(1 - Mathf.Pow(time, 2.0f)) - 1.0f) + initial);
                }

                time -= 2.0f;
                return(delta / 2.0f * (Mathf.Sqrt(1 - Mathf.Pow(time, 2.0f)) + 1.0f) + initial);
            }
예제 #3
0
            private static OperatableBase <T> EaseInOutQuintic(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration / 2.0f;
                if (time <= 1.0f)
                {
                    return(delta / 2.0f * Mathf.Pow(time, 5.0f) + initial);
                }

                time -= 2.0f;
                return(delta / 2.0f * (Mathf.Pow(time, 5.0f) + 2.0f) + initial);
            }
예제 #4
0
            private static OperatableBase <T> EaseInOutQuadratic(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration / 2.0f;
                if (time <= 1.0f)
                {
                    return(delta / 2.0f * time * time + initial);
                }

                time -= 1.0f;
                return(-delta / 2.0f * (time * (time - 2.0f) - 1.0f) + initial);
            }
예제 #5
0
            private static OperatableBase <T> EaseInOutExponential(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration / 2.0f;
                if (time <= 1.0f)
                {
                    return(delta / 2.0f * Mathf.Pow(2.0f, 10.0f * (time - 1.0f)) + initial);
                }

                time -= 1.0f;
                return(delta / 2.0f * (-Mathf.Pow(2.0f, -10.0f * time) + 2.0f) + initial);
            }
예제 #6
0
 public TweenInformation(float startTime, OperatableBase <T> start, OperatableBase <T> finish, float duration, EaseType easeType, out T startValue, out T finishValue)
 {
     Time        = startTime;
     StartTime   = startTime;
     Start       = start;
     Finish      = finish;
     Duration    = duration;
     EaseType    = easeType;
     startValue  = start.Value;
     finishValue = finish.Value;
 }
예제 #7
0
            private static OperatableBase <T> EaseInOutBack(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                const float threshold = EaseBackThreshold * 1.525f;

                time /= duration / 2.0f;
                if (time <= 1.0f)
                {
                    return(delta / 2.0f * (Mathf.Pow(time, 2.0f) * ((threshold + 1.0f) * time - threshold)) + initial);
                }

                time -= 2.0f;
                return(delta / 2.0f * (Mathf.Pow(time, 2.0f) * ((threshold + 1.0f) * time + threshold) + 2.0f) + initial);
            }
예제 #8
0
            private static OperatableBase <T> EaseOutElastic(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration;
                if (Mathf.Approximately(time, 1.0f))
                {
                    return(initial + delta);
                }

                float p = duration * 0.3f;
                float s = p / 4.0f;

                return(delta * Mathf.Pow(2.0f, -10.0f * time) * Mathf.Sin((time * duration - s) * (2.0f * Mathf.PI) / p) + delta + initial);
            }
예제 #9
0
            private static OperatableBase <T> EaseInOutElastic(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration / 2.0f;
                if (Mathf.Approximately(time, 2.0f))
                {
                    return(initial + delta);
                }

                time -= 1.0f;
                float p = duration * (0.3f * 1.5f);
                float s = p / 4.0f;

                if (time <= 0.0f)
                {
                    return((delta * Mathf.Pow(2.0f, 10.0f * time) * Mathf.Sin((time * duration - s) * (2.0f * Mathf.PI) / p)) * -0.5f + initial);
                }

                return(delta * Mathf.Pow(2.0f, -10.0f * time) * Mathf.Sin((time * duration - s) * (2.0f * Mathf.PI) / p) * 0.5f + delta + initial);
            }
예제 #10
0
        private static OperatableBase <T> Easing <T>(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration, EaseType easeType) where T : struct
        {
            if (!EasingFunctions <T> .EasingFunctionMap.ContainsKey(easeType))
            {
                throw new ArgumentException(string.Format("EaseType: '{0}' does not implement yet.", easeType.ToString()));
            }

            if (time <= 0.0f)
            {
                return(initial);
            }

            if (time >= duration)
            {
                return(initial + delta);
            }

            return(EasingFunctions <T> .EasingFunctionMap[easeType](time, initial, delta, duration));
        }
예제 #11
0
            private static OperatableBase <T> EaseOutBounce(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
            {
                time /= duration;
                if (time <= (1.0f / 2.75f))
                {
                    return(delta * (7.5625f * Mathf.Pow(time, 2.0f)) + initial);
                }

                if (time <= (2.0f / 2.75f))
                {
                    time -= (1.5f / 2.75f);
                    return(delta * (7.5625f * Mathf.Pow(time, 2.0f) + 0.75f) + initial);
                }

                if (time <= (2.5f / 2.75f))
                {
                    time -= (2.25f / 2.75f);
                    return(delta * (7.5625f * Mathf.Pow(time, 2.0f) + 0.9375f) + initial);
                }

                time -= (2.625f / 2.75f);
                return(delta * (7.5625f * Mathf.Pow(time, 2.0f) + 0.984375f) + initial);
            }
예제 #12
0
 protected abstract int Compare(OperatableBase <T> value);
예제 #13
0
 protected override OperatableBase <int> Add(OperatableBase <int> value)
 {
     return(new OperatableInt(Value + value.Value));
 }
예제 #14
0
 protected abstract OperatableBase <T> Add(OperatableBase <T> value);
예제 #15
0
 protected abstract OperatableBase <T> Substract(OperatableBase <T> value);
예제 #16
0
 private static OperatableBase <T> EaseInCircular(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     time /= duration;
     return(-delta * (Mathf.Sqrt(1 - Mathf.Pow(time, 2.0f)) + 1.0f) + initial);
 }
예제 #17
0
 private static OperatableBase <T> EaseInOutSinusoidal(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     return(-delta / 2.0f * (Mathf.Cos(Mathf.PI * time / duration) + 1.0f) + initial);
 }
예제 #18
0
 protected override int Compare(OperatableBase <float> value)
 {
     return(Value > value.Value ? 1 : -1);
 }
예제 #19
0
 private static OperatableBase <T> EaseOutExponential(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     return(delta * (-Mathf.Pow(2.0f, -10.0f * time / duration) + 1.0f) + initial);
 }
예제 #20
0
 protected override OperatableBase <float> Add(OperatableBase <float> value)
 {
     return(new OperatableFloat(Value + value.Value));
 }
예제 #21
0
 protected override OperatableBase <Vector3> Substract(OperatableBase <Vector3> value)
 {
     return(new OperatableVector3(Value - value.Value));
 }
예제 #22
0
 private static OperatableBase <T> EaseOutBack(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     time /= duration;
     time -= 1.0f;
     return(delta * (Mathf.Pow(time, 2.0f) * ((EaseBackThreshold + 1.0f) * time + EaseBackThreshold) + 1.0f) + initial);
 }
예제 #23
0
 private static OperatableBase <T> EaseOutSinusoidal(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     return(delta * Mathf.Sin(time / duration * (Mathf.PI / 2.0f)) + initial);
 }
예제 #24
0
 private static OperatableBase <T> EaseOutCircular(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     time /= duration;
     time -= 1.0f;
     return(delta * Mathf.Sqrt(1 - Mathf.Pow(time, 2.0f)) + initial);
 }
예제 #25
0
 protected override OperatableBase <float> Substract(OperatableBase <float> value)
 {
     return(new OperatableFloat(Value - value.Value));
 }
예제 #26
0
 private static OperatableBase <T> EaseOutQuintic(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     time /= duration;
     time -= 1.0f;
     return(delta * (Mathf.Pow(time, 5.0f) + 1.0f) + initial);
 }
예제 #27
0
 protected override OperatableBase <Vector3> Add(OperatableBase <Vector3> value)
 {
     return(new OperatableVector3(Value + value.Value));
 }
예제 #28
0
 private static OperatableBase <T> EaseInExponential(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     return(delta * Mathf.Pow(2.0f, 10.0f * (time / duration - 1.0f)) + initial);
 }
예제 #29
0
 protected override int Compare(OperatableBase <Vector3> value)
 {
     return(Value.magnitude > value.Value.magnitude ? 1 : -1);
 }
예제 #30
0
 private static OperatableBase <T> EaseInBounce(float time, OperatableBase <T> initial, OperatableBase <T> delta, float duration)
 {
     return(delta - EaseOutBounce(duration - time, default(OperatableBase <T>), delta, duration) + initial);
 }