Exemplo n.º 1
0
    private void CreateBehaviourTree()
    {
        behaviourTree = new BehaviourTreeEngine(false);

        rootSequence  = behaviourTree.CreateSequenceNode("Root", false);
        selectorDoor  = behaviourTree.CreateSelectorNode("Selector door");
        sequenceDoor  = behaviourTree.CreateSequenceNode("Sequence door", false);
        walkToDoor1   = behaviourTree.CreateLeafNode("Walk to door 1", WalkToDoor, ArriveToDoor);
        walkToDoor2   = behaviourTree.CreateLeafNode("Walk to door 2", WalkToDoor, ArriveToDoor);
        enterTheHouse = behaviourTree.CreateLeafNode("Enter the house", EnterTheHouse, HasEnteredTheHouse);
        openDoor1     = behaviourTree.CreateLeafNode("Open the door 1", OpenDoor, DoorOpened);
        openDoor2     = behaviourTree.CreateLeafNode("Open the door 2", OpenDoor, DoorOpened);
        unlockDoor    = behaviourTree.CreateLeafNode("Find key", UnlockDoor, IsTheDoorUnlocked);
        smashDoor     = behaviourTree.CreateLeafNode("Explode door", SmashDoor, DoorSmashed);

        rootSequence.AddChild(walkToDoor1);
        rootSequence.AddChild(selectorDoor);
        rootSequence.AddChild(enterTheHouse);

        selectorDoor.AddChild(openDoor1);
        selectorDoor.AddChild(sequenceDoor);
        selectorDoor.AddChild(smashDoor);

        sequenceDoor.AddChild(unlockDoor);
        sequenceDoor.AddChild(walkToDoor2);
        sequenceDoor.AddChild(openDoor2);

        behaviourTree.SetRootNode(rootSequence);
    }
Exemplo n.º 2
0
        public static void LoadChildren(SequenceNode root, YamlSequenceNode sequence)
        {
            foreach (var child in sequence.Children)
            {
                if (child is YamlSequenceNode)
                {
                    var node = root.AddChild(new SequenceNode(root.Value, child, ImageLoad.GetImageIndex(child), id, root));
                    id++;
                    LoadChildren(node as SequenceNode, child as YamlSequenceNode);
                }
                else if (child is YamlMappingNode)
                {
                    var teste = child as YamlMappingNode;
                    var node  = root.AddChild(new MappingNode(root.Value, child, ImageLoad.GetImageIndex(child), id, root));
                    id++;

                    LoadChildren(node as MappingNode, child as YamlMappingNode);
                }
                else if (child is YamlScalarNode)
                {
                    var scalar = child as YamlScalarNode;
                    var node   = root.AddChild(new ScalarNode(scalar.Value, child, scalar.Tag, ImageLoad.GetImageIndex(child), id, root));
                    id++;
                }
            }
        }
