예제 #1
0
    public virtual bool SetOrInitializeState(StateOld state)
    {
        bool success = false;

        if (state && state != currentState)
        {
            StateOld oldState = currentState;
            currentState = state;
            if (oldState)
            {
                oldState.ExitState();
            }
            if (stateList.Contains(currentState))
            {
                currentState.EnterState();
            }
            else
            {
                currentState.Initialize(this);
                stateList.Add(currentState);
            }
            success = true;
        }
        return(success);
    }
예제 #2
0
    public virtual bool SetState(StateOld state)
    {
        //print(state.name);
        bool success = false;

        if (state && state != currentState)
        {
            StateOld oldState = currentState;
            currentState = state;
            if (oldState)
            {
                oldState.ExitState();
            }
            currentState.EnterState();
            success = true;
        }
        return(success);
    }