Exemplo n.º 1
0
 /// <summary>
 /// Handles the event.
 /// </summary>
 /// <param name="eventName">Event name.</param>
 public void HandleEvent(ushort eventName)
 {
     if (mCurState != null && mStateDict[mCurState.Name].TranslationDict.ContainsKey(eventName))
     {
         QFSMTranslation tempTranslation = mStateDict [mCurState.Name].TranslationDict [eventName];
         tempTranslation.FromState.OnExit();
         mCurState = tempTranslation.ToState;
         tempTranslation.ToState.OnEnter();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Handles the event.
 /// </summary>
 /// <param name="eventName">Event name.</param>
 public void HandleEvent(ushort eventName)
 {
     if (mCurState != null && mStateDict[mCurState.Name].TranslationDict.ContainsKey(eventName))
     {
         //状态转移,从状态字典中当前状态的转移状态从来时状态中退出
         //状态转移的State换做当前状态,执行进入的OnEnter函数
         var tempTranslation = mStateDict[mCurState.Name].TranslationDict[eventName];
         tempTranslation.FromState.OnExit();
         mCurState = tempTranslation.ToState;
         tempTranslation.ToState.OnEnter();
     }
 }
Exemplo n.º 3
0
 public QFSMTranslation(QFSMState fromState, ushort eventName, QFSMState toState)
 {
     FromState = fromState;
     ToState   = toState;
     EventName = eventName;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Start the specified startState.
 /// </summary>
 /// <param name="startState">Start state.</param>
 public void Start(QFSMState startState)
 {
     mCurState = startState;
     mCurState.OnEnter();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds the translation.
 /// </summary>
 /// <param name="fromState">From state.</param>
 /// <param name="eventName">Event name.</param>
 /// <param name="toState">To state.</param>
 public void AddTranslation(QFSMState fromState, ushort eventName, QFSMState toState)
 {
     mStateDict [fromState.Name].TranslationDict.Add(eventName, new QFSMTranslation(fromState, eventName, toState));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds the state.
 /// </summary>
 /// <param name="state">State.</param>
 public void AddState(QFSMState state)
 {
     mStateDict.Add(state.Name, state);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds the state.
 /// </summary>
 /// <param name="name">Name.</param>
 public void AddState(string name)
 {
     mStateDict[name] = new QFSMState(name);
 }
Exemplo n.º 8
0
 public QFSMTranslation(QFSMState fromState, ushort eventName, QFSMState toState)
 {
     this.fromState = fromState;
     this.toState   = toState;
     this.eventName = eventName;
 }