Exemplo n.º 3
0
        public void tableData()
        {
            MappingNode  map = new MappingNode();
            SequenceNode sec = new SequenceNode();

            ComponentName = textBox1.Text;

            //INode nodeFound = editor.mapNode.searchNodeByName(ComponentName);
            INode nodeFound = editor.nodeSelected;

            if (nodeFound != null)
            {
                if (nodeFound == editor.mapNode)
                {
                    map = new MappingNode(ComponentName, LoadTree.id++);
                    getPropertiesFromWizard(map, dataGridView1);
                    editor.mapNode.AddChild(map);
                }
                else if (nodeFound.Value != ComponentName)
                {
                    map = new MappingNode(ComponentName, null, 4, LoadTree.id++, editor.nodeSelected);
                    getPropertiesFromWizard(map, dataGridView1);
                    editor.nodeSelected.AddChild(map);
                }
                else if (nodeFound is MappingNode)
                {
                    if (ComponentName == nodeFound.Value && nodeFound.getParent() is SequenceNode)
                    {
                        MessageBox.Show("Can not add a new component with this name to this component", "Invalid operation",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    map = (MappingNode)nodeFound;
                    MappingNode tempMap = map.DeepClone();
                    map.RemoveNode(map);

                    sec = new SequenceNode(tempMap.Value, tempMap.Tag, 3, LoadTree.id++, tempMap.parent);

                    MappingNode mapAntigo = tempMap;
                    mapAntigo.id = LoadTree.id++;
                    sec.AddChild(mapAntigo);

                    MappingNode newMap = new MappingNode(ComponentName, null, 4, LoadTree.id++, sec);
                    sec.AddChild(newMap);

                    getPropertiesFromWizard(newMap, dataGridView1);
                    editor.nodeSelected.getParent().AddChild(sec);
                }
                else if (nodeFound is SequenceNode)
                {
                    map = new MappingNode(ComponentName, null, 4, LoadTree.id++, editor.nodeSelected);
                    editor.nodeSelected.AddChild(map);
                    getPropertiesFromWizard(map, dataGridView1);
                }
            }


            //editor.mapNode.SearchNode(mapping);
        }
Exemplo n.º 4
0
    /// <summary>
    /// 顺序节点测试
    /// </summary>
    private void SequenceNodeText()
    {
        SequenceNode sequenceNode = new SequenceNode();

        sequenceNode.AddChild(move);
        sequenceNode.AddChild(idel);
        Debug.Log("顺序节点执行结果为:" + sequenceNode.DoAction());
    }
        public void redoes_conditions_when_continuing_to_running_node()
        {
            testObject = new SequenceNode("some-sequence", 0, false);

            var time = new TimeData(0);

            //Condition 1
            var mockChild1 = new Mock <BehaviourTreeNode>();

            mockChild1.Object.IsCondition = true;
            mockChild1
            .Setup(node => node.Tick(time))
            .Returns(Status.Success);

            var mockChild5 = new Mock <BehaviourTreeNode>();

            mockChild5
            .Setup(node => node.Tick(time))
            .Returns(Status.Success);

            //Condition 2
            var mockChild2 = new Mock <BehaviourTreeNode>();

            mockChild2.Object.IsCondition = true;
            mockChild2
            .Setup(m => m.Tick(time))
            .Returns(Status.Success);

            var mockChild3 = new Mock <BehaviourTreeNode>();

            mockChild3
            .SetupSequence(node => node.Tick(time))
            .Returns(Status.Running)
            .Returns(Status.Success);

            var mockChild4 = new Mock <BehaviourTreeNode>();

            mockChild4
            .Setup(m => m.Tick(time))
            .Returns(Status.Success);

            testObject.AddChild(mockChild1.Object);
            testObject.AddChild(mockChild2.Object);
            testObject.AddChild(mockChild3.Object);
            testObject.AddChild(mockChild4.Object);
            testObject.AddChild(mockChild5.Object);

            Assert.Equal(Status.Running, testObject.Tick(time));
            Assert.Equal(Status.Success, testObject.Tick(time));

            mockChild1.Verify(m => m.Tick(time), Times.Exactly(2));
            mockChild2.Verify(m => m.Tick(time), Times.Exactly(2));
            mockChild3.Verify(m => m.Tick(time), Times.Exactly(2));
            mockChild4.Verify(m => m.Tick(time), Times.Once());
            mockChild5.Verify(m => m.Tick(time), Times.Once());
        }
Exemplo n.º 6
0
        private void BuildFirstLevel(SequenceNode root)
        {
            LogMessageNode debugLogToContent1 = new LogMessageNode("logMessageSuccess0000", tree,
                                                                   tree.unit, "Log Node", BehaviorNodeState.Success);

            HasFollowLanceTargetNode hasFollowLanceTarget = new HasFollowLanceTargetNode("hasFollowLanceTarget0000", tree, tree.unit);
            MoveToFollowLanceNode    moveToFollowLance    = new MoveToFollowLanceNode("moveToFollowLance0000", tree, tree.unit, false);

            root.AddChild(debugLogToContent1);
            root.AddChild(hasFollowLanceTarget);
            root.AddChild(moveToFollowLance);
        }
Exemplo n.º 7
0
    private void CreateBehaviourTree()
    {
        //LeafNode lookRecipe = behaviourTree.CreateLeafNode("Look recipe", CreateRecipe, IsRecipeCreated);
        LeafNode     bake      = behaviourTree.CreateLeafNode("Bake pizza", BakePizza, IsPizzaBaked);
        SequenceNode makePizza = behaviourTree.CreateSequenceNode("Make a pizza", false);

        makePizza.AddChild(lookRecipe);
        makePizza.AddChild(subFSM);
        makePizza.AddChild(bake);
        LoopDecoratorNode loopNode = behaviourTree.CreateLoopNode("Loop root", makePizza);

        behaviourTree.SetRootNode(loopNode);
    }
Exemplo n.º 8
0
        void SetUpBehaviorTree()
        {
            SequenceNode rootSequence = new SequenceNode("Root");

            behaviorTree.AddRoot(rootSequence);

            InverterNode isDeadInverter = new InverterNode();

            rootSequence.AddChild(isDeadInverter);

            ConditionalNode isDead = new DeathCondition <Miner>(this);

            isDeadInverter.AddChild(isDead);

            SelectorNode mainSelector = new SelectorNode("Main");

            rootSequence.AddChild(mainSelector);

            SequenceNode miningSequence = new SequenceNode("Mining");

            mainSelector.AddChild(miningSequence);

            SequenceNode depositingSequence = new SequenceNode("Depositing");

            mainSelector.AddChild(depositingSequence);

            InverterNode isBagFullInverter = new InverterNode();

            miningSequence.AddChild(isBagFullInverter);

            ConditionalNode isBagFull = new BagFullCondition <Miner>(this);

            isBagFullInverter.AddChild(isBagFull);

            LeafNode walkToMine = new WalkToAction <Miner>(this, targetMiningPoint.position, targetMiningPoint.gameObject.name);

            miningSequence.AddChild(walkToMine);

            LeafNode mine = new MineAction <Miner>(this, mineIntervals, resourceMinedPerInterval);

            miningSequence.AddChild(mine);

            LeafNode walkToBase = new WalkToAction <Miner>(this, targetDeployPoint.position, targetDeployPoint.gameObject.name);

            depositingSequence.AddChild(walkToBase);

            LeafNode deposit = new DepositAction <Miner>(this, depositDuration);

            depositingSequence.AddChild(deposit);
        }
Exemplo n.º 9
0
            public MockBehaviourTreeDFS() : base()
            {
                SequenceNode seq1 = new SequenceNode();
                SequenceNode seq2 = new SequenceNode();

                for (int i = 0; i < 4; i++)
                {
                    seq1.AddChild(Substitute.For <BTNode>());
                }

                for (int i = 0; i < 4; i++)
                {
                    seq2.AddChild(Substitute.For <BTNode>());
                }

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

                SetRoot(root);

                PerformDFS(x => {
                    if (x == seq1)
                    {
                        result = 1;
                    }
                    if (x == seq2)
                    {
                        result = 2;
                    }
                });
            }
Exemplo n.º 10
0
        public void Sequence_Node_Succeds_When_All_Childs_Succeeds(int childsCount)
        {
            SequenceNode seq = new SequenceNode();

            for (int i = 0; i < childsCount; i++)
            {
                var mock = Substitute.For <BTNode>();
                mock.Update().Returns(NodeState.Success);
                seq.AddChild(mock);
            }

            if (childsCount == 0)
            {
                Assert.IsTrue(seq.Update() == NodeState.Success);
            }
            else
            {
                for (int i = 0; i < childsCount; i++)
                {
                    if (i == childsCount - 1)
                    {
                        Assert.IsTrue(seq.Update() == NodeState.Success);
                    }
                    else
                    {
                        Assert.IsTrue(seq.Update() == NodeState.Running);
                    }
                }
            }
        }
Exemplo n.º 11
0
    private void CreateBehaviourTree()
    {
        behaviourTree = new BehaviourTreeEngine(true);

        LeafNode     toKey        = behaviourTree.CreateLeafNode("To key", GoToKey, ArriveToKey);
        LeafNode     getKey       = behaviourTree.CreateLeafNode("Get key", GetKey, KeyTaken);
        LeafNode     backToDoor   = behaviourTree.CreateLeafNode("Back to door", ToDoor, ArriveToDoor);
        LeafNode     openDoor     = behaviourTree.CreateLeafNode("Open door", OpenDoor, DoorOpened);
        SequenceNode sequenceRoot = behaviourTree.CreateSequenceNode("Sequence root", false);

        sequenceRoot.AddChild(toKey);
        sequenceRoot.AddChild(getKey);
        sequenceRoot.AddChild(backToDoor);
        sequenceRoot.AddChild(openDoor);

        behaviourTree.SetRootNode(sequenceRoot);
    }
Exemplo n.º 12
0
        public void Sequence_Node_Stays_Running_When_A_Child_Is_Running()
        {
            var mock = Substitute.For <BTNode>();

            mock.Update().Returns(NodeState.Running);

            SequenceNode seq = new SequenceNode();

            seq.AddChild(mock);

            Assert.IsTrue(seq.Update() == NodeState.Running);
        }
Exemplo n.º 13
0
    private void CreateBehaviourTree()
    {
        behaviourTree = new BehaviourTreeEngine(false);

        LeafNode           throwRod       = behaviourTree.CreateLeafNode("Throw rod", ThrowRod, RodThrown);
        LeafNode           catchSomething = behaviourTree.CreateLeafNode("Catch something", Catch, SomethingCatched);
        LeafNode           returnToWater  = behaviourTree.CreateLeafNode("Return to water", () => Invoke("ReturnToWater", 2), ReturnedToWater);
        LeafNode           storeInBasket  = behaviourTree.CreateLeafNode("Store in the basket", () => Invoke("StoreBasket", 2), StoredInBasket);
        TimerDecoratorNode timerNode      = behaviourTree.CreateTimerNode("Timer node", catchSomething, 3);
        SelectorNode       selectorNode   = behaviourTree.CreateSelectorNode("Selector node");

        selectorNode.AddChild(returnToWater);
        selectorNode.AddChild(storeInBasket);
        SequenceNode sequenceNode = behaviourTree.CreateSequenceNode("Sequence node", false);

        sequenceNode.AddChild(throwRod);
        sequenceNode.AddChild(timerNode);
        sequenceNode.AddChild(selectorNode);
        LoopDecoratorNode rootNode = behaviourTree.CreateLoopNode("Root node", sequenceNode);

        behaviourTree.SetRootNode(rootNode);
    }
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit);

        FindPlayerTutorialTargetNode findPlayerTutorialTarget0000 = new FindPlayerTutorialTargetNode("findPlayerTutorialTarget0000", behaviorTree, unit);

        ShootTrainingWeaponsAtTargetNode shootTrainingWeaponsAtTarget0000 = new ShootTrainingWeaponsAtTargetNode("shootTrainingWeaponsAtTarget0000", behaviorTree, unit);

        SequenceNode attack_sequence = new SequenceNode("attack_sequence", behaviorTree, unit);

        attack_sequence.AddChild(attackAvailable0000);
        attack_sequence.AddChild(findPlayerTutorialTarget0000);
        attack_sequence.AddChild(shootTrainingWeaponsAtTarget0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit);

        selector0000.AddChild(attack_sequence);
        selector0000.AddChild(brace0000);

        return(selector0000);
    }
