Пример #1
0
    // Use this for initialization
    void Start()
    {
        BT = new BehaviourTree();
        var qFood       = BT.CreateActionNode(IsFoodLow);
        var gFood       = BT.CreateActionNode(FetchFood);
        var GetFoodList = new List <uint> {
            qFood, gFood
        };

        var qWater       = BT.CreateActionNode(IsWaterLow);
        var gWater       = BT.CreateActionNode(FetchWater);
        var GetWaterList = new List <uint> {
            qWater, gWater
        };

        var qHeat       = BT.CreateActionNode(IsHeatLow);
        var gHeat       = BT.CreateActionNode(FetchHeat);
        var GetHeatList = new List <uint> {
            qHeat, gHeat
        };

        var cFood  = BT.CreateCompositeNode(CompositeNodeTypes.Sequence, GetFoodList);
        var cWater = BT.CreateCompositeNode(CompositeNodeTypes.Sequence, GetWaterList);
        var cHeat  = BT.CreateCompositeNode(CompositeNodeTypes.Sequence, GetHeatList);

        var resourceList = new List <uint> {
            BT.CreateDecoratorNode(DecoratorNodeType.Succeeder, cFood),
            BT.CreateDecoratorNode(DecoratorNodeType.Succeeder, cWater),
            BT.CreateDecoratorNode(DecoratorNodeType.Succeeder, cHeat)
        };

        var root = BT.CreateCompositeNode(CompositeNodeTypes.Sequence, resourceList);

        BT.SetRootNode(root);

        myLineRenderer = GetComponent <LineRenderer>();

        UpdateGUI();
    }