/// <summary> /// Changeds animation dependant on PlayerState. /// </summary> protected virtual void HandleAnimation(float delta) { string oldAnimation = CurrentAnimationName; #region Handle Animation States // Change the animation depending on the player // state. if (_playerState == PlayerState.Grounded) { CurrentAnimationName = "Idle"; } else if (_playerState == PlayerState.Running) { CurrentAnimationName = "Run"; } else if (_playerState == PlayerState.Falling) { CurrentAnimationName = "Falling"; } else if (_playerState == PlayerState.Jumping) { CurrentAnimationName = "Jumping"; } else if (_playerState == PlayerState.Climbing) { CurrentAnimationName = "Climbing"; } else if (_playerState == PlayerState.Dead) { CurrentAnimationName = "Dead"; } else if (_playerState == PlayerState.Swinging) { CurrentAnimationName = "Swinging"; } #endregion // If the animation has changed, reset its current frame if (oldAnimation != CurrentAnimationName) { CurrentAnimation.ResetCurrentFrame(); } // Play through the animation if (CurrentAnimation != null) { CurrentAnimation.Update(delta); } }