Exemplo n.º 15
0
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit);

        LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit);

        LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit);

        SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit);

        selector0000.AddChild(lanceHasStartedRoute0000);
        selector0000.AddChild(lanceStartRoute0000);

        LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit);

        InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit);

        inverter0000.AddChild(lanceHasCompletedRoute0000);

        MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit);

        SequenceNode incrementally_patrol = new SequenceNode("incrementally_patrol", behaviorTree, unit);

        incrementally_patrol.AddChild(unitHasRoute0000);
        incrementally_patrol.AddChild(selector0000);
        incrementally_patrol.AddChild(inverter0000);
        incrementally_patrol.AddChild(moveAlongRoute0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode route_AI_root = new SelectorNode("route_AI_root", behaviorTree, unit);

        route_AI_root.AddChild(incrementally_patrol);
        route_AI_root.AddChild(brace0000);

        return(route_AI_root);
    }
Exemplo n.º 16
0
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        LanceDetectsEnemiesNode lanceDetectsEnemies0000 = new LanceDetectsEnemiesNode("lanceDetectsEnemies0000", behaviorTree, unit);

        FindDetectedEnemiesNode findDetectedEnemies0000 = new FindDetectedEnemiesNode("findDetectedEnemies0000", behaviorTree, unit);

        IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit);

        BlockUntilPathfindingReadyNode blockUntilPathfindingReady0000 = new BlockUntilPathfindingReadyNode("blockUntilPathfindingReady0000", behaviorTree, unit);

        ClearMoveCandidatesNode clearMoveCandidates0000 = new ClearMoveCandidatesNode("clearMoveCandidates0000", behaviorTree, unit);

        GenerateMoveCandidatesNode generateMoveCandidates0000 = new GenerateMoveCandidatesNode("generateMoveCandidates0000", behaviorTree, unit);

        SortMoveCandidatesByDecreasingDistanceToHostilesNode sortMoveCandidatesByDecreasingDistanceToHostiles0000 = new SortMoveCandidatesByDecreasingDistanceToHostilesNode("sortMoveCandidatesByDecreasingDistanceToHostiles0000", behaviorTree, unit);

        FilterMoveCandidatesByLowestLOSToHostilesNode filterMoveCandidatesByLowestLOSToHostiles0000 = new FilterMoveCandidatesByLowestLOSToHostilesNode("filterMoveCandidatesByLowestLOSToHostiles0000", behaviorTree, unit);

        MoveTowardsHighestPriorityMoveCandidateNode moveTowardsHighestPriorityMoveCandidate0000 = new MoveTowardsHighestPriorityMoveCandidateNode("moveTowardsHighestPriorityMoveCandidate0000", behaviorTree, unit, false);

        SequenceNode run_away = new SequenceNode("run_away", behaviorTree, unit);

        run_away.AddChild(lanceDetectsEnemies0000);
        run_away.AddChild(findDetectedEnemies0000);
        run_away.AddChild(movementAvailable0000);
        run_away.AddChild(blockUntilPathfindingReady0000);
        run_away.AddChild(clearMoveCandidates0000);
        run_away.AddChild(generateMoveCandidates0000);
        run_away.AddChild(sortMoveCandidatesByDecreasingDistanceToHostiles0000);
        run_away.AddChild(filterMoveCandidatesByLowestLOSToHostiles0000);
        run_away.AddChild(moveTowardsHighestPriorityMoveCandidate0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode flee_AI_root = new SelectorNode("flee_AI_root", behaviorTree, unit);

        flee_AI_root.AddChild(run_away);
        flee_AI_root.AddChild(brace0000);

        return(flee_AI_root);
    }
