示例#1
0
        public void SelectorNodeContinuesWithCurrentlyRunningNodeWithNextTick()
        {
            var model    = new MyModel();
            var sequence = new SelectorNode <MyModel>(new FailOnceNode(), new RunOnceAndSucceedNextNode());

            Assert.AreEqual(AivoTreeStatus.Running, sequence.Tick(1, model));
            Assert.AreEqual(AivoTreeStatus.Success, sequence.Tick(2, model));
        }
示例#2
0
        public void SelectorNodeSucceedSWithFirstSucceedingNode()
        {
            var model    = new MyModel();
            var sequence = new SelectorNode <MyModel>(new SucceedingNode(), new ShouldNotRunNode());

            Assert.AreEqual(AivoTreeStatus.Success, sequence.Tick(1, model));
        }
示例#3
0
        public void SelectorNodeFailsIfAllNodesFails()
        {
            var model    = new MyModel();
            var sequence = new SelectorNode <MyModel>(new FailingNode());

            Assert.AreEqual(AivoTreeStatus.Failure, sequence.Tick(1, model));
        }
示例#4
0
        public void runs_the_first_node_if_it_succeeds()
        {
            Init();

            var time = new MyTimeData();

            var mockChild1 = new Mock <IMyBehaviourTreeNode>();

            mockChild1
            .Setup(m => m.Tick(time))
            .Returns(MyBehaviourTreeStatus.Success);

            var mockChild2 = new Mock <IMyBehaviourTreeNode>();

            testObject.AddChild(mockChild1.Object);
            testObject.AddChild(mockChild2.Object);

            Assert.Equal(MyBehaviourTreeStatus.Success, testObject.Tick(time));

            mockChild1.Verify(m => m.Tick(time), Times.Once());
            mockChild2.Verify(m => m.Tick(time), Times.Never());
        }
示例#5
0
        Result AlwaysAs(Result res)
        {
            IContext ctx = new SimpleContext();

            Node root = new SelectorNode("Root", null, false);

            root.Children.Add(new AlwaysCmd(res));

            Console.WriteLine("BEGIN RUN: {0}", res);
            var ret = root.Tick(ctx);

            Console.WriteLine("END-RUN..: {0}", ret);
            return(ret);
        }
        public void Tick_AllChildrenFail_ReturnsFailure()
        {
            var blackboard = this.GetBlackboard();
            var children   = new INode <TestBlackboard>[]
            {
                new ActionNode <TestBlackboard>((TestBlackboard bb) =>
                {
                    return(NodeStatus.Failure);
                }),
                new ActionNode <TestBlackboard>((TestBlackboard bb) =>
                {
                    return(NodeStatus.Failure);
                }),
            };
            var sequenceNode = new SelectorNode <TestBlackboard>(children);

            Assert.AreEqual(NodeStatus.Failure, sequenceNode.Tick(blackboard));
        }
示例#7
0
 private void Update()
 {
     _rootNode.Tick();
 }
 // Update is called once per frame
 void Update()
 {
     rootNode.Tick();
 }