Ejemplo n.º 1
0
 public void ChangeAnimation(CharacterAnimationState state, CharacterAnimationDirection direction = CharacterAnimationDirection.Down)
 {
     if (currentCharacterAnimation.characterAnimationState != state || currentCharacterAnimation.characterAnimationDirection != direction)
     {
         currentCharacterAnimation = GetCharacterAnimation(state, direction);
         SetUpAnimation();
     }
 }
Ejemplo n.º 2
0
 private CharacterAnimation GetCharacterAnimation(CharacterAnimationState state, CharacterAnimationDirection direction = CharacterAnimationDirection.Down)
 {
     for (int i = 0; i < characterAnimations.Length; i++)
     {
         if (characterAnimations[i].characterAnimationState == state && characterAnimations[i].characterAnimationDirection == direction)
         {
             return(characterAnimations[i]);
         }
     }
     return(characterAnimations[0]);
 }
Ejemplo n.º 3
0
    public void GetAnimationFromVector2(float x, float y, CharacterAnimationState animationState)
    {
        CharacterAnimationDirection direction = CharacterAnimationDirection.Down;

        if (x == 0 && y != 0)
        {
            if ((y > 0))
            {
                direction = CharacterAnimationDirection.Up;
            }
            else
            {
                direction = CharacterAnimationDirection.Down;
            }
        }
        else
        {
            if (x < 0)
            {
                x        *= -1;
                direction = CharacterAnimationDirection.Left;
            }
            else
            {
                direction = CharacterAnimationDirection.Right;
            }

            if (y > x || (y < 0 && y + x < 0))
            {
                if ((y > 0))
                {
                    direction = CharacterAnimationDirection.Up;
                }
                else
                {
                    direction = CharacterAnimationDirection.Down;
                }
            }
        }
        //else
        //ChangeAnimation(state);
        ChangeAnimation(animationState, direction);
    }