Ejemplo n.º 1
0
    public ICharacterAction DequeueAction(ActionTree parent)
    {
        ICharacterAction rv;

        if (leftNode != null)
        {
            rv = leftNode.DequeueAction(this);
        }
        else
        {
            rv = root;
            if (parent != null)
            {
                // There should now be nothing to my left.  Remove myself from the equation,
                // and make my parent look to my right from now on.
                parent.leftNode = rightNode;
            }
            else if (rightNode != null)
            {
                // Replace self with minimum action of the right node, removing it in the process.
                root = rightNode.DequeueAction(null);
            }
            else
            {
                root = null; // IS THIS CORRECT?
            }
        }

        return(rv);
    }
Ejemplo 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());
     }
 }