예제 #1
0
    private void Awake()
    {
        move = new Vector3(0, 0, 0);
        var tag = GameObject.Find("Tag").GetComponent <Tag>();

        var root = new SelectorNode("/");

        root.Add("/", new DecoratorNode("/IsIt", () => tag.target == this.gameObject.transform));
        root.Add("/IsIt", new ActionNode("/IsIt/RunAfter", () =>
        {
            move = GameObject.Find("Player").transform.position - this.transform.position;
            return(true);
        }));
        root.Add("/", new ActionNode("/RunAway", () =>
        {
            move = this.transform.position - tag.target.position;
            return(true);
        }));

        this.UpdateAsObservable()
        .Subscribe(_ => {
            root.Excute();
        });
    }