示例#1
0
        public void ChangeState(StateType type)
        {
            var state = _stateRegister[type];

            _currentState = state;
            _currentState.Enter();
        }
 public void SetState(AbstractState state)
 {
     if (_state != null)
     {
         _state.Exit(this);
     }
     _state = state;
     _state.Enter(this);
 }
    public void ChangeState(AbstractState newState)
    {
        if (_currentState == newState)
        {
            return;
        }

        _currentState.Exit();
        _currentState = newState;
        _currentState.Enter();
    }
    private void Awake()
    {
        CacheAllStates();
        _currentState = GetComponentInChildren <IdleState>();
        _currentState.Enter();

        idle = true;


        walking = running = backwards = false;
    }
示例#5
0
文件: Fsm.cs 项目: igli15/Circly-Fly
 private void ChangeState(AbstractState <T> pNewState)
 {
     if (_currentState == pNewState)
     {
         return;
     }
     if (_currentState != null)
     {
         _currentState.Exit(_target);
     }
     _currentState = pNewState;
     if (_currentState != null)
     {
         _currentState.Enter(_target);
     }
 }
示例#6
0
 /// <summary>
 /// Transitions from one state to another. Should only ever be called
 /// from the state machine's update function.
 /// </summary>
 /// <param name="id">ID mapped to the state in the Dictionary.</param>
 protected void Transition(int id)
 {
     // Call current state's Exit method. Base case: Initial transition.
     if (currentState != null) currentState.Exit();
     // Set current state to state mapped to the given key.
     currentState = states[id];
     // Call the new current state's Enter method.
     currentState.Enter();
 }