public void NextState(InputAction.CallbackContext context) { if (context.performed) { CurrentPlayerState = CurrentPlayerState.Next(); } }
public void PreviousState(InputAction.CallbackContext context) { if (context.performed) { CurrentPlayerState = CurrentPlayerState.Prev(); } }
// 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(); } }
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; }
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; } }
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); } }
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(); } }
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(); }
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); } }