Exemple #1
0
        public MiddleBT()
        {
            Selector selector =
                ScriptableObject.CreateInstance <Selector>();
            Sequence sequence =
                ScriptableObject.CreateInstance <Sequence>();
            ParallelSelector ps =
                ScriptableObject.CreateInstance <ParallelSelector>();
            CanISeePlayer c1 =
                ScriptableObject.CreateInstance <CanISeePlayer>();
            CanISeePlayer c2 =
                ScriptableObject.CreateInstance <CanISeePlayer>();
            TranslatetoARandomPosition t1 =
                ScriptableObject.CreateInstance <TranslatetoARandomPosition>();
            UntilSuccess untilSuccess =
                ScriptableObject.CreateInstance <UntilSuccess>();
            RotateByY r1 = ScriptableObject.CreateInstance <RotateByY>();

            selector.AddChild(sequence, 0);
            selector.AddChild(ps, 1);
            sequence.AddChild(c1, 0);
            sequence.AddChild(t1, 1);
            ps.AddChild(untilSuccess, 0);
            ps.AddChild(r1, 1);
            untilSuccess.AddChild(c2, 0);

            InitalBTStructureData(selector);
        }
Exemple #2
0
    public MiddleBTRandom()
    {
        Selector                   selector     = ScriptableObject.CreateInstance <Selector>();
        Sequence                   sequence     = ScriptableObject.CreateInstance <Sequence>();
        ParallelSelector           ps           = ScriptableObject.CreateInstance <ParallelSelector>();
        CanISeePlayer              c1           = ScriptableObject.CreateInstance <CanISeePlayer>();
        CanISeePlayer              c2           = ScriptableObject.CreateInstance <CanISeePlayer>();
        TranslatetoARandomPosition t1           = ScriptableObject.CreateInstance <TranslatetoARandomPosition>();
        UntilSuccess               untilSuccess = ScriptableObject.CreateInstance <UntilSuccess>();
        RotateByY                  r1           = ScriptableObject.CreateInstance <RotateByY>();

        // 包含0,不包含3
        int    randomChoice = Random.Range(0, 3);
        string color        = "";

        switch (randomChoice)
        {
        case 0:
            RedAction redTask = ScriptableObject.CreateInstance <RedAction>();
            color = "red";
            sequence.AddChild(redTask, 0);
            break;

        case 1:
            BlueAction blueTask = ScriptableObject.CreateInstance <BlueAction>();
            color = "blue";
            sequence.AddChild(blueTask, 0);
            break;

        case 2:
            YellowAction yellowTask = ScriptableObject.CreateInstance <YellowAction>();
            color = "yellow";
            sequence.AddChild(yellowTask, 0);
            break;

        default:
            break;
        }

        if (null == UIBTInformationNotifier.instance)
        {
            UIBTInformationNotifier notifier = new UIBTInformationNotifier();
        }
        UIBTInformationNotifier.instance.NotifyColorInfoChangeEvent(color);


        selector.AddChild(sequence, 0);
        selector.AddChild(ps, 1);
        sequence.AddChild(c1, 1);
        sequence.AddChild(t1, 2);
        ps.AddChild(untilSuccess, 0);
        ps.AddChild(r1, 1);
        untilSuccess.AddChild(c2, 0);

        InitalBTStructureData(selector);
    }
Exemple #3
0
        public SimpleBT()
        {
            Sequence         s1        = new Sequence();
            Parallel         p1        = new Parallel();
            Selector         selector1 = new Selector();
            ParallelSelector ps1       = new ParallelSelector();
            RedAction        a1        = new RedAction();
            //SimpleAction2 a2 = new SimpleAction2();
            YellowAction a2 = new YellowAction();

            s1.AddChild(a1, 0);
            s1.AddChild(a2, 1);
            p1.AddChild(a1, 0);
            p1.AddChild(a2, 1);
            selector1.AddChild(a1, 0);
            selector1.AddChild(a2, 1);
            ps1.AddChild(a1, 0);
            ps1.AddChild(a2, 1);
            // just test sequence
            // this.taskList.Add(s1);
            // just test parallel
            //this.taskList.Add(p1);
            // just test selector
            //this.taskList.Add(selector1);
            // just test ParallelSelecotr
            this.taskList.Add(ps1);
            this.taskList.Add(a1);
            this.taskList.Add(a2);
            this.parentIndexList.Add(0);
            // 其实组装一个action的东西是不是应该是AddTask方法封装好的呀,而用户只是传进来一个Type
            //SimpleAction2 a3 = new SimpleAction2();
            //this.AddTask(0, 0, a3);

            for (int i = 0; i < taskList.Count; i++)
            {
                NodeData nd = new NodeData();
                nd.ExecutionStatus   = TaskStatus.Inactive;
                taskList[i].NodeData = nd;
                taskList[i].OnAwake();
            }
        }