Exemplo n.º 1
0
    private void OnTick(PushdownState inputState)
    {
        IOnStateTick inputInterface = inputState as IOnStateTick;

        if (inputInterface != null)
        {
            inputInterface.OnTick();
        }
    }
Exemplo n.º 2
0
    private void OnExit(PushdownState inputState)
    {
        IOnStateExit inputInterface = inputState as IOnStateExit;

        if (inputInterface != null)
        {
            inputInterface.OnExit();
        }
    }
Exemplo n.º 3
0
    private void OnEnter(PushdownState inputState)
    {
        IOnStateEnter inputInterface = inputState as IOnStateEnter;

        if (inputInterface != null)
        {
            inputInterface.OnEnter();
        }
    }
Exemplo n.º 4
0
    private void OnAwake(PushdownState inputState)
    {
        IOnStateAwake inputInterface = inputState as IOnStateAwake;

        if (inputInterface != null)
        {
            inputInterface.OnAwake();
        }
    }
Exemplo n.º 5
0
 public void AddState(PushdownState inputState)
 {
     if (inputState == null)
     {
         return;
     }
     inputState.StateMachine = this;
     OnAwake(inputState);
 }
Exemplo n.º 6
0
 public void ClearStates()
 {
     while (_pushdownStack.Count > 1)
     {
         PushdownState tempState = _pushdownStack[_pushdownStack.Count - 1];
         _pushdownStack.RemoveAt(_pushdownStack.Count - 1);
         OnExit(tempState);
     }
 }
Exemplo n.º 7
0
    public void QueueState(PushdownState inputState)
    {
        if (inputState == null)
        {
            Debug.LogFormat("Tried to queue a null state!");
            return;
        }

        _pushdownStack.Insert(1, inputState);
        inputState.StateMachine = this;


        OnAwake(inputState);
    }
Exemplo n.º 8
0
    public void Tick()
    {
        PushdownState currentState = PeekState();

        if (currentState != null)
        {
            //Debug.LogFormat("PushdownStateMachine.Tick: currentState = {0}", currentState.GetStateName());
            OnTick(currentState);
        }
        else
        {
            Debug.LogFormat("CurrentState = null!");
        }
    }
Exemplo n.º 9
0
    public void PushState(PushdownState state)
    {
        AddState(state);
        PushdownState previousState = PeekState();

        if (previousState != null)
        {
            OnExit(previousState);
        }

        PushdownState nextState = state;

        if (nextState != null)
        {
            _pushdownStack.Add(nextState);
            OnEnter(nextState);
        }
    }
Exemplo n.º 10
0
    public void PopState()
    {
        if (_pushdownStack.Count == 0)
        {
            return;
        }

        PushdownState previousState = _pushdownStack[_pushdownStack.Count - 1];

        _pushdownStack.RemoveAt(_pushdownStack.Count - 1);
        if (previousState != null)
        {
            OnExit(previousState);
        }

        PushdownState nextState = PeekState();

        if (nextState != null)
        {
            OnEnter(nextState);
        }
    }