Exemplo n.º 17
0
        public void Behaviour_Tree_Properly_Sets_All_Children_Blackboard_On_Start()
        {
            List <BTNode> allNodes = new List <BTNode>();

            SequenceNode seq1 = new SequenceNode();
            SequenceNode seq2 = new SequenceNode();

            for (int i = 0; i < 4; i++)
            {
                BTNode mock = Substitute.For <BTNode>();
                seq1.AddChild(mock);
                allNodes.Add(mock);
            }

            for (int i = 0; i < 4; i++)
            {
                BTNode mock = Substitute.For <BTNode>();
                seq2.AddChild(mock);
                allNodes.Add(mock);
            }

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

            allNodes.Add(seq1);
            allNodes.Add(seq2);
            allNodes.Add(root);

            BehaviourTree tree = new BehaviourTree(root);

            tree.Start();

            bool allShareSameBB = true;

            foreach (var node in allNodes)
            {
                if (node.Blackboard != tree.Blackboard)
                {
                    allShareSameBB = false;
                    break;
                }
            }

            Assert.IsTrue(allShareSameBB);
        }
Exemplo n.º 18
0
        public void can_run_all_children_in_order()
        {
            Init();

            var time = new TimeData();

            var callOrder = 0;

            var mockChild1 = new Mock <IBehaviourTreeNode <TimeData> >();

            mockChild1
            .Setup(m => m.Tick(time))
            .Returns(BehaviourTreeStatus.Success)
            .Callback(() =>
            {
                Assert.Equal(1, ++callOrder);
            });

            var mockChild2 = new Mock <IBehaviourTreeNode <TimeData> >();

            mockChild2
            .Setup(m => m.Tick(time))
            .Returns(BehaviourTreeStatus.Success)
            .Callback(() =>
            {
                Assert.Equal(2, ++callOrder);
            });

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

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

            Assert.Equal(2, callOrder);

            mockChild1.Verify(m => m.Tick(time), Times.Once());
            mockChild2.Verify(m => m.Tick(time), Times.Once());
        }
Exemplo n.º 19
0
        public void Sequence_Node_Fails_If_One_Child_Fails(int childsCount, int failsAtIdx)
        {
            SequenceNode seq = new SequenceNode();

            for (int i = 0; i < childsCount; i++)
            {
                var mock = Substitute.For <BTNode>();
                mock.Update().Returns(i == failsAtIdx ? NodeState.Failure : NodeState.Success);
                seq.AddChild(mock);
            }

            for (int i = 0; i <= failsAtIdx; i++)
            {
                if (i == failsAtIdx)
                {
                    Assert.IsTrue(seq.Update() == NodeState.Failure);
                }
                else
                {
                    Assert.IsTrue(seq.Update() == NodeState.Running);
                }
            }
        }
Exemplo n.º 20
0
        public void Sequence_Properly_Resets_After_Finishing(NodeState finishState)
        {
            SequenceNode seq       = new SequenceNode();
            int          finishIdx = finishState == NodeState.Success ? 2 : 1;

            for (int i = 0; i < 3; i++)
            {
                var mock = Substitute.For <BTNode>();
                mock.Update().Returns(i == finishIdx ? finishState : NodeState.Success);
                seq.AddChild(mock);
            }

            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i <= finishIdx; i++)
                {
                    var expected = i == finishIdx ? finishState : NodeState.Running;

                    var update = seq.Update();
                    Assert.IsTrue(update == expected);
                }
            }
        }
