Esempio n. 1
0
 public void NextState(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         CurrentPlayerState = CurrentPlayerState.Next();
     }
 }
Esempio n. 2
0
 public void PreviousState(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         CurrentPlayerState = CurrentPlayerState.Prev();
     }
 }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     currentPlayerState = CurrentPlayerState.alive;
     rigidBody          = GetComponent <Rigidbody2D>();
     spriteRenderer     = GetComponent <SpriteRenderer>();
     animator           = GetComponent <Animator>();
 }
 protected void Update()
 {
     UpdateMovementVector();
     DetectAttack();
     if (!InBlockingAnimation())
     {
         CurrentPlayerState.UpdateState();
     }
 }
Esempio n. 5
0
 public CurrentPlayerState(CurrentPlayerState state)
 {
     primaryWeapon   = state.primaryWeapon;
     primaryAmmo     = state.primaryAmmo;
     primaryClip     = state.primaryClip;
     secondaryWeapon = state.secondaryWeapon;
     secondaryAmmo   = state.secondaryAmmo;
     secondaryClip   = state.secondaryClip;
     maxHP           = state.maxHP;
 }
Esempio n. 6
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.gameObject.tag == "Ladder")
     {
         isClimbing             = false;
         facingLadder           = false;
         rigidBody.gravityScale = 5;
         currentPlayerState     = CurrentPlayerState.alive;
     }
     if (other.gameObject.tag == "upperLadder")
     {
         upperCollider = false;
     }
 }
Esempio n. 7
0
    private void playerMoveVertical(float verticalMovement)
    {
        Vector2 pos = transform.position;

        if (currentPlayerState != CurrentPlayerState.climbing && verticalMovement > 0 && facingLadder == true)
        {
            currentPlayerState = CurrentPlayerState.climbing;
            rigidBody.velocity = new Vector2(0f, verticalMovement + 1f);
            isGrounded         = false;
        }



        else if (currentPlayerState == CurrentPlayerState.climbing)
        {
            rigidBody.velocity = new Vector2(0f, verticalMovement + 1f);
        }
    }
Esempio n. 8
0
 private void EvaluateEndGame()
 {
     if (_scores[Players.Top].Value == Goal && _scores[Players.Bottom].Value == Goal)
     {
         Debug.Log("Ending. Tied!");
     }
     else if (_scores[_currentPlayer].Value == Goal && NextPlayerState.Equals(PlayerFSMStates.Stand))
     {
         Debug.Log("Ending. Won by: " + _currentPlayer);
     }
     else if (CurrentPlayerState.Equals(PlayerFSMStates.Stand) && NextPlayerState.Equals(PlayerFSMStates.Stand))
     {
         DeclareWinnerForBestScore();
     }
     else if (TopSlots.MaxedOut && BottomSlots.MaxedOut)
     {
         DeclareWinnerForBestScore();
     }
 }
Esempio n. 9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Ladder")
     {
         facingLadder = true;
     }
     if (other.gameObject.tag == "upperLadder")
     {
         upperCollider = true;
         if (currentPlayerState == CurrentPlayerState.climbing)
         {
             currentPlayerState     = CurrentPlayerState.alive;
             rigidBody.gravityScale = 5;
         }
     }
     currentPlayerState     = CurrentPlayerState.alive;
     rigidBody.gravityScale = 5;
     setAnimatorState();
 }
Esempio n. 10
0
 private void SwitchPlayers()
 {
     if (CurrentPlayerState.Equals(PlayerFSMStates.Stand) && NextPlayerState.Equals(PlayerFSMStates.Stand))
     {
         EvaluateEndGame();
     }
     else if (CurrentPlayerState.Equals(PlayerFSMStates.Stand))
     {
         _currentPlayer = NextPlayer;
         CurrentPlayerFsm.PerformTransition(PlayerFSMTransitions.PlayerTurn);
     }
     else if (NextPlayerState.Equals(PlayerFSMStates.Stand))
     {
         CurrentPlayerFsm.PerformTransition(PlayerFSMTransitions.PlayerTurn);
     }
     else
     {
         CurrentPlayerFsm.PerformTransition(PlayerFSMTransitions.PassControllToOtherPlayer);
         _currentPlayer = NextPlayer;
         CurrentPlayerFsm.PerformTransition(PlayerFSMTransitions.PlayerTurn);
     }
 }