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;
 }