Exemplo n.º 21
0
    private void CreateBehaviourTree()
    {
        behaviourTree = new BehaviourTreeEngine(false);

        LeafNode     toPoint1      = behaviourTree.CreateLeafNode("To point 1", () => ToPoint(routePoints[0]), () => ArrivedToPoint(routePoints[0]));
        LeafNode     toPoint2      = behaviourTree.CreateLeafNode("To point 2", () => ToPoint(routePoints[1]), () => ArrivedToPoint(routePoints[1]));
        LeafNode     toPoint3      = behaviourTree.CreateLeafNode("To point 3", () => ToPoint(routePoints[2]), () => ArrivedToPoint(routePoints[2]));
        LeafNode     toPoint4      = behaviourTree.CreateLeafNode("To point 4", () => ToPoint(routePoints[3]), () => ArrivedToPoint(routePoints[3]));
        LeafNode     toPoint5      = behaviourTree.CreateLeafNode("To point 5", () => ToPoint(routePoints[4]), () => ArrivedToPoint(routePoints[4]));
        LeafNode     toPoint6      = behaviourTree.CreateLeafNode("To point 6", () => ToPoint(routePoints[5]), () => ArrivedToPoint(routePoints[5]));
        SequenceNode sequenceRoute = behaviourTree.CreateSequenceNode("Route", false);

        sequenceRoute.AddChild(toPoint1);
        sequenceRoute.AddChild(toPoint2);
        sequenceRoute.AddChild(toPoint3);
        sequenceRoute.AddChild(toPoint4);
        sequenceRoute.AddChild(toPoint5);
        sequenceRoute.AddChild(toPoint6);
        LoopDecoratorNode loopNode = behaviourTree.CreateLoopNode("Loop root", sequenceRoute);

        behaviourTree.SetRootNode(loopNode);
    }
Exemplo n.º 22
0
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        IsShutDownNode isShutdown0000 = new IsShutDownNode("isShutdown0000", behaviorTree, unit);

        MechStartUpNode mechStartUp0000 = new MechStartUpNode("mechStartUp0000", behaviorTree, unit);

        SequenceNode if_shutdown__restart = new SequenceNode("if_shutdown__restart", behaviorTree, unit);

        if_shutdown__restart.AddChild(isShutdown0000);
        if_shutdown__restart.AddChild(mechStartUp0000);

        IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit);

        IsProneNode isProne0000 = new IsProneNode("isProne0000", behaviorTree, unit);

        StandNode stand0000 = new StandNode("stand0000", behaviorTree, unit);

        SequenceNode if_prone__stand_up = new SequenceNode("if_prone__stand_up", behaviorTree, unit);

        if_prone__stand_up.AddChild(movementAvailable0000);
        if_prone__stand_up.AddChild(isProne0000);
        if_prone__stand_up.AddChild(stand0000);

        IsMovementAvailableForUnitNode movementAvailable0001 = new IsMovementAvailableForUnitNode("movementAvailable0001", behaviorTree, unit);

        UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit);

        LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit);

        LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit);

        SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit);

        selector0000.AddChild(lanceHasStartedRoute0000);
        selector0000.AddChild(lanceStartRoute0000);

        LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit);

        InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit);

        inverter0000.AddChild(lanceHasCompletedRoute0000);

        MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit);

        SequenceNode patrol_opportunistic_shoot = new SequenceNode("patrol_opportunistic_shoot", behaviorTree, unit);

        patrol_opportunistic_shoot.AddChild(movementAvailable0001);
        patrol_opportunistic_shoot.AddChild(unitHasRoute0000);
        patrol_opportunistic_shoot.AddChild(selector0000);
        patrol_opportunistic_shoot.AddChild(inverter0000);
        patrol_opportunistic_shoot.AddChild(moveAlongRoute0000);

        LanceDetectsEnemiesNode lanceDetectsEnemies0000 = new LanceDetectsEnemiesNode("lanceDetectsEnemies0000", behaviorTree, unit);

        FindDetectedEnemiesNode findDetectedEnemies0000 = new FindDetectedEnemiesNode("findDetectedEnemies0000", behaviorTree, unit);

        IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit);

        SortEnemiesByThreatNode sortEnemiesByThreat0000 = new SortEnemiesByThreatNode("sortEnemiesByThreat0000", behaviorTree, unit);

        UseNormalToHitThreshold useNormalToHitThreshold0000 = new UseNormalToHitThreshold("useNormalToHitThreshold0000", behaviorTree, unit);

        WasTargetedRecentlyNode wasTargetedRecently0000 = new WasTargetedRecentlyNode("wasTargetedRecently0000", behaviorTree, unit);

        InverterNode inverter0001 = new InverterNode("inverter0001", behaviorTree, unit);

        inverter0001.AddChild(wasTargetedRecently0000);

        RandomPercentageLessThanBVNode randomPercentageLessThanBV0000 = new RandomPercentageLessThanBVNode("randomPercentageLessThanBV0000", behaviorTree, unit, BehaviorVariableName.Float_PriorityAttackPercentage);

        SortEnemiesByPriorityListNode sortEnemiesByPriorityList0000 = new SortEnemiesByPriorityListNode("sortEnemiesByPriorityList0000", behaviorTree, unit);

        SequenceNode sequence0000 = new SequenceNode("sequence0000", behaviorTree, unit);

        sequence0000.AddChild(inverter0001);
        sequence0000.AddChild(randomPercentageLessThanBV0000);
        sequence0000.AddChild(sortEnemiesByPriorityList0000);

        MaybeFilterOutPriorityTargetsNode maybeFilterOutPriorityTargets0000 = new MaybeFilterOutPriorityTargetsNode("maybeFilterOutPriorityTargets0000", behaviorTree, unit);

        FilterKeepingRecentAttackersNode filterKeepingRecentAttackers0000 = new FilterKeepingRecentAttackersNode("filterKeepingRecentAttackers0000", behaviorTree, unit);

        SequenceNode sequence0001 = new SequenceNode("sequence0001", behaviorTree, unit);

        sequence0001.AddChild(maybeFilterOutPriorityTargets0000);
        sequence0001.AddChild(filterKeepingRecentAttackers0000);

        SucceedNode succeed0000 = new SucceedNode("succeed0000", behaviorTree, unit);

        SelectorNode priorityAttack = new SelectorNode("priorityAttack", behaviorTree, unit);

        priorityAttack.AddChild(sequence0000);
        priorityAttack.AddChild(sequence0001);
        priorityAttack.AddChild(succeed0000);

        ShootAtHighestPriorityEnemyNode shootAtHighestPriorityEnemy0000 = new ShootAtHighestPriorityEnemyNode("shootAtHighestPriorityEnemy0000", behaviorTree, unit);

        SequenceNode opportunity_fire = new SequenceNode("opportunity_fire", behaviorTree, unit);

        opportunity_fire.AddChild(lanceDetectsEnemies0000);
        opportunity_fire.AddChild(findDetectedEnemies0000);
        opportunity_fire.AddChild(attackAvailable0000);
        opportunity_fire.AddChild(sortEnemiesByThreat0000);
        opportunity_fire.AddChild(useNormalToHitThreshold0000);
        opportunity_fire.AddChild(priorityAttack);
        opportunity_fire.AddChild(shootAtHighestPriorityEnemy0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode patrol_With_Opportunistic_Shooting_AI_root = new SelectorNode("patrol_With_Opportunistic_Shooting_AI_root", behaviorTree, unit);

        patrol_With_Opportunistic_Shooting_AI_root.AddChild(if_shutdown__restart);
        patrol_With_Opportunistic_Shooting_AI_root.AddChild(if_prone__stand_up);
        patrol_With_Opportunistic_Shooting_AI_root.AddChild(patrol_opportunistic_shoot);
        patrol_With_Opportunistic_Shooting_AI_root.AddChild(opportunity_fire);
        patrol_With_Opportunistic_Shooting_AI_root.AddChild(brace0000);

        return(patrol_With_Opportunistic_Shooting_AI_root);
    }
