Exemple #1
0
        /// <summary>
        ///     Handls the logic for looping an animation that is ping-pong
        ///     animating.
        /// </summary>
        private void PingPongAnimationLoopCheck()
        {
            //  Check if we are still within the bounds of the animations frames
            if (CurrentFrameIndex < CurrentAnimation.From || CurrentFrameIndex > CurrentAnimation.To)
            {
                //  Reverse the direction of the animation
                _direction = -_direction;

                if (_direction == -1)
                {
                    //  We've reached the end frame and reversed direciton, so set hte
                    //  current frame index to one less the last frame
                    CurrentFrameIndex = CurrentAnimation.To - 1;
                }
                else if (_direction == 1 && CurrentAnimation.IsOneShot)
                {
                    //  We've cycled the animation forward and backwards, and it's a one-shot
                    //  aniamtion, so we set the current frame to the first and stop animating
                    CurrentFrameIndex = CurrentAnimation.From;
                    Animating         = false;
                    OnAnimationEnd?.Invoke();
                }
                else if (_direction == 1)
                {
                    //  We've cycled the animation forward and backwards, and it is NOT
                    //  a one-shot animation, so we start it at the beginning + 1
                    CurrentFrameIndex = CurrentAnimation.From + 1;

                    //  And invoke the OnAnimationLoop action
                    OnAnimationLoop?.Invoke();
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///     Handles the logic for looping an animation that is animating
        ///     in a reverse direction.
        /// </summary>
        private void ReverseAnimationLoopCheck()
        {
            //  Chck that we are still within the bounds of the animation's frames
            if (CurrentFrameIndex < CurrentAnimation.From)
            {
                //  Check if this is a one-shot animation
                if (CurrentAnimation.IsOneShot)
                {
                    //  It's one-shot, set hte current frame to the first and stop animating
                    CurrentFrameIndex = CurrentAnimation.From;
                    Animating         = false;
                    OnAnimationEnd?.Invoke();
                }
                else
                {
                    //  Otherwise we loop the animation back to the end
                    CurrentFrameIndex = CurrentAnimation.To;

                    //  Since we looped, invoke the OnAnimationLoop action
                    OnAnimationLoop?.Invoke();
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///     Handles the logic for looping an animation that is animating
        ///     in a foward direciton.
        /// </summary>
        private void ForwardAnimationLoopCheck()
        {
            //  Check that we are still within the bounds of the animation's frames
            if (CurrentFrameIndex > CurrentAnimation.To)
            {
                //  Check if this is a one-shot animation
                if (CurrentAnimation.IsOneShot)
                {
                    //  It's one-shot, set current frame to last and stop animating
                    CurrentFrameIndex = CurrentAnimation.To;
                    Animating         = false;
                    OnAnimationEnd?.Invoke();
                }
                else
                {
                    //  Otherwise we loop the animation back to the beginning
                    CurrentFrameIndex = CurrentAnimation.From;

                    //  Since we looped, invoke the OnAnimationLoop action
                    OnAnimationLoop?.Invoke();
                }
            }
        }