Beispiel #1
0
    public void SetDirection(Vector2 direction)
    {
        if (_isometricType == IsometricType.Death)
        {
            return;
        }

        //use the Run states by default
        string[] directionArray = null;

        //measure the magnitude of the input.
        if (direction.magnitude < .01f)
        {
            //if we are basically standing still, we'll use the Static states
            //we won't be able to calculate a direction if the user isn't pressing one, anyway!
            directionArray = staticDirections;
            _isometricType = IsometricType.Idle;
        }
        else
        {
            //we can calculate which direction we are going in
            //use DirectionToIndex to get the index of the slice from the direction vector
            //save the answer to lastDirection
            directionArray = runDirections;
            _isometricType = IsometricType.Move;
            lastDirection  = DirectionToIndex(direction, 8);
        }

        //tell the animator to play the requested state
        animator.Play(directionArray[lastDirection]);
    }
Beispiel #2
0
 public void SetRest()
 {
     if (_isometricType != IsometricType.Rest && _isometricType != IsometricType.Death)
     {
         animator.Play(REST_ANIM);
         _isometricType = IsometricType.Rest;
         EventManager.OnRestClickTimeChanged += CheckRest;
     }
 }
Beispiel #3
0
    public void SetDeath()
    {
        if (_isometricType != IsometricType.Death)
        {
            animator.Play(DEATH_ANIM);
            _isometricType = IsometricType.Death;

            Invoke("OnDeath", 1.2f);
        }
    }