Exemplo n.º 23
0
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        LanceHasLOSNode lanceHasLOS0000 = new LanceHasLOSNode("lanceHasLOS0000", behaviorTree, unit);

        FindVisibleEnemiesNode findVisibleEnemies0000 = new FindVisibleEnemiesNode("findVisibleEnemies0000", behaviorTree, unit);

        IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit);

        SortEnemiesByThreatNode sortEnemiesByThreat0000 = new SortEnemiesByThreatNode("sortEnemiesByThreat0000", behaviorTree, unit);

        MoveTowardsHighestPriorityEnemyNode moveTowardsHighestPriorityEnemy0000 = new MoveTowardsHighestPriorityEnemyNode("moveTowardsHighestPriorityEnemy0000", behaviorTree, unit);

        SequenceNode canMove = new SequenceNode("canMove", behaviorTree, unit);

        canMove.AddChild(movementAvailable0000);
        canMove.AddChild(sortEnemiesByThreat0000);
        canMove.AddChild(moveTowardsHighestPriorityEnemy0000);

        IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit);

        SortEnemiesByEffectivenessNode sortEnemiesByEffectiveness0000 = new SortEnemiesByEffectivenessNode("sortEnemiesByEffectiveness0000", behaviorTree, unit);

        ShootAtHighestPriorityEnemyNode shootAtHighestPriorityEnemy0000 = new ShootAtHighestPriorityEnemyNode("shootAtHighestPriorityEnemy0000", behaviorTree, unit);

        SequenceNode canAttack = new SequenceNode("canAttack", behaviorTree, unit);

        canAttack.AddChild(attackAvailable0000);
        canAttack.AddChild(sortEnemiesByEffectiveness0000);
        canAttack.AddChild(shootAtHighestPriorityEnemy0000);

        SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit);

        selector0000.AddChild(canMove);
        selector0000.AddChild(canAttack);

        SequenceNode free_engage = new SequenceNode("free_engage", behaviorTree, unit);

        free_engage.AddChild(lanceHasLOS0000);
        free_engage.AddChild(findVisibleEnemies0000);
        free_engage.AddChild(selector0000);

        IsMovementAvailableForUnitNode movementAvailable0001 = new IsMovementAvailableForUnitNode("movementAvailable0001", behaviorTree, unit);

        FindPreviouslySeenEnemiesNode findPreviouslySeenEnemies0000 = new FindPreviouslySeenEnemiesNode("findPreviouslySeenEnemies0000", behaviorTree, unit);

        SortEnemiesByProximityNode sortEnemiesByProximity0000 = new SortEnemiesByProximityNode("sortEnemiesByProximity0000", behaviorTree, unit);

        MoveTowardsHighestPriorityEnemyNode moveTowardsHighestPriorityEnemy0001 = new MoveTowardsHighestPriorityEnemyNode("moveTowardsHighestPriorityEnemy0001", behaviorTree, unit);

        SequenceNode hunt_previously_seen = new SequenceNode("hunt_previously_seen", behaviorTree, unit);

        hunt_previously_seen.AddChild(movementAvailable0001);
        hunt_previously_seen.AddChild(findPreviouslySeenEnemies0000);
        hunt_previously_seen.AddChild(sortEnemiesByProximity0000);
        hunt_previously_seen.AddChild(moveTowardsHighestPriorityEnemy0001);

        SelectorNode selector0001 = new SelectorNode("selector0001", behaviorTree, unit);

        selector0001.AddChild(hunt_previously_seen);

        FailNode fail0000 = new FailNode("fail0000", behaviorTree, unit);

        SelectorNode patrol = new SelectorNode("patrol", behaviorTree, unit);

        patrol.AddChild(fail0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode dumb_AI_root = new SelectorNode("dumb_AI_root", behaviorTree, unit);

        dumb_AI_root.AddChild(free_engage);
        dumb_AI_root.AddChild(selector0001);
        dumb_AI_root.AddChild(patrol);
        dumb_AI_root.AddChild(brace0000);

        return(dumb_AI_root);
    }
