コード例 #1
0
ファイル: FSM.cs プロジェクト: takaaptech/CosmosFramework
        public void StartDefault()
        {
            if (IsRunning)
            {
                return;
            }
            if (defaultState == null)
            {
                return;
            }
            Type type = defaultState.GetType();

            if (!typeof(FSMState <T>).IsAssignableFrom(type))
            {
                throw new ArgumentException("State type is invalid" + type.FullName);
            }
            FSMState <T> state = GetState(type);

            if (state == null)
            {
                return;
            }
            currentState = state;
            currentState.OnEnter(this);
        }
コード例 #2
0
ファイル: FSM.cs プロジェクト: Xujintao0519/CosmosFramework
        public void ChangeState(Type stateType)
        {
            if (currentState == null)
            {
                Utility.DebugError("Current state is invalid");
            }
            FSMState <T> state = null;

            state = GetState(state.GetType());
            if (state == null)
            {
                Utility.DebugError("FSM" + currentState.ToString() + " can not change state to " + state.ToString() + " which is not exist");
            }
            currentState.OnExit(this);
            currentState = state;
            currentState.OnEnter(this);
        }
コード例 #3
0
ファイル: FSM.cs プロジェクト: takaaptech/CosmosFramework
 public bool HasState(FSMState <T> state)
 {
     return(HasState(state.GetType()));
 }