Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (_nextState != null && _currentState != null && _currentState.Status == StateStatus.Running)
        {
            Debug.LogWarning(_currentState.GetType() + " OnLeave");
            _currentState.OnLeave();
        }

        if (_currentState != null && _currentState.Status == StateStatus.LeaveEnded)
        {
            _currentState = null;
        }

        if (_currentState == null && _nextState != null)
        {
            _currentState = _nextState;
            _nextState    = null;
            Debug.LogWarning(_currentState.GetType() + " OnStart");
            _currentState.OnEnter();
        }

        if (_currentState != null && _currentState.Status == StateStatus.Running)
        {
            _currentState.Update();
        }
    }
    private void Update()
    {
        // handle StateMachine
        AbstractState newState = currentState.UpdateState();

        if (newState != null)
        {
            currentState.OnExit();
            currentState = newState;
            currentState.OnEnter();
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (Time.timeScale != 0)
     {
         // handle StateMachine
         AbstractState newState = currentState.UpdateState();
         if (newState != null)
         {
             currentState.OnExit();
             currentState = newState;
             currentState.OnEnter();
         }
     }
 }
Beispiel #4
0
        public void Run()
        {
            AbstractState <T> previous = currentState;

            if (Manager.GetNewState(ref currentState))
            {
                previous.OnExit(Entity);
                currentState.OnEnter(Entity);
                currentState.InState(Entity);
            }
            else
            {
                currentState.InState(Entity);
            }
        }