Exemple #1
0
 protected override void HandleInput(HashSet <KeyPress> input)
 {
     if (input.Contains(KeyPress.Roll))
     {
         ChangeState(PlayerStateEnum.TestRoll);
     }
     else if (input.Contains(KeyPress.Jump) && IsGrounded())
     {
         ChangeState(PlayerStateEnum.TestJump);
     }
     else if (input.Contains(KeyPress.MoveLeft))
     {
         // unflipped = facing right
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceLeft(_animator);
     }
     else if (input.Contains(KeyPress.MoveRight))
     {
         // unflipped = facing right
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceRight(_animator);
     }
     else if (input.Contains(KeyPress.MidAttack))
     {
         ChangeState(PlayerStateEnum.TestMidAttack);
     }
 }
Exemple #2
0
 protected override void HandleInput(HashSet <KeyPress> input)
 {
     if (!CollisionCommon.IsGrounded(_player))
     {
         ChangeState(PlayerStateEnum.TestAirborneMove);
     }
     else if (input.Contains(KeyPress.Jump))
     {
         ChangeState(PlayerStateEnum.TestJump);
     }
     else if (input.Contains(KeyPress.Roll))
     {
         ChangeState(PlayerStateEnum.TestRoll);
     }
     else if (input.Contains(KeyPress.MidAttack))
     {
         ChangeState(PlayerStateEnum.TestMidAttack);
     }
     else if (input.Contains(KeyPress.MoveRight))
     {
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceRight(_animator);
     }
     else if (input.Contains(KeyPress.MoveLeft))
     {
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceLeft(_animator);
     }
 }
Exemple #3
0
    protected override void HandleInput(HashSet <KeyPress> input)
    {
        if ((timeLeft -= Time.deltaTime) > 0f)
        {
            return;
        }

        if (input.Contains(KeyPress.MoveRight))
        {
            ChangeState(PlayerStateEnum.TestMove);
            AnimatorCommon.FaceRight(_animator);
            timeLeft = Constants.ROLL_TIME;
        }
        else if (input.Contains(KeyPress.MoveLeft))
        {
            ChangeState(PlayerStateEnum.TestMove);
            AnimatorCommon.FaceLeft(_animator);
            timeLeft = Constants.ROLL_TIME;
        }
        else
        {
            ChangeState(PlayerStateEnum.TestIdle);
            timeLeft = Constants.ROLL_TIME;
        }
    }
    void Start()
    {
        _animator       = GetComponent <Animator>();
        _spriteRenderer = GetComponent <SpriteRenderer>();
        _states         = new Dictionary <PlayerStateEnum, PlayerState>();

        AnimatorCommon.FaceRight(_animator);
        AnimatorCommon.SetState(_animator, (int)(PlayerStateEnum.TestIdle));
        InitStates();
    }