Exemplo n.º 1
0
        private static IBehaviour <BtContext> BuildHouseBehaviour()
        {
            const int requiredStones = 2;
            const int requiredWood   = 4;

            var gatherRequiredResources = FluentBuilder.FluentBuilder.Create <BtContext>()
                                          .Sequence("Gather resources")
                                          .Selector("Gather wood")
                                          .Condition("Has enough wood?", c => BotBehaviourFunctions.HasItem(c, ItemTypes.Wood, requiredWood))
                                          .Subtree(ChopWoodBehaviour())
                                          .End()
                                          .Selector("Gather stone")
                                          .Condition("Has enough stone?", c => BotBehaviourFunctions.HasItem(c, ItemTypes.Stone, requiredStones))
                                          .Subtree(MineStoneBehaviour())
                                          .End()
                                          .End()
                                          .Build();

            return(FluentBuilder.FluentBuilder.Create <BtContext>()
                   .PrioritySequence("Build house")
                   .Subtree(gatherRequiredResources)
                   .Do("Spawn house", c => BotBehaviourFunctions.BuildHouse(c, requiredStones, requiredWood))
                   .End()
                   .Build());
        }
Exemplo n.º 2
0
 private static IBehaviour <BtContext> FindAndPickupItem(ItemTypes itemType)
 {
     return(FluentBuilder.FluentBuilder.Create <BtContext>()
            .Sequence("Find and pick up item")
            .Do($"Set closest [{itemType}] as target", c => BotBehaviourFunctions.SetItemAsTarget(c, itemType))
            .Do("Move to target", BotBehaviourFunctions.MoveToTargetEntity)
            .Do("Pickup target", BotBehaviourFunctions.PickupTarget)
            .End()
            .Build());
 }
Exemplo n.º 3
0
 private static IBehaviour <BtContext> ChopWoodBehaviour()
 {
     return(FluentBuilder.FluentBuilder.Create <BtContext>()
            .PrioritySequence("Chop wood")
            .Selector("Get axe")
            .Condition("Has axe?", c => BotBehaviourFunctions.HasItem(c, ItemTypes.Axe, 1))
            .Subtree(FindAndPickupItem(ItemTypes.Axe))
            .End()
            .Subtree(FindAndPickupItem(ItemTypes.Wood))
            .End()
            .Build());
 }
Exemplo n.º 4
0
 private static IBehaviour <BtContext> MineStoneBehaviour()
 {
     return(FluentBuilder.FluentBuilder.Create <BtContext>()
            .PrioritySequence("Mine stone")
            .Selector("Get pickaxe")
            .Condition("Has pickaxe?", c => BotBehaviourFunctions.HasItem(c, ItemTypes.Pickaxe, 1))
            .Subtree(FindAndPickupItem(ItemTypes.Pickaxe))
            .End()
            .Subtree(FindAndPickupItem(ItemTypes.Stone))
            .End()
            .Build());
 }