Exemplo n.º 1
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        internal void Update()
        {
            if (Paused)
            {
                return;
            }

            if (Delay > 0)
            {
                Delay -= _elapsed;
                return;
            }

            if (Math.Abs(_time) < Single.Epsilon)
            {
                _begin?.Invoke();
            }

            _update?.Invoke(Completion);

            _time += _elapsed;
            float t          = _time / Duration;
            bool  doComplete = false;

            if (_time >= Duration)
            {
                if (_repeatCount > 0)
                {
                    --_repeatCount;
                    _time = t = 0;
                }
                else if (_repeatCount < 0)
                {
                    doComplete = true;
                    _time      = t = 0;
                }
                else
                {
                    _time = Duration;
                    t     = 1;
                    _parent.Remove(this);
                    doComplete = true;
                }

                if (Math.Abs(_time) < Single.Epsilon)
                {
                    //	If the timer is zero here, we just restarted.
                    //	If reflect mode is on, flip start to end
                    if ((_behavior & Behavior.Reflect) == Behavior.Reflect)
                    {
                        Reverse();
                    }
                }
            }

            if (_ease != null)
            {
                t = _ease(t);
            }

            Interpolate(t);

            if (doComplete && _complete != null)
            {
                _complete();
            }
        }