Example #1
0
 /// <summary>
 ///  添加一个状态
 /// </summary>
 /// <param name="state"></param>
 public void AddState(FSMBaseState state)
 {
     if (!allStateDic.ContainsKey(state.stateName))
     {
         allStateDic.Add(state.stateName, state);
     }
 }
Example #2
0
        /// <summary>
        ///  构造方法
        /// </summary>
        public FSMManager(object control)
        {
            this.control = control;
            FSMBaseState rootState = new FSMBaseState(FSMBaseState.RootState, this);

            AddState(rootState);
            TranslateToState(FSMBaseState.RootState);
        }
Example #3
0
 /// <summary>
 ///  转移到某个状态
 /// </summary>
 /// <param name="stateName"></param>
 public void TranslateToState(string stateName)
 {
     if (CurrentState != null)
     {
         if (stateName != CurrentState.stateName)
         {
             CurrentState.OnStateInvoke(StateEnum.StateExit);
             CurrentState = this[stateName];
             CurrentState.OnStateInvoke(StateEnum.StateEnter);
         }
     }
     else
     {
         CurrentState = this[stateName];
         CurrentState.OnStateInvoke(StateEnum.StateEnter);
     }
 }