Example #1
0
 public AValueArrayTween(EasingFunc easing, TValue[] buffer, TValue[] source, TValue[] target)
     : base(easing)
 {
     m_Buffer = buffer;
     m_Source = source;
     m_Target = target;
 }
Example #2
0
        public AEasingTween(EasingFunc easing)
        {
#if CALLSTACK_DEBUG
            Callstack = System.Environment.StackTrace;
#endif
            m_Easing   = easing;
            m_Progress = 0;
        }
Example #3
0
 // -------------------------------------------------------------------------------------------
 /// <summary>
 /// Sets the easing function to use.
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 public Tween SetEasing(EasingFunc e)
 {
     _easing = e;
     if (_easing == null)
     {
         _easing = Easing.QuadEaseIn;
     }
     return(this);
 }
Example #4
0
        protected override void OnKill()
        {
            setter_ = null;

            duration_ = 0f;
            easing_   = null;

            points_.Clear();
            elapsed_ = 0f;
        }
Example #5
0
        // -------------------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------------------
        // METHODS
        // -------------------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------------------

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="time"></param>
        /// <param name="useFrames"></param>
        public Tween(object target, int time, bool useFrames)
        {
            _duration   = time;
            _elapsed    = 0;
            _delay      = 0;
            _numRepeats = 0;
            _target     = target;
            _useFrames  = useFrames;
            _state      = TweenState.START;
            _easing     = Easing.QuadEaseOut;
            _overwrite  = Overwrite.OVERWRITE_DEFAULT;
            _procedures = new List <ITweenProcedure>();
        }
Example #6
0
        protected override void OnKill()
        {
            getter_ = null;
            setter_ = null;

            getterWithPayload_ = null;
            setterWithPayload_ = null;

            baseValue_       = Vector3.zero;
            forcedBaseValue_ = null;

            strength_ = Vector3.one;
            vibrato_  = 10f;
            duration_ = 0f;
            easing_   = null;
            payload_  = null;

            elapsed_ = 0f;
        }
        protected override void OnKill()
        {
            getter_ = null;
            setter_ = null;

            getterWithPayload_ = null;
            setterWithPayload_ = null;

            startValue_ = default(T);
            endValue_   = default(T);
            finalValue_ = default(T);

            duration_      = 0f;
            relative_      = false;
            easing_        = null;
            onUpdateValue_ = null;
            payload_       = null;

            elapsed_ = 0f;
        }
Example #8
0
 public Tween(IEasing easing, TweenType easingType = TweenType.In)
 {
     _name = easing.Name;
     _type = easingType;
     switch (easingType)
     {
             case TweenType.In:
             _easing = easing.In;
             break;
             case TweenType.Out:
             _easing = easing.Out;
             break;
             case TweenType.OutIn:
             _easing = easing.OutIn;
             break;
         default:
             throw new ArgumentException("easingType must be one of [Tween.TweenType.In, Tween.TweenType.Out, Tween.TweenType.OutIn]. Value: " + easingType);
     }
     StartTime = 0;
     EndTime = 1000;
     StartValue = 0;
     EndValue = 1;
 }
 public ConcreteClass SetEasing(EasingFunc easing)
 {
     easing_ = easing;
     return((ConcreteClass)((object)this));
 }
Example #10
0
 public UIntTween(EasingFunc easing, uint source, uint target)
     : base(easing, source, target)
 {
 }
Example #11
0
        // -------------------------------------------------------------------------------------------
        /// <summary>
        /// Retrieves the reverse of the specified easing function, if one exists.
        /// Otherwise, returns the same function.
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private EasingFunc GetReverse(EasingFunc e)
        {
            EasingFunc result = e;

            if (e == Easing.BackEaseIn)
            {
                result = Easing.BackEaseOut;
            }
            else if (e == Easing.BackEaseOut)
            {
                result = Easing.BackEaseIn;
            }
            else if (e == Easing.BounceEaseIn)
            {
                result = Easing.BounceEaseOut;
            }
            else if (e == Easing.BounceEaseOut)
            {
                result = Easing.BounceEaseIn;
            }
            else if (e == Easing.CircEaseIn)
            {
                result = Easing.CircEaseOut;
            }
            else if (e == Easing.CircEaseOut)
            {
                result = Easing.CircEaseIn;
            }
            else if (e == Easing.CubicEaseIn)
            {
                result = Easing.CubicEaseOut;
            }
            else if (e == Easing.CubicEaseOut)
            {
                result = Easing.CubicEaseIn;
            }
            else if (e == Easing.ElasticEaseIn)
            {
                result = Easing.ElasticEaseOut;
            }
            else if (e == Easing.ElasticEaseOut)
            {
                result = Easing.ElasticEaseIn;
            }
            else if (e == Easing.ExpoEaseIn)
            {
                result = Easing.ExpoEaseOut;
            }
            else if (e == Easing.ExpoEaseOut)
            {
                result = Easing.ExpoEaseIn;
            }
            else if (e == Easing.QuadEaseIn)
            {
                result = Easing.QuadEaseOut;
            }
            else if (e == Easing.QuadEaseOut)
            {
                result = Easing.QuadEaseIn;
            }
            else if (e == Easing.QuartEaseIn)
            {
                result = Easing.QuartEaseOut;
            }
            else if (e == Easing.QuartEaseOut)
            {
                result = Easing.QuartEaseIn;
            }
            else if (e == Easing.QuintEaseIn)
            {
                result = Easing.QuintEaseOut;
            }
            else if (e == Easing.QuintEaseOut)
            {
                result = Easing.QuintEaseIn;
            }
            else if (e == Easing.SineEaseIn)
            {
                result = Easing.SineEaseOut;
            }
            else if (e == Easing.SineEaseOut)
            {
                result = Easing.SineEaseIn;
            }

            return(result);
        }
