예제 #1
0
    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);
    }
예제 #2
0
 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();
 }
예제 #4
0
    /// <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);
    }
예제 #5
0
 public void ChangeState(IPlayerState newPlayerState)
 {
     if (playerState != null)
     {
         Debug.Log("Change state from: " + playerState.GetType() + " to: " + newPlayerState.GetType());
         playerState.OnExit();
     }
     playerState = newPlayerState;
     playerState.OnEnter();
 }
예제 #6
0
        public void TranslateTo(IPlayerState newPlayerState)
        {
            if (newPlayerState == _curPlayerState)
            {
                return;
            }

            _curPlayerState.OnExit();
            _curPlayerState = newPlayerState;
            _curPlayerState.OnEnter(_player, _controller);
        }
예제 #7
0
        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);
        }
예제 #8
0
 /// <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();
     }
 }
예제 #9
0
 /// <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);
 }