Exemplo n.º 1
0
    public bool ChangeState(int newStateID)
    {
        VOState newState = getStateByID(newStateID);

        if (newState == null)
        {
            if (verbose == true)
            {
                Debug.Log("[STATE MACHINE] State " + newStateID + " not found!");
            }
            return(false);
        }

        if (canChangeTo(newStateID) == false)
        {
            if (verbose == true)
            {
                Debug.Log("[STATE MACHINE] Cannot change from state " + state.id + " to " + newStateID);
            }
            return(false);
        }

        lastState = state;
        state     = newState;

        lastState.exit();
        state.enter();
        if (verbose == true)
        {
            Debug.Log("[STATE MACHINE] State changed to " + state.id);
        }
        return(true);
    }
Exemplo n.º 2
0
    public void SetInitialState(int initialStateID)
    {
        VOState initialState = getStateByID(initialStateID);

        if (initialState == null)
        {
            if (verbose == true)
            {
                Debug.Log("[STATE MACHINE] State " + initialStateID + " not found!");
            }
        }
        else
        {
            state = initialState;
            state.enter();
        }
    }