Esempio n. 1
0
    public void EnqueueAction(ICharacterAction action)
    {
        // This case should only happen IF all other actions
        // have been dequeued.
        if (root == null)
        {
            root = action;
            return;
        }

        // NOTE: The = means that for actions completing on the same tick,
        // actions enqueued later wil complete first.  This makes sense because
        // those actions would logically be faster, so making them complete first
        // is consistent.

        if (action.GetCompletionTick() <= root.GetCompletionTick())
        {
            if (leftNode == null)
            {
                leftNode = new ActionTree(action);
            }
            else
            {
                leftNode.EnqueueAction(action);
            }
        }
        else
        {
            if (rightNode == null)
            {
                rightNode = new ActionTree(action);
            }
            else
            {
                rightNode.EnqueueAction(action);
            }
        }
    }
Esempio n. 2
0
 private void PerformNextAction()
 {
     if (initiativeTracker == null)
     {
         return;
     }
     else
     {
         waiting = false;
         ICharacterAction a = initiativeTracker.DequeueAction(null);
         if (a != null)
         {
             a.DoAction();
             currentTick = a.GetCompletionTick();
             if (!(a is PauseAction))
             {
                 Debug.Log("Action" + a.GetType() + " completed at tick " + currentTick);
             }
         }
         waiting = true;
         EnqueueAction(a.GetInitiatingAI().GetNextAction());
     }
 }