예제 #1
0
 public void NextState(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         CurrentPlayerState = CurrentPlayerState.Next();
     }
 }
예제 #2
0
 public void PreviousState(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         CurrentPlayerState = CurrentPlayerState.Prev();
     }
 }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     currentPlayerState = CurrentPlayerState.alive;
     rigidBody          = GetComponent <Rigidbody2D>();
     spriteRenderer     = GetComponent <SpriteRenderer>();
     animator           = GetComponent <Animator>();
 }
예제 #4
0
 protected void Update()
 {
     UpdateMovementVector();
     DetectAttack();
     if (!InBlockingAnimation())
     {
         CurrentPlayerState.UpdateState();
     }
 }
예제 #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;
 }
예제 #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;
     }
 }
예제 #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);
        }
    }
예제 #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();
     }
 }
예제 #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();
 }
예제 #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);
     }
 }