Ejemplo n.º 1
0
 public void Initialize(ITweenTarget <T> target, T to, float duration)
 {
     Reset();
     this.target   = target;
     this.toValue  = to;
     this.duration = duration;
 }
Ejemplo n.º 2
0
 public virtual void recycleSelf()
 {
     if (_shouldRecycleTween)
     {
         _target    = null;
         _nextTween = null;
     }
 }
Ejemplo n.º 3
0
 public virtual void RecycleSelf()
 {
     if (shouldRecycleTween)
     {
         target    = null;
         nextTween = null;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// resets all state to defaults and sets the initial state based on the paramaters passed in. This method serves
        /// as an entry point so that Tween subclasses can call it and so that tweens can be recycled. When recycled,
        /// the constructor will not be called again so this method encapsulates what the constructor would be doing.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        public void initialize(ITweenTarget <T> target, T to, float duration)
        {
            // reset state in case we were recycled
            resetState();

            _target   = target;
            _toValue  = to;
            _duration = duration;
        }
Ejemplo n.º 5
0
 public IntTween(ITweenTarget <int> target, int from, int to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 6
0
 public QuaternionTween(ITweenTarget <Quaternion> tweenTarget, Quaternion toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 7
0
 public Vector2Tween(ITweenTarget <Vector2> target, Vector2 from, Vector2 to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 8
0
 public Color32Tween(ITweenTarget <Color32> target, Color32 from, Color32 to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 9
0
 public RectTween(ITweenTarget <Rect> target, Rect to, float duration)
 {
     Initialize(target, to, duration);
 }
Ejemplo n.º 10
0
 public Vector3Tween(ITweenTarget <Vector3> target, Vector3 from, Vector3 to, float duration)
 {
     Initialize(target, to, duration);
 }
Ejemplo n.º 11
0
 public ColorTween(ITweenTarget <Color> tweenTarget, Color toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 12
0
 public RectangleTween(ITweenTarget <Rectangle> tweenTarget, Rectangle toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 13
0
 public Vector2Tween(ITweenTarget <System.Numerics.Vector2> target, System.Numerics.Vector2 to, float duration)
 {
     Initialize(target, to, duration);
 }
Ejemplo n.º 14
0
 public IntTween(ITweenTarget <int> tweenTarget, int toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 15
0
 public QuaternionTween(ITweenTarget <Quaternion> target, Quaternion from, Quaternion to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 16
0
 public ColorTween(ITweenTarget <Color> target, Color from, Color to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 17
0
        public bool tick()
        {
            if (_tweenState == TweenState.Paused)
            {
                return(false);
            }

            // when we loop we clamp values between 0 and duration. this will hold the excess that we clamped off so it can be reapplied
            var elapsedTimeExcess = 0f;

            if (!_isRunningInReverse && _elapsedTime >= _duration)
            {
                elapsedTimeExcess = _elapsedTime - _duration;
                _elapsedTime      = _duration;
                _tweenState       = TweenState.Complete;
            }
            else if (_isRunningInReverse && _elapsedTime <= 0)
            {
                elapsedTimeExcess = 0 - _elapsedTime;
                _elapsedTime      = 0f;
                _tweenState       = TweenState.Complete;
            }

            // elapsed time will be negative while we are delaying the start of the tween so dont update the value
            if (_elapsedTime >= 0 && _elapsedTime <= _duration)
            {
                updateValue();
            }

            // if we have a loopType and we are Complete (meaning we reached 0 or duration) handle the loop.
            // handleLooping will take any excess elapsedTime and factor it in and call udpateValue if necessary to keep
            // the tween perfectly accurate.
            if (_loopType != LoopType.None && _tweenState == TweenState.Complete && _loops > 0)
            {
                handleLooping(elapsedTimeExcess);
            }

            var deltaTime = _isTimeScaleIndependent ? Time.unscaledDeltaTime : Time.deltaTime;

            deltaTime *= _timeScale;

            // running in reverse? then we need to subtract deltaTime
            if (_isRunningInReverse)
            {
                _elapsedTime -= deltaTime;
            }
            else
            {
                _elapsedTime += deltaTime;
            }

            if (_tweenState == TweenState.Complete)
            {
                if (_completionHandler != null)
                {
                    _completionHandler(this);
                }

                // if we have a nextTween add it to ZestKit so that it can start running
                if (_nextTween != null)
                {
                    _nextTween.start();
                    _nextTween = null;
                }

                if (ticker != null)
                {
                    StopTicker();
                    _target = null;
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 18
0
 public FloatTween(ITweenTarget <float> target, float from, float to, float duration)
 {
     initialize(target, from, to, duration);
 }
Ejemplo n.º 19
0
 public Vector4Tween(ITweenTarget <Vector4> tweenTarget, Vector4 toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 20
0
 public FloatTween(ITweenTarget <float> tweenTarget, float toValue, float duration)
     : base(tweenTarget, toValue, duration)
 {
 }
Ejemplo n.º 21
0
 public Vector4Tween(ITweenTarget <Vector4> target, Vector4 to, float duration)
 {
     Initialize(target, to, duration);
 }
Ejemplo n.º 22
0
 public RectangleTween(ITweenTarget <Rectangle> target, Rectangle to, float duration)
 {
     Initialize(target, to, duration);
 }
Ejemplo n.º 23
0
 protected Tween(ITweenTarget <T> tweenTarget, T toValue, float duration)
 {
     this.TweenTarget = tweenTarget;
     this.ToValue     = toValue;
     this.Duration    = duration;
 }