private void Update() { if (dead) { return; } // Check Ground RaycastHit hitInfo; if (groundgracetimer <= 0 && Physics.Raycast(transform.position, Vector3.down, out hitInfo, GROUNDCHECKDIST, ~LayerMask.NameToLayer("Terrain"))) { grounded = true; } else { groundgracetimer--; grounded = false; } // State implementation var newState = state.HandleTransition(this); if (newState != null) { state.OnExit(this); state = newState; actions = state.OnEnter(this); } state.HandleUpdate(this); }
private void ProcessState(IPlayerState newState) { if (newState != null) { playerState.OnLeave(); playerState = newState; playerState.OnEnter(); } }
public void SwitchState(IPlayerState newPlayerState) { if (newPlayerState.Equals(null)) { return; } m_PlayerState.OnExit(); m_PlayerState = newPlayerState; m_PlayerState.OnEnter(); }
/// <summary> /// プレイヤーのステートを変更する /// </summary> /// <param name="arg_nextState">Argument next state.</param> public void StateTransion(IPlayerState arg_nextState) { if (m_currentState != null) { m_currentState.OnExit(this); } m_currentState = arg_nextState; m_currentState.OnEnter(this); }
public void ChangeState(IPlayerState newPlayerState) { if (playerState != null) { Debug.Log("Change state from: " + playerState.GetType() + " to: " + newPlayerState.GetType()); playerState.OnExit(); } playerState = newPlayerState; playerState.OnEnter(); }
public void TranslateTo(IPlayerState newPlayerState) { if (newPlayerState == _curPlayerState) { return; } _curPlayerState.OnExit(); _curPlayerState = newPlayerState; _curPlayerState.OnEnter(_player, _controller); }
public PlayerFiniteStateMachine(GameObject player, ActorController actorController, IPlayerState fristPlayerState, PlayerInput playerInput, Animator animator, Rigidbody rigidbody) { _curPlayerState = fristPlayerState; this._animator = animator; this._rigidbody = rigidbody; this._playerInput = playerInput; this._player = player; this._controller = actorController; fristPlayerState.OnEnter(_player, _controller); }
/// <summary> /// ステートの遷移を行う /// </summary> /// <param name="arg_nextState">次のステート</param> private void StateTransition(IPlayerState arg_nextState) { if (m_currentState != null) { m_currentState.OnExit(); m_currentState = null; } if (arg_nextState != null) { m_currentState = arg_nextState; m_currentState.OnEnter(); } }
/// <summary> /// ステートを遷移させる /// </summary> /// <param name="arg_nextState">次の状態</param> protected void StateTransition(IPlayerState arg_nextState) { m_currentState.OnExit(this); m_currentState = arg_nextState; m_currentState.OnEnter(this); }