Example #12
0
 public UIntArrayTween(EasingFunc easing, uint[] buffer, uint[] source, uint[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #13
0
        // -------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the tween.
        /// </summary>
        /// <param name="ms"></param>
        internal void Update(int ms)
        {
            if (_useFrames)
            {
                ms = 1;
            }

            if (_paused || _state == TweenState.COMPLETE)
            {
                return;
            }

            HandleOverwrite(Overwrite.OVERWRITE_ALL);

            _elapsed += ms;

            if (_state == TweenState.DELAY && _delay > 0)
            {
                if (_elapsed < _delay)
                {
                    return;
                }
                _state   = TweenState.START;
                _delay   = 0;
                _elapsed = 0;
            }

            if (_state == TweenState.START)
            {
                HandleOverwrite(_overwrite);
                if (_onStart != null)
                {
                    _onStart();
                }
                _state = TweenState.UPDATE;
            }

            UpdateProgress();
            if (_onUpdate != null)
            {
                _onUpdate();
            }

            if (_elapsed >= _duration && _state != TweenState.COMPLETE)
            {
                if (_numRepeats != 0)
                {
                    _elapsed = 0;
                    if (_numRepeats > 0)
                    {
                        --_numRepeats;
                    }
                    if (_onRepeat != null)
                    {
                        _onRepeat();
                    }

                    if (_yoyo)
                    {
                        foreach (ITweenProcedure proc in _procedures)
                        {
                            proc.Reverse();
                        }
                        _easing = GetReverse(_easing);
                    }
                }
                else
                {
                    _state = TweenState.COMPLETE;
                    if (_onComplete != null)
                    {
                        _onComplete();
                    }
                }
            }
        }
Example #14
0
 public FloatTween(EasingFunc easing, float source, float target)
     : base(easing, source, target)
 {
 }
Example #15
0
 public ULongTween(EasingFunc easing, ulong source, ulong target)
     : base(easing, source, target)
 {
 }
Example #16
0
 public ShakeTweenAction SetEasing(EasingFunc easing)
 {
     easing_ = easing;
     return(this);
 }
Example #17
0
 public DoubleArrayTween(EasingFunc easing, double[] buffer, double[] source, double[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #18
0
 public DoubleTween(EasingFunc easing, double source, double target)
     : base(easing, source, target)
 {
 }
Example #19
0
 public FloatArrayTween(EasingFunc easing, float[] buffer, float[] source, float[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #20
0
 public AValueTween(EasingFunc easing, TValue source, TValue target)
     : base(easing)
 {
     m_Source = source;
     m_Target = target;
 }
Example #21
0
 public UShortTween(EasingFunc easing, ushort source, ushort target)
     : base(easing, source, target)
 {
 }
Example #22
0
 public SByteArrayTween(EasingFunc easing, sbyte[] buffer, sbyte[] source, sbyte[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #23
0
 public ULongArrayTween(EasingFunc easing, ulong[] buffer, ulong[] source, ulong[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #24
0
        private double GetFormula(EasingFunc animType, double t, double b, double d, double c)
        {
            switch (animType)
            {
            case EasingFunc.Linear:
                return(c * t / d + b);

            case EasingFunc.EaseInQuad:
                return(c * (t /= d) * t + b);

            case EasingFunc.EaseOutQuad:
                return(-c * (t = t / d) * (t - 2) + b);

            case EasingFunc.EaseInOutQuad:
                if ((t /= d / 2) < 1)
                {
                    return(c / 2 * t * t + b);
                }
                else
                {
                    return(-c / 2 * (--t * (t - 2) - 1) + b);
                }

            case EasingFunc.EaseInCubic:
                return(c * (t /= d) * t * t + b);

            case EasingFunc.EaseOutCubic:
                return(c * ((t = t / d - 1) * t * t + 1) + b);

            case EasingFunc.EaseInOutCubic:
                if ((t /= d / 2) < 1)
                {
                    return(c / 2 * t * t * t + b);
                }
                else
                {
                    return(c / 2 * ((t -= 2) * t * t + 2) + b);
                }

            case EasingFunc.EaseInQuart:
                return(c * (t /= d) * t * t * t + b);

            case EasingFunc.EaseOutQuart:
                return(-c * ((t = t / d - 1) * t * t * t - 1) + b);

            case EasingFunc.EaseInExpo:
                if (Math.Abs(t) <= 0)
                {
                    return(b);
                }
                else
                {
                    return(c * Math.Pow(2, 10 * (t / d - 1)) + b);
                }

            case EasingFunc.EaseOutExpo:
                if (Math.Abs(t - d) <= 0)
                {
                    return(b + c);
                }
                else
                {
                    return(c * (-Math.Pow(2, -10 * t / d) + 1) + b);
                }

            default:
                return(0);
            }
        }
Example #25
0
 public ByteTween(EasingFunc easing, byte source, byte target)
     : base(easing, source, target)
 {
 }
Example #26
0
 public ShortArrayTween(EasingFunc easing, short[] buffer, short[] source, short[] target)
     : base(easing, buffer, source, target)
 {
 }
Example #27
0
 public PathAction SetEasing(EasingFunc easing)
 {
     easing_ = easing;
     return(this);
 }