Esempio n. 1
0
 public StateMachine(AbsEntity entity, string name,
                     List <AbsState> stateList, AbsState defaultState, List <AbsTransition> transitionList)
 {
     Enable = false;
     Name   = name;
     Entity = entity;
     _stateList.Clear();
     _transitionList.Clear();
     _stateList      = stateList;
     _defaultState   = defaultState;
     CurTrans        = null;
     CurrentState    = _defaultState;
     _transitionList = transitionList;
 }
Esempio n. 2
0
 public bool OnChangeState(AbsState fromState, AbsState toState)
 {
     if (CurTrans == null)
     {
         foreach (var target in TransitionList)
         {
             if (target.FromState == fromState && target.ToState == toState && target.TransState == StateMachineTransitionState.Finish && target.IsCanTrans())
             {
                 CurTrans = target;
                 return(true);
             }
         }
     }
     return(false);
 }