Exemplo n.º 24
0
    public static BehaviorNode InitRootNode(BehaviorTree behaviorTree, AbstractActor unit, GameInstance game)
    {
        IsShutDownNode isShutdown0000 = new IsShutDownNode("isShutdown0000", behaviorTree, unit);

        MechStartUpNode mechStartUp0000 = new MechStartUpNode("mechStartUp0000", behaviorTree, unit);

        SequenceNode if_shutdown__restart = new SequenceNode("if_shutdown__restart", behaviorTree, unit);

        if_shutdown__restart.AddChild(isShutdown0000);
        if_shutdown__restart.AddChild(mechStartUp0000);

        IsMovementAvailableForUnitNode movementAvailable0000 = new IsMovementAvailableForUnitNode("movementAvailable0000", behaviorTree, unit);

        IsProneNode isProne0000 = new IsProneNode("isProne0000", behaviorTree, unit);

        StandNode stand0000 = new StandNode("stand0000", behaviorTree, unit);

        SequenceNode if_prone__stand_up = new SequenceNode("if_prone__stand_up", behaviorTree, unit);

        if_prone__stand_up.AddChild(movementAvailable0000);
        if_prone__stand_up.AddChild(isProne0000);
        if_prone__stand_up.AddChild(stand0000);

        IsMovementAvailableForUnitNode movementAvailable0001 = new IsMovementAvailableForUnitNode("movementAvailable0001", behaviorTree, unit);

        HasSensorLockAbilityNode hasSensorLockAbility0000 = new HasSensorLockAbilityNode("hasSensorLockAbility0000", behaviorTree, unit);

        HasSensorLockTargetNode hasSensorLockTarget0000 = new HasSensorLockTargetNode("hasSensorLockTarget0000", behaviorTree, unit);

        SortEnemiesBySensorLockQualityNode sortEnemiesBySensorLockQuality0000 = new SortEnemiesBySensorLockQualityNode("sortEnemiesBySensorLockQuality0000", behaviorTree, unit);

        RecordHighestPriorityEnemyAsSensorLockTargetNode recordHighestPriorityEnemyAsSensorLockTarget0000 = new RecordHighestPriorityEnemyAsSensorLockTargetNode("recordHighestPriorityEnemyAsSensorLockTarget0000", behaviorTree, unit);

        SequenceNode sensor_lock_success = new SequenceNode("sensor_lock_success", behaviorTree, unit);

        sensor_lock_success.AddChild(hasSensorLockAbility0000);
        sensor_lock_success.AddChild(hasSensorLockTarget0000);
        sensor_lock_success.AddChild(sortEnemiesBySensorLockQuality0000);
        sensor_lock_success.AddChild(recordHighestPriorityEnemyAsSensorLockTarget0000);

        ClearSensorLockNode clearSensorLock0000 = new ClearSensorLockNode("clearSensorLock0000", behaviorTree, unit);

        SelectorNode selector0000 = new SelectorNode("selector0000", behaviorTree, unit);

        selector0000.AddChild(sensor_lock_success);
        selector0000.AddChild(clearSensorLock0000);

        SequenceNode evalSensorLock = new SequenceNode("evalSensorLock", behaviorTree, unit);

        evalSensorLock.AddChild(selector0000);

        SuccessDecoratorNode maybe_sensor_lock = new SuccessDecoratorNode("maybe_sensor_lock", behaviorTree, unit);

        maybe_sensor_lock.AddChild(evalSensorLock);

        UnitHasRouteNode unitHasRoute0000 = new UnitHasRouteNode("unitHasRoute0000", behaviorTree, unit);

        LanceHasCompletedRouteNode lanceHasCompletedRoute0000 = new LanceHasCompletedRouteNode("lanceHasCompletedRoute0000", behaviorTree, unit);

        InverterNode inverter0000 = new InverterNode("inverter0000", behaviorTree, unit);

        inverter0000.AddChild(lanceHasCompletedRoute0000);

        LanceHasStartedRouteNode lanceHasStartedRoute0000 = new LanceHasStartedRouteNode("lanceHasStartedRoute0000", behaviorTree, unit);

        LanceStartRouteNode lanceStartRoute0000 = new LanceStartRouteNode("lanceStartRoute0000", behaviorTree, unit);

        SelectorNode selector0001 = new SelectorNode("selector0001", behaviorTree, unit);

        selector0001.AddChild(lanceHasStartedRoute0000);
        selector0001.AddChild(lanceStartRoute0000);

        BlockUntilPathfindingReadyNode blockUntilPathfindingReady0000 = new BlockUntilPathfindingReadyNode("blockUntilPathfindingReady0000", behaviorTree, unit);

        MoveAlongRouteNode moveAlongRoute0000 = new MoveAlongRouteNode("moveAlongRoute0000", behaviorTree, unit);

        SequenceNode move_along_route = new SequenceNode("move_along_route", behaviorTree, unit);

        move_along_route.AddChild(movementAvailable0001);
        move_along_route.AddChild(maybe_sensor_lock);
        move_along_route.AddChild(unitHasRoute0000);
        move_along_route.AddChild(inverter0000);
        move_along_route.AddChild(selector0001);
        move_along_route.AddChild(blockUntilPathfindingReady0000);
        move_along_route.AddChild(moveAlongRoute0000);

        HasSensorLockAbilityNode hasSensorLockAbility0001 = new HasSensorLockAbilityNode("hasSensorLockAbility0001", behaviorTree, unit);

        HasRecordedSensorLockTargetNode hasRecordedSensorLockTarget0000 = new HasRecordedSensorLockTargetNode("hasRecordedSensorLockTarget0000", behaviorTree, unit);

        SetMoodNode setMood0000 = new SetMoodNode("setMood0000", behaviorTree, unit, AIMood.Aggressive);

        SensorLockRecordedSensorLockTargetNode sensorLockRecordedSensorLockTarget0000 = new SensorLockRecordedSensorLockTargetNode("sensorLockRecordedSensorLockTarget0000", behaviorTree, unit);

        SequenceNode choseToSensorLock = new SequenceNode("choseToSensorLock", behaviorTree, unit);

        choseToSensorLock.AddChild(hasSensorLockAbility0001);
        choseToSensorLock.AddChild(hasRecordedSensorLockTarget0000);
        choseToSensorLock.AddChild(setMood0000);
        choseToSensorLock.AddChild(sensorLockRecordedSensorLockTarget0000);

        LanceDetectsEnemiesNode lanceDetectsEnemies0000 = new LanceDetectsEnemiesNode("lanceDetectsEnemies0000", behaviorTree, unit);

        FindDetectedEnemiesNode findDetectedEnemies0000 = new FindDetectedEnemiesNode("findDetectedEnemies0000", behaviorTree, unit);

        IsAttackAvailableForUnitNode attackAvailable0000 = new IsAttackAvailableForUnitNode("attackAvailable0000", behaviorTree, unit);

        SortEnemiesByThreatNode sortEnemiesByThreat0000 = new SortEnemiesByThreatNode("sortEnemiesByThreat0000", behaviorTree, unit);

        UseNormalToHitThreshold useNormalToHitThreshold0000 = new UseNormalToHitThreshold("useNormalToHitThreshold0000", behaviorTree, unit);

        WasTargetedRecentlyNode wasTargetedRecently0000 = new WasTargetedRecentlyNode("wasTargetedRecently0000", behaviorTree, unit);

        InverterNode inverter0001 = new InverterNode("inverter0001", behaviorTree, unit);

        inverter0001.AddChild(wasTargetedRecently0000);

        RandomPercentageLessThanBVNode randomPercentageLessThanBV0000 = new RandomPercentageLessThanBVNode("randomPercentageLessThanBV0000", behaviorTree, unit, BehaviorVariableName.Float_PriorityAttackPercentage);

        SortEnemiesByPriorityListNode sortEnemiesByPriorityList0000 = new SortEnemiesByPriorityListNode("sortEnemiesByPriorityList0000", behaviorTree, unit);

        SequenceNode sequence0000 = new SequenceNode("sequence0000", behaviorTree, unit);

        sequence0000.AddChild(inverter0001);
        sequence0000.AddChild(randomPercentageLessThanBV0000);
        sequence0000.AddChild(sortEnemiesByPriorityList0000);

        MaybeFilterOutPriorityTargetsNode maybeFilterOutPriorityTargets0000 = new MaybeFilterOutPriorityTargetsNode("maybeFilterOutPriorityTargets0000", behaviorTree, unit);

        FilterKeepingRecentAttackersNode filterKeepingRecentAttackers0000 = new FilterKeepingRecentAttackersNode("filterKeepingRecentAttackers0000", behaviorTree, unit);

        SucceedNode succeed0000 = new SucceedNode("succeed0000", behaviorTree, unit);

        SelectorNode priorityAttack = new SelectorNode("priorityAttack", behaviorTree, unit);

        priorityAttack.AddChild(sequence0000);
        priorityAttack.AddChild(maybeFilterOutPriorityTargets0000);
        priorityAttack.AddChild(filterKeepingRecentAttackers0000);
        priorityAttack.AddChild(succeed0000);

        ShootAtHighestPriorityEnemyNode shootAtHighestPriorityEnemy0000 = new ShootAtHighestPriorityEnemyNode("shootAtHighestPriorityEnemy0000", behaviorTree, unit);

        SequenceNode opportunity_fire = new SequenceNode("opportunity_fire", behaviorTree, unit);

        opportunity_fire.AddChild(lanceDetectsEnemies0000);
        opportunity_fire.AddChild(findDetectedEnemies0000);
        opportunity_fire.AddChild(attackAvailable0000);
        opportunity_fire.AddChild(sortEnemiesByThreat0000);
        opportunity_fire.AddChild(useNormalToHitThreshold0000);
        opportunity_fire.AddChild(priorityAttack);
        opportunity_fire.AddChild(shootAtHighestPriorityEnemy0000);

        BraceNode brace0000 = new BraceNode("brace0000", behaviorTree, unit);

        SelectorNode patrol_and_shoot_AI_root = new SelectorNode("patrol_and_shoot_AI_root", behaviorTree, unit);

        patrol_and_shoot_AI_root.AddChild(if_shutdown__restart);
        patrol_and_shoot_AI_root.AddChild(if_prone__stand_up);
        patrol_and_shoot_AI_root.AddChild(move_along_route);
        patrol_and_shoot_AI_root.AddChild(choseToSensorLock);
        patrol_and_shoot_AI_root.AddChild(opportunity_fire);
        patrol_and_shoot_AI_root.AddChild(brace0000);

        return(patrol_and_shoot_AI_root);
    }