Ejemplo n.º 1
0
        public override bool Process(BehaviorTree tree)
        {
            if (NextNode == null)
            {
                Debug.LogWarning("Root node finished processing as non-leaf node");
                return(true);
            }

            return(NextNode.Process(tree));
        }
Ejemplo n.º 2
0
        public override bool Process(BehaviorTree tree)
        {
            bool value = false;

            if (Logic != null)
            {
                value = Logic.Evaluate(tree.currentAI.localBlackboard);
            }

            if (value)
            {
                return(nodeOnTrue.Process(tree));
            }
            else
            {
                return(nodeOnFalse.Process(tree));
            }
        }
Ejemplo n.º 3
0
        public override bool Process(BehaviorTree tree)
        {
            if (!tree.currentAI.instanceSequencePositions.ContainsKey(this))
            {
                tree.currentAI.instanceSequencePositions.Add(this, 0);
                tree.QueueNode(this);
            }

            if (tree.currentAI.instanceSequencePositions[this] >= sequenceNodes.Length)
            {
                tree.currentAI.instanceSequencePositions[this] = 0;
                return(true);
            }

            Node nodeInSequence = sequenceNodes[tree.currentAI.instanceSequencePositions[this]];

            tree.currentAI.instanceSequencePositions[this]++;
            return(nodeInSequence.Process(tree));
        }
Ejemplo n.º 4
0
        public virtual void ProcessTree(AIController ai)
        {
            currentAI = ai;
            Node activeNode = ai.ActiveNode;

            if (activeNode == null)
            {
                activeNode = root;
            }

            if (activeNode.Process(this))
            {
                if (currentAI.NodesToProcess.Count > 0)
                {
                    if (currentAI.ActiveNode is Sequence)
                    {
                        currentAI.instanceSequencePositions.Remove(currentAI.ActiveNode as Sequence);
                    }
                    //Debug.Log("Popping " + currentAI.ActiveNode + " for " + currentAI);
                    currentAI.NodesToProcess.Pop();
                }
            }
            currentAI = null;
        }