Exemple #1
0
 private bool Excute(FSMSentence sentence, int tokenIndex, FSMHandle handle, Stack<State> stack, object externalArg)
 {
     FSMToken.ExcuteResult excuteResult = sentence.Excute(tokenIndex, ref lastToken, handle, stack, externalArg);
     if (excuteResult == null)
     {
         Debug.LogError("excuteResult null on " + sentence + ", token:" + tokenIndex);
     }
     if (excuteResult.stopParagraph)
     {
         if (excuteResult.stopTokenType == FSMToken.E_TokenType.ChangeState)
         {
             string nextState = excuteResult.stopParam as string;
             fsm.SetState(nextState, excuteResult.stopParamArg);
         }
         else if (excuteResult.stopTokenType == FSMToken.E_TokenType.PushState)
         {
             string nextState = excuteResult.stopParam as string;
             fsm.PushState(nextState, excuteResult.stopParamArg);
         }
         else if (excuteResult.stopTokenType == FSMToken.E_TokenType.PopState)
         {
             fsm.PopState();
         }
         else if (excuteResult.stopTokenType == FSMToken.E_TokenType.SetTimer)
         {
             float? waitTime = Cast.To<float>(excuteResult.stopParam);
             SetTimer(waitTime.Value, handle, stack);
         }
         else if (excuteResult.stopTokenType == FSMToken.E_TokenType.Sleep)
         {
             float? waitTime = Cast.To<float>(excuteResult.stopParam);
             Sleep(waitTime.Value, handle, stack);
         }
         else
         {
             Debug.LogError("why stop in stopParam " + excuteResult.stopParam + "(" + excuteResult.stopParam.GetType() + ")");
         }
     }
     return excuteResult.stopParagraph;
 }
Exemple #2
0
 public void Update(FSMHandle handle, Stack<State> stack)
 {
     foreach (var sentence in paragraph.sentences)
     {
         //LogTool.Log("[sentence] " + sentence);
         bool stop = Excute(sentence, 0, handle, stack, null);
         if (stop)
         {
             lastSentence = sentence;
             return;
         }
     }
 }
Exemple #3
0
    private void ExcuteEvent(string eventName, FSMHandle handle, Stack<State> stack, object externalArg)
    {
        if (isWaiting)
        {
            return;
        }

        if (paragraph.events.ContainsKey(eventName))
        {
            var sentence = paragraph.events[eventName];
            bool stop = Excute(sentence, 0, handle, stack, externalArg);
            if (stop)
            {
                lastSentence = sentence;
                return;
            }
        }
    }