Пример #1
0
 /// <summary>
 /// 处理事件
 /// </summary>
 /// <param name="name">Name.</param>
 public void HandleEvent(string name)
 {
     if (mCurState != null && mStateDict[mCurState].TranslationDict.ContainsKey(name))
     {
         QFSMTranslation tempTranslation = mStateDict [mCurState].TranslationDict [name];
         tempTranslation.callfunc();
         mCurState = tempTranslation.toState;
     }
 }
Пример #2
0
 /// <summary>
 /// Handles the event.
 /// </summary>
 /// <param name="name">Name.</param>
 /// <param name="param">Parameter.</param>
 public void HandleEvent(string name, params object[] param)
 {
     if (mCurState != null && mStateDict[mCurState].TranslationDict.ContainsKey(name))
     {
         QFSMTranslation tempTranslation = mStateDict [mCurState].TranslationDict [name];
         tempTranslation.OnTranslationCallback(param);
         mCurState = tempTranslation.ToState;
     }
 }
Пример #3
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();
     }
 }
        void Awake()
        {
            var stateA = new StateA(StateName.A);
            var stateB = new StateB(StateName.B);
            var stateC = new StateC(StateName.C);

            var a2b = new QFSMTranslation(stateA, (ushort)TranslationEvent.A_2_B, stateB);
            var a2c = new QFSMTranslation(stateA, (ushort)TranslationEvent.A_2_C, stateC);

            mFSM.AddState(stateA);
            mFSM.AddState(stateB);
            mFSM.AddState(stateC);

            mFSM.AddTranslation(a2b);
            mFSM.AddTranslation(a2c);

            mFSM.Start(stateA);



            mFSM.HandleEvent((ushort)TranslationEvent.A_2_B);
        }
Пример #5
0
 /// <summary>
 /// Adds the translation.
 /// </summary>
 /// <param name="translation">Translation.</param>
 public void AddTranslation(QFSMTranslation translation)
 {
     mStateDict [translation.FromState.Name].TranslationDict.Add(translation.EventName, translation);
 }