コード例 #1
0
ファイル: SpiderJPTree.cs プロジェクト: JPedroMPF/GettinFat
    public void StartTree()
    {
        DTAction action = root.MakeDecision();

        if (action != null)
        {
            action.Run();
        }
    }
コード例 #2
0
    void Update()
    {
        distanceToPlayer = Vector3.Distance(transform.position, target.position);

        //Debug.Log("Distance: " + distanceToPlayer);

        DTBinaryDecision tree = new DTBinaryDecision(() =>
        {
            return(distanceToPlayer < 50f);
        },

                                                     new DTAction(() =>
        {
            Attack();
        }),

                                                     new DTAction(() =>
        {
            Debug.Log("Waiting");
            isClose = false;
        }));

        new DTBinaryDecision(() =>
        {
            return(distanceToPlayer < 10f);
        },

                             new DTAction(() =>
        {
            Debug.Log("You died");
        }),
                             new DTAction(() =>
        {
            Debug.Log("Continue");
        }));

        tree.MakeDecision().Run();
    }