Пример #1
0
 protected bool SetDefaultInitState(FSM_State newState)
 {
     // determine whether state id is valid or not
     if (newState.GetID() == StateID_Invalid)
     {
         Debug.LogError("Invalid state ID");
         return(false);
     }
     _defaultInitState = newState;
     return(true);
 }
Пример #2
0
        public bool ChangeState(FSM_State nextState)
        {
            // determine whether state id is valid or not
            if ((nextState == null) || (nextState.GetID() == FSM.StateID_Invalid))
            {
                Debug.LogError("Invalid state ID");
                return(false);
            }

            // compared with state priority
            if (this._stateID_Next != FSM.StateID_Invalid)
            {
                if (_thisFSM.GetState(this._stateID_Next).GetPriority() > nextState.GetPriority())
                {
                    return(true);
                }
            }
            _stateID_Next = nextState.GetID();

            return(true);
        }
Пример #3
0
        public bool AddState(FSM_State newState)
        {
            int stateID = newState.GetID();

            // determine whether state id is valid or not
            if (this.StateMap.ContainsKey(stateID))
            {
                Debug.LogError("StateID is repeated.");
                return(false);
            }

            this.StateMap.Add(stateID, newState);

            // this state is InitState if it's the first one
            if (this.StateMap.Count == 1)
            {
                SetDefaultInitState(newState);
            }
            return(true);
        }