static BehaviorTreeDesc BuildTreeDesc()
        {
            var builder = new BehaviorTreeBuilder();

            builder.Composite <SequenceTaskDesc>()
            .AppendChild(builder.Leaf <LogTaskDesc>(
                             d => d.Message = "Start"))
            .AppendChild(builder.Leaf <WaitTimerTaskDesc>(
                             d => d.Time = new VariableDesc(VariableType.UInteger, VariableSource.LiteralConstant, "3000")))
            .AppendChild(builder.Leaf <LogTaskDesc>(d =>
                                                    d.Message = "End"));
            return(builder.Build());
        }
Esempio n. 2
0
    void Start()
    {
        BehaviorTreeBuilder builder = new BehaviorTreeBuilder();

        builder.Sequence("sequence1");
        builder.Action("action1", Action01);
        builder.Action("action2", Action02);
        builder.Sequence("sequence02");
        builder.Action("action03", Action03);
        builder.Action("action04", Action04);
        builder.End();
        builder.Action("Action05", Action05);
        builder.Action("Action06", Action06);
        builder.End();
        tree = builder.Build();
    }
Esempio n. 3
0
        BehaviorTreeDesc IBehaviorTreeLoader.LoadTree(string path)
        {
            var builder = new BehaviorTreeBuilder();

            switch (path)
            {
            case "Log":
            {
                builder.Leaf <LogTaskDesc>(d => d.Message = "Log");
                break;
            }

            case "WaitTimer":
            {
                builder.Composite <SequenceTaskDesc>()
                .AppendChild(builder.Leaf <DumpLogTaskDesc>(
                                 d => d.Text = "Start"))
                .AppendChild(builder.Leaf <WaitTimerTaskDesc>(
                                 d => d.Time = new VariableDesc(VariableType.UInteger, VariableSource.LiteralConstant, "3000")))
                .AppendChild(builder.Leaf <DumpLogTaskDesc>(d =>
                                                            d.Text = "CheckPoint1"))
                .AppendChild(builder.Leaf <WaitTimerTaskDesc>(
                                 d => d.Time = new VariableDesc(VariableType.UInteger, VariableSource.TreeOwnerProperty, "uint.3000")))
                .AppendChild(builder.Leaf <DumpLogTaskDesc>(d =>
                                                            d.Text = "CheckPoint2"))
                .AppendChild(builder.Leaf <WaitTimerTaskDesc>(
                                 d => d.Time = new VariableDesc(VariableType.UInteger, VariableSource.GlobalConstant, "uint.5000")))
                .AppendChild(builder.Leaf <DumpLogTaskDesc>(d =>
                                                            d.Text = "End"));
                break;
            }

            case "ConditionEvaluator1":
            {
                builder.Composite <SelectorTaskDesc>()
                .AppendChild(builder.Leaf <ConditionalEvaluatorTaskDesc>(d =>
                    {
                        d.Left  = new VariableDesc(VariableType.UInteger, VariableSource.GlobalConstant, "uint.5000");
                        d.Op    = ComparisonOperator.LessThan;
                        d.Right = new VariableDesc(VariableType.UInteger, VariableSource.LiteralConstant, "100");
                    }))
                .AppendChild(builder.Leaf <ConditionalEvaluatorTaskDesc>(d =>
                    {
                        d.Left  = new VariableDesc(VariableType.Float, VariableSource.GlobalConstant, "float.pi");
                        d.Op    = ComparisonOperator.GreaterThan;
                        d.Right = new VariableDesc(VariableType.Float, VariableSource.LiteralConstant, "4");
                    }))
                .AppendChild(builder.Leaf <ConditionalEvaluatorTaskDesc>(d =>
                    {
                        d.Left  = new VariableDesc(VariableType.Float, VariableSource.GlobalConstant, "float.pi");
                        d.Op    = ComparisonOperator.Equal;
                        d.Right = new VariableDesc(VariableType.Float, VariableSource.GlobalConstant, "float.pi");
                    }));
            }
            break;

            default:
                throw new KeyNotFoundException(path);
            }

            return(builder.Build());
        }