コード例 #1
0
ファイル: ActionManager.cs プロジェクト: 2d12/Roguelike
    public void EnqueueAction(ICharacterAction a)
    {
        a.SetStartingTick(currentTick);

        if (initiativeTracker == null)
        {
            initiativeTracker = new ActionTree(a);
        }
        else
        {
            initiativeTracker.EnqueueAction(a);
        }


        //PerformNextAction ();
    }
コード例 #2
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);
            }
        }
    }