Пример #1
0
        public IBehaviour <Creature> AttackBehaviour()
        {
            return(FluentBuilder.Create <Creature>()
                   .Selector("attack-behaviour")
                   //.Wait("GCD", 1400)


                   .Random("change-to-random", .05)
                   .Do("change-to-random", ChangeToRandomTarget)
                   .End()
                   .Random("seeping-wound", .05)
                   .Do("seeping-wound", SeepingWound)
                   .End()
                   .Random("touch-of-palsy", .10)
                   .Do("touch-of-palsy", TouchOfPalsy)
                   .End()
                   .Random("ravage", 25.00)
                   .Do("ravage", Ravage)
                   .End()
                   .Random("Taunt", 0.05)
                   .Do("Taunt", Taunt)
                   .End()

                   .End()
                   .Build());
        }
Пример #2
0
        public void BuilderCreatesDefaultObject()
        {
            var builder = new FluentBuilder <Car>();
            Car car     = builder.Create();

            car.Should().NotBeNull();
        }
Пример #3
0
        public void BuilderCreatesObjectWithRequiredProperty()
        {
            var builder = new FluentBuilder <Car>();
            Car car     = builder.Create(1);

            car.Should().NotBeNull();
            car.Id.Should().Be(1);
        }
Пример #4
0
 public IBehaviour <Creature> MakeTree()
 {
     return(FluentBuilder.Create <Creature>()
            .PrioritySelector("root")
            .Subtree(ProcessDirectiveBehaviour())
            .Subtree(HighLevelActionBehaviour())
            .End()
            .Build());
 }
        public void Test()
        {
            var subTree = FluentBuilder.Create <Clock>()
                          .LimitCallRate("LimitCallRate1", 963)
                          .AlwaysSucceed("AlwaysSucceed1")
                          .AlwaysFail("AlwaysFail1")
                          .UntilSuccess("UntilSuccess1")
                          .Do("action9", _ => BehaviourStatus.Failed)
                          .End()
                          .End()
                          .End()
                          .End()
                          .Build();

            var tree = FluentBuilder.Create <Clock>()
                       .Selector("Selector1")
                       .Subtree("Subtree1", subTree)
                       .Sequence("PrioritySelector1")
                       .PrioritySelector("PrioritySelector1")
                       .Do("action1", _ => BehaviourStatus.Succeeded)
                       .Do("action2", _ => BehaviourStatus.Succeeded)
                       .End()
                       .Do("action3", _ => BehaviourStatus.Succeeded)
                       .End()
                       .PrioritySequence("PrioritySequence1")
                       .Condition("Condition1", _ => true)
                       .Wait("Wait1", 456)
                       .SimpleParallel("SimpleParallel1")
                       .AutoReset("AutoReset1")
                       .Cooldown("Cooldown1", 789)
                       .Repeat("Repeat1", 4)
                       .Condition("Condition5", _ => false)
                       .End()
                       .End()
                       .End()
                       .TimeLimit("Timelimit1", 147)
                       .UntilFailed("UntilFailed1")
                       .Invert("Invert1")
                       .Condition("Condition2", _ => false)
                       .End()
                       .End()
                       .End()
                       .End()
                       .End()
                       .End()
                       .Build();

            var printer = new BehaviourTreeExpressionPrinter <Clock>();

            printer.Visit(tree);

            var result = printer.ToString();

            // TODO: string comparison is flaky on build server
        }
Пример #6
0
 public IBehaviour <Creature> ProcessDirectiveBehaviour()
 {
     return(FluentBuilder.Create <Creature>()
            .Sequence("directive-processing")
            .Condition("directive-exists", HasDirective)
            .Do("processDirective", t =>
     {
         SpeakYourMind($"Processing Directive..");
         return BehaviourStatus.Succeeded;
     })
            .End()
            .Build());
 }
Пример #7
0
        public void BuilderCreatesObjectWithAttributes()
        {
            var builder = new FluentBuilder <Car>();
            Car car     = builder.Create(1)
                          .WithManufacturer("BMW")
                          .WithPower(100);

            car.Should().NotBeNull().And.BeEquivalentTo(new
            {
                Id           = 1,
                Manufacturer = "BMW",
                Power        = 100
            });
        }
Пример #8
0
 public IBehaviour <Creature> HighLevelActionBehaviour()
 {
     return(FluentBuilder.Create <Creature>()
            .Selector("high-level-actions")
            .Do("setTarget", SetNewTarget)
            .Do("drink-potion", DrinkPotion)
            .Random("crowd-control", 0.2)
            .Do("knock-down", KnockDownTarget)
            .End()
            .Random("crowd-control", 0.1)
            .Do("punt", PuntTarget)
            .End()
            .Condition("can-attack", CanAttack)
            .Subtree(AttackBehaviour())
            .End()
            .Build());
 }
Пример #9
0
        public void WhereClauseTest()
        {
            var actual = FluentBuilder.Create().Select("*").From("Customers").Where("Country = 'Mexico'").ToString();

            StringAssert.AreEqualIgnoringCase("SELECT * FROM Customers WHERE Country = 'Mexico';", actual);
        }
Пример #10
0
        public void SelectClauseTest()
        {
            var actual = FluentBuilder.Create().Select("CustomerName,City").From("Customers").ToString();

            StringAssert.AreEqualIgnoringCase("SELECT CustomerName,City FROM Customers;", actual);
        }
Пример #11
0
        public void OrderByClauseTest()
        {
            var actual = FluentBuilder.Create().Select("*").From("Customers").OrderBy("Country ASC, CustomerName DESC").ToString();

            StringAssert.AreEqualIgnoringCase("SELECT * FROM Customers ORDER BY Country ASC, CustomerName DESC;", actual);
        }