Ejemplo n.º 1
0
        public void Behaviour_Tree_Visits_All_Childrens_On_Tick()
        {
            MockBTNode node = new MockBTNode();

            SequenceNode seq1 = new SequenceNode(new List <BTNode> {
                node, node, node
            });
            SequenceNode seq2 = new SequenceNode(new List <BTNode> {
                node, node, node
            });
            SequenceNode root = new SequenceNode(new List <BTNode> {
                seq1, seq2
            });

            BehaviourTree tree = new BehaviourTree(root);

            tree.Start();

            for (int i = 0; i < 6; i++)
            {
                tree.Update();
                if (i < 5)
                {
                    Assert.IsTrue(tree.TreeState == NodeState.Running);
                }
            }

            Assert.IsTrue(node.started == 6);
            Assert.IsTrue(tree.TreeState == NodeState.Success);
        }
Ejemplo n.º 2
0
        public void Behaviour_Tree_Node_Triggers_All_Events()
        {
            MockBTNode node = new MockBTNode();

            node.Update();

            Assert.IsTrue(node.State == NodeState.Success);
            Assert.IsTrue(node.finished == 1 && node.started == 1);
        }
Ejemplo n.º 3
0
        public void Behaviour_Tree_Node_Correctly_Restarts_After_Finish()
        {
            MockBTNode node = new MockBTNode();

            node.Update();
            Assert.IsTrue(node.State == NodeState.Success);

            node.Update();
            Assert.IsTrue(node.State == NodeState.Success);
            Assert.IsTrue(node.finished == 2 && node.started == 2);
        }