コード例 #1
0
ファイル: IAiLogic.cs プロジェクト: yqxflong/DashFire
 public void Execute(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
 {
     if (npc.GetAIEnable())
     {
         NpcAiStateInfo npcAi = npc.GetAiStateInfo();
         if (npcAi.CommandQueue.Count <= 0)
         {
             int curState = npcAi.CurState;
             if (curState > (int)AiStateId.Invalid && curState < (int)AiStateId.MaxNum)
             {
                 if (m_Handlers.ContainsKey(curState))
                 {
                     NpcAiStateHandler handler = m_Handlers[curState];
                     if (null != handler)
                     {
                         handler(npc, aiCmdDispatcher, deltaTime);
                     }
                 }
                 else
                 {
                     LogSystem.Error("Illegal ai state: " + curState + " npc:" + npc.GetId());
                 }
             }
             else
             {
                 OnStateLogicInit(npc, aiCmdDispatcher, deltaTime);
                 ChangeToState(npc, (int)AiStateId.Idle);
             }
         }
         ExecuteCommandQueue(npc, deltaTime);
     }
 }