示例#1
0
    /// <summary>
    /// This is what you create, using control nodes(sequence, selector, etc.) and leaf nodes
    /// and pass it to the Behavior Agent. Each time the root ticks, it will tick its children,
    /// if any, and the ticks continue down the tree until reaching a leaf to execute. This process
    /// is implemented using Closures and Enumerators in C#.
    /// </summary>
    /// <returns></returns>
    protected Node BuildTreeRoot()
    {
        //Node actor1 = new DecoratorLoop(new SequenceShuffle(this.ST_GoToUpToRadius(wanderpoint1,0.5f, 3f), this.ST_GoToUpToRadius(wanderpoint2,0.5f, 5.0f), this.ST_GoToUpToRadius(wanderpoint3, 1f, 6f)));
        Node actor1 = new DecoratorLoop(
            new Sequence(
                this.ST_Routes(wanderpoint1, wanderpoint2, 3f, 2f, 6f, 3f, wanderpoint3),
                this.ST_Grab(item)
                )
            );
        Node actor2       = new Sequence();
        Node mainStoryArc = new SequenceParallel(actor1, actor2);

        return(mainStoryArc);
    }
    protected Node BuildTreeRoot()
    {
        Val <float> pp      = Val.V(() => police.transform.position.z);
        Func <bool> act     = () => (police.transform.position.z > 10) || (police.transform.position.z < -10);
        Node        roaming = new DecoratorLoop(
            new Sequence(
                this.ST_ApproachAndWait(this.wander1),
                this.ST_ApproachAndWait(this.wander2),
                this.ST_ApproachAndWait(this.wander3)));
        Node trigger = new DecoratorLoop(new LeafAssert(act));
        Node root    = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger, roaming)));

        return(root);
    }
示例#3
0
    protected Node BuildTreeRoot()
    {
        var         distance = Vector3.Distance(wander1.transform.position, participant.transform.position);
        Func <bool> act      = () => (waveFlag);
        Node        roaming  = new DecoratorLoop(1,
                                                 new Sequence(
                                                     this.ST_ApproachAndWait(this.wander1.transform)));

        return(roaming);

        //Node trigger = new DecoratorLoop(new LeafAssert(act));
        //Node root = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger, roaming)));
        //return root;
    }
    protected Node BuildTreeRoot()
    {
        //return new Sequence(this.goToExit1(this.participant1.transform));

        Node roaming = new DecoratorLoop(
            new SequenceParallel(
                goToExit(this.participant1.transform),
                goToExit2(this.participant2.transform),
                goToExit3(this.participant3.transform),
                goToExit4(this.participant4.transform),
                goToExit5(this.participant5.transform),
                goToExit6(this.participant6.transform),
                goToExit7(this.participant7.transform),
                goToExit8(this.participant8.transform),
                goToExit9(this.participant9.transform),
                goToExit10(this.participant10.transform),
                goToExitCommon(this.participant11.transform),
                goToExitCommon(this.participant12.transform),
                goToExitCommon(this.participant13.transform),
                goToExitCommon(this.participant14.transform),
                goToExitCommon(this.participant15.transform),
                goToExitCommon(this.participant16.transform),
                goToExitCommon(this.participant17.transform),
                goToExitCommon(this.participant18.transform),
                goToExitCommon(this.participant19.transform),
                goToExitCommon(this.participant20.transform),
                goToExit(this.participant21.transform),
                goToExit2(this.participant22.transform),
                goToExit3(this.participant23.transform),
                goToExit4(this.participant24.transform),
                goToExit5(this.participant25.transform),
                goToExit6(this.participant26.transform),
                goToExit7(this.participant27.transform),
                goToExit8(this.participant28.transform),
                goToExit9(this.participant29.transform),
                goToExit10(this.participant30.transform),
                goToExitCommon(this.participant31.transform),
                goToExitCommon(this.participant32.transform),
                goToExitCommon(this.participant33.transform),
                goToExitCommon(this.participant34.transform),
                goToExitCommon(this.participant35.transform),
                goToExitCommon(this.participant36.transform),
                goToExitCommon(this.participant37.transform),
                goToExitCommon(this.participant38.transform),
                goToExitCommon(this.participant39.transform),
                goToExitCommon(this.participant40.transform)));

        return(roaming);
    }
    protected Node BuildTreeRoot()
    {
        Func <bool> SeeAcquaintance    = () => (!checkSee(speaker1, heroAgent));
        Func <bool> NotSeeAcquaintance = () => (checkSee(speaker1, heroAgent));

        Node doConversation = new Sequence(new DecoratorInvert(
                                               new DecoratorLoop(new LeafAssert(NotSeeAcquaintance))), new LeafWait(1000), ST_Conversation(speaker1, speaker2, speaker3));

        Node doSayHello = new Sequence(new DecoratorInvert(
                                           new DecoratorLoop(new LeafAssert(SeeAcquaintance))), new LeafWait(1000), ST_SayHello(speaker1, speaker2, speaker3, heroAgent));

        Node root = new DecoratorLoop(new SequenceParallel(doConversation, doSayHello));

        return(root);
    }
示例#6
0
    protected Node Ending2(GameObject partc)
    {
        Func <bool> act     = () => (lamp.enabled);
        Node        trigger = new DecoratorLoop(new LeafAssert(act));

        // You ask A to fix light bulb and he is angry
        return(new Sequence(
                   new SequenceParallel(this.TextOn("You: The light bulb is broken, can you help that guy fix it?", canvasTV, bubbleTextT)),
                   new SequenceParallel(this.TextOn("C: Alright. I'll take a look at that.", canvasLight, bubbleTextL)),

                   new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                              new SequenceParallel(
                                                                  trigger,
                                                                  new Sequence(
                                                                      this.LightOff(partc.GetComponent <BehaviorMecanim>()), this.WatchTV(partc.GetComponent <BehaviorMecanim>(), TVp3, SofaIK3)))))
                   ));
    }
示例#7
0
    protected Node BuildTreeRoot()
    {
        Node roaming = new DecoratorLoop(
            new Selector(
                new Sequence(
                    this.ST_ApproachAndWait(this.wander1),
                    new DecoratorLoop(
                        //new Sequence(this.PickUp(participant), ChaChaRealSmooth(participant, 3), this.PutDown(participant)))
                        new Sequence(
                            participant.GetComponent <BehaviorMecanim>().ST_TurnToFace(Val.V(() => ball.transform.position)),
                            this.PickUp(participant),
                            this.PutDown(participant)
                            )
                        )
                    ),
                this.ST_ApproachAndWait(this.wander2)
                )
            );

        return(roaming);
    }
示例#8
0
    // protected Node NPCLightOff(GameObject partb)
    // {
    //     angryCount += 1;
    //     Debug.Log(angryCount);
    //     return new Sequence(this.LightOff(partb.GetComponent<BehaviorMecanim>()), this.WatchTV(partb.GetComponent<BehaviorMecanim>(), TVp3, SofaIK3));
    // }

    protected Node AssignRoles(GameObject parta, GameObject partb, GameObject partc)
    {
        // A ask B turn off light
        // A ask C turn on TV

        //Val<bool> pp = Val.V (() => lamp.enabled);
        Func <bool> act     = () => (lamp.enabled);
        Node        trigger = new DecoratorLoop(new LeafAssert(act));

        Func <bool> playerinRangeA = () => (parta.GetComponentInChildren <PlayerinRange>().playerinRange);
        Func <bool> playerinRangeB = () => (partb.GetComponentInChildren <PlayerinRange>().playerinRange);
        Func <bool> playerinRangeC = () => (partc.GetComponentInChildren <PlayerinRange>().playerinRange);

        Node triggerA = new DecoratorLoop(new LeafAssert(playerinRangeA));
        Node triggerB = new DecoratorLoop(new LeafAssert(playerinRangeB));
        Node triggerC = new DecoratorLoop(new LeafAssert(playerinRangeC));

        return(new Sequence(
                   new SequenceParallel(this.faceAndPoint(parta.GetComponent <BehaviorMecanim>(), partb, 2000), this.TextOn("You turn off the light", canvasLight, bubbleTextL)),
                   new SequenceParallel(this.faceAndPoint(parta.GetComponent <BehaviorMecanim>(), partc, 2000), this.TextOn("You turn on the TV", canvasLight, bubbleTextL)),

                   new SequenceParallel(
                       this.WatchTV(parta.GetComponent <BehaviorMecanim>(), TVp1, SofaIK1),
                       new Sequence(this.LightOff(partb.GetComponent <BehaviorMecanim>()), this.WatchTV(partb.GetComponent <BehaviorMecanim>(), TVp3, SofaIK3)),
                       new Sequence(this.TVOnOff(partc.GetComponent <BehaviorMecanim>()), this.WatchTV(partc.GetComponent <BehaviorMecanim>(), TVp2, SofaIK2)),
                       // new Sequence(this.TextOn ("GOGOGO...", canvasTV, bubbleTextT)),
                       new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                                  new SequenceParallel(
                                                                      trigger,
                                                                      new Sequence(
                                                                          this.LightOff(partb.GetComponent <BehaviorMecanim>()),
                                                                          this.WatchTV(partb.GetComponent <BehaviorMecanim>(), TVp3, SofaIK3))
                                                                      )
                                                                  ))

                       )

                   ));
    }
示例#9
0
    protected Node BuildTreeRoot()
    {
        Val <bool>  criminalInRange = Val.V(() => this.checkForCriminals());
        Func <bool> act1            = () => (criminalInRange.Value == false);
        Node        lookoutNode     = new DecoratorLoop(new LeafAssert(act1));
        Node        patrolNode      = new DecoratorLoop(
            new SequenceShuffle(
                this.ST_ApproachAndWait(this.wander3)
                )
            );
        Node phasePatrol = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(lookoutNode, patrolNode)));
        Val <UnityEngine.Transform> criminalPosition = Val.V(() => this.Monster.transform);

        Func <bool> act2           = () => (criminalInRange.Value == true);
        Node        chaseNode      = new DecoratorLoop(new LeafAssert(act2));
        Node        followCriminal = new DecoratorLoop(new Sequence(this.ST_ApproachAndWait(criminalPosition.Value)));
        Node        phaseChase     = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(chaseNode, followCriminal)));

        Node root = new DecoratorLoop(new SelectorParallel(phasePatrol, phaseChase));

        return(root);
    }
示例#10
0
    protected Node BuildTreeRoot()
    {
        rnd = new System.Random();
        rn  = rnd.Next(1, 3);

        if (rn == 2)
        {
            Node roaming   = new DecoratorLoop(new Sequence(this.ST_ApproachAndWait(this.point2, Explorer)));
            Node chase1    = new DecoratorLoop(new Sequence(this.ST_Chase1(Explorer, Chaser1)));
            Node chase2    = new DecoratorLoop(new Sequence(this.ST_Chase2(Explorer, Chaser2)));
            Node rightPath = new DecoratorLoop(new Sequence(roaming, new SequenceParallel(chase1, chase2)));
            return(rightPath);
        }
        else
        {
            Node roaming  = this.ST_ApproachAndWait(this.point1, Explorer);
            Node roaming2 = this.ST_ApproachAndWait(this.point3, Sage);
            Node follow   = this.ST_Follow(Explorer, Chest);
            Node leftPath = new Sequence(roaming, new SequenceParallel(roaming2, follow));
            return(leftPath);
        }
    }
示例#11
0
    // protected Node ST_Chase(GameObject char1, GameObject char2, GameObject char3)
    // {
    //    Vector3 pos = new Vector3(char2.transform.position.x, char2.transform.position.y, char2.transform.position.z + 2.0f);
    //   Val<Vector3> position = Val.V(() => pos);
    //    return new Sequence(char1.GetComponent<BehaviorMecanim>().Node_GoTo(position), new LeafWait(1000));
    //}

    protected Node BuildTreeRoot()
    {
        rnd = new System.Random();
        rn  = rnd.Next(1, 2);

        if (rn == 2)
        {
            Node roaming = new DecoratorLoop(new SequenceShuffle(this.ST_ApproachAndWait(this.point2, Explorer)));
            return(roaming);
        }
        else if (rn == 1)
        {
            Node roaming  = new DecoratorLoop(new SequenceShuffle(this.ST_ApproachAndWait(this.point1, Explorer)));
            Node roaming2 = new DecoratorLoop(new SequenceShuffle(this.ST_ApproachAndWait(this.point3, Sage)));
            Node follow   = new DecoratorLoop(new Sequence(this.ST_Follow(Explorer, Sage)));
            Node leftPath = new DecoratorLoop(new Sequence(roaming, new SequenceParallel(roaming2, follow)));
            return(leftPath);
        }
        else
        {
            return(null);
        }
    }
示例#12
0
    protected Node[] BuildTreeRoot()
    {
        ForEach <GameObject> returnValue = new ForEach <GameObject>((participant) =>
        {
            Func <bool> act  = () => ((Math.Abs(police.transform.position.z - participant.transform.position.z) < 5) && (Math.Abs(police.transform.position.x - participant.transform.position.x) < 5));
            Func <bool> act2 = () => ((Math.Abs(door.transform.position.z - participant.transform.position.z) < 5) && (Math.Abs(door.transform.position.x - participant.transform.position.x) < 5));
            Func <bool> act4 = () => ((Math.Abs(police.transform.position.z - participant.transform.position.z) >= 5) && (Math.Abs(police.transform.position.x - participant.transform.position.x) >= 5));
            Node trigger     = new DecoratorLoop(new LeafAssert(act));
            Node trigger4    = new DecoratorLoop(new LeafAssert(act4));
            Node roaming     =
                new SequenceParallel(
                    new DecoratorForceStatus(RunStatus.Success, ST_RunAndWait(police.transform, participant.transform)), new LeafInvoke(() => { participant.GetComponent <CanvasController>().enableSpeech(); participant.GetComponent <CanvasController>().setText("AHH, RUN!"); }))
            ;
            Node clearText = new LeafInvoke(() => { participant.GetComponent <CanvasController>().disableSpeech(); });
            Node trigger2  = new DecoratorLoop(new LeafAssert(act2));

            Node open = new DecoratorLoop(
                new Sequence(CompleteOpenDoor(specialDaniel.transform)));
            Node root = new DecoratorLoop(new Sequence(new SequenceParallel(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger, roaming)),
                                                                            new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger4, clearText))),
                                                       new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger2, open))));
            return(root);
        }, participants);

        Func <bool> act3     = () => (1 < 0);
        Node        trigger3 = new LeafInvoke(() => RunStatus.Failure);
        Node        temp     = new Sequence(new LeafInvoke(() => {
            if (index < 2)
            {
                index++;
            }
            else
            {
                index = 0;
            }
            Debug.Log("leafinvoke index: " + index);
        }), new LeafWait(5000));
        //Vector3 policeVector = new Vector3(0,0,0);

        Node chasing = new DecoratorLoop(
            new Sequence(
                ChaseDaniels(police.transform, participants[index].transform)));
        Func <bool> danny0     = () => (index == 0);
        Func <bool> danny1     = () => (index == 1);
        Func <bool> danny2     = () => (index == 2);
        Node        dannyTest0 = new LeafAssert(danny0);
        Node        dannyTest1 = new LeafAssert(danny1);
        Node        dannyTest2 = new LeafAssert(danny2);

        Node check = new LeafInvoke(() => {
            foreach (GameObject participant in participants)
            {
                Func <bool> measure = () => ((Math.Abs(police.transform.position.z - participant.transform.position.z) < 1) && (Math.Abs(police.transform.position.x - participant.transform.position.x) < 1));
                Node trigger        = new DecoratorLoop(new LeafAssert(measure));
                Node root           = new Sequence(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger, ChaseDaniels(police.transform, participant.transform))));
            }
        });
        Node change = new Sequence(new Race(new LeafWait(10000), ChaseDaniels(police.transform, participants[0].transform)), new Race(new LeafWait(10000), ChaseDaniels(police.transform, participants[1].transform)), new Race(new LeafWait(10000), ChaseDaniels(police.transform, participants[2].transform)));

        //Node trigger = new DecoratorLoop(new LeafAssert(measure));
        //Node change2 =
        Node returnValue2 = new DecoratorLoop(change);

        // Node returnValue3 = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new LeafInvoke(() => { CompleteOpenDoor(specialDaniel.transform); })));

        Node[] rv = new Node[2];
        rv[0] = returnValue;
        rv[1] = returnValue2;
        // rv[2] = returnValue3;
        return(rv);

        //Vector3 min = (participants[0].transform.position - police.transform.position);
        //int index = 0;


        /*
         * Node chase =
         *      new Sequence(new LeafInvoke(() => {
         *          //min = (participants[0].transform.position - police.transform.position);
         *          //for (int i = 1; i < participants.Length; i++)
         *          //{
         *          //    if ((Math.Pow((police.transform.position.x - participants[i].transform.position.x), 2) + Math.Pow((police.transform.position.z - participants[i].transform.position.z), 2) < min.sqrMagnitude))
         *          //    {
         *          //        min = participants[i].transform.position - police.transform.position;
         *          //        index = i;
         *          //    }
         *          //
         *          if (index < 2)
         *              index++;
         *          else
         *              index = 0;
         *      }),ST_ApproachAndWait(participants[index].transform, police.transform));
         *     // new Sequence(ChaseDaniels(police.transform, participants)));
         */
        //return new Sequence(new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(trigger3, chasing))), returnValue);
        //return new Sequence(new DecoratorLoop(new SequenceParallel(new Sequence(chasing, new LeafWait(1000)),returnValue)));
        //return returnValue;
    }
示例#13
0
    protected Node BuildTreeRoot()
    {
        //Node node1 = new Sequence (new LeafWait (1000), this.Conversation (Daniel, Tom, gatherPoint), new LeafWait(1000));
        //Node node2 = new Sequence (new LeafWait(1000), this.ExchangeItem(Daniel, Tom, gatherPoint, ball));
        //Node node3 = new Sequence (new LeafWait(1000), this.Follow(Daniel, Tom, Richard));
        //Node node4 = new Sequence (new LeafWait(1000), this.Haggling(Daniel, Tom)); // TODO: when does this event happen? price = 7? or what?

        Node nodeDanielOut = new Sequence(Daniel.GetComponent <BehaviorMecanim> ().ST_PlayHandGesture("THINK", 1000),
                                          this.ST_turnonlight(Daniel),
                                          this.ST_GetOutHouse(Daniel),
                                          this.ST_SetDanielOut(),
                                          this.ST_WalkTo(Daniel, fishingPoint),
                                          this.ST_LookAT(Daniel, poolCenter));
        Node nodeLuren = new SequenceParallel(
            //this.ST_ThinkUntilClicked (Luren1),
            this.Conversation(Luren1, Luren2, LurenMeetingPoint12),
            this.Conversation(Luren3, Luren4, LurenMeetingPoint34),
            this.Conversation(Luren5, Luren6, LurenMeetingPoint56),
            this.Conversation(Luren7, Luren8, LurenMeetingPoint78));
        //Node nodePolice = new Sequence (
        //	                  this.ST_ThinkUntilClicked (police),
        //	                  this.ChaseBoss ());
        Node nodeFish = new DecoratorInvert(
            new DecoratorLoop(
                new Sequence(
                    Daniel.GetComponent <BehaviorMecanim> ().ST_PlayHandGesture("Fishing", 1000),
                    new DecoratorInvert(this.ST_Call(Daniel)))));
        Node nodeConverse = this.ConversationNtimes(Daniel, Tom, gatherPoint, 2);
        Node nodeSteal    = new Sequence(this.WaitUntilDanielLeave(Richard),
                                         this.ST_GetInHouse(Richard),
                                         this.ST_SetRichardIn(),
                                         Richard.GetComponent <BehaviorMecanim> ().ST_PlayFaceGesture("ROAR", 1000),
                                         this.ST_GrabObj(Richard, ball),
                                         this.ST_GetOutHouse(Richard));
        Node nodeChase   = this.Chase(Richard, Daniel, Tom, chasePoint1);
        Node nodeTomCall = new Sequence(this.WaitUntilRichardIn(Tom),
                                        this.ST_TomCallDaniel(),
                                        new SequenceParallel(
                                            Daniel.GetComponent <BehaviorMecanim> ().ST_PlayBodyGesture("Talking On Phone", 1000),
                                            Tom.GetComponent <BehaviorMecanim> ().ST_PlayBodyGesture("Talking On Phone", 1000)));
        Node nodeExchange = new Sequence(new LeafWait(1000), this.ExchangeItem(Richard, PassengerB, dealPoint, ball), this.ST_DropObj(PassengerB, ball));
        //Node nodeEnd = new Sequence (this.ST_BallUp (), this.ST_SetGameOver (), this.ST_CheerN (PassengerB, 5));
        //Node nodeEnd = new Sequence (this.ST_CheerN (PassengerB, 5), new DecoratorForceStatus(RunStatus.Failure, new LeafWait(1000)));
        Node doorNode      = this.AssertAndWaitForClap();
        Node passengerNode = new Sequence(
            new DecoratorLoop(
                this.ST_Repeat(Passenger)));

        Node nodeMonitorUI    = this.MonitorUI();
        Node nodeMonitorState = this.MonitorState();
        Node nodeStory1       = this.NewConverse();
        Node nodeStory2       = this.NewPolice();

        /*Node root1 = new SequenceParallel (
         *      new Sequence (
         *              new SequenceParallel (
         *                      new Sequence (nodeDanielOut, nodeFish),
         *                      nodeSteal,
         *                      nodeTomCall),
         *              nodeConverse,
         *              nodeChase,
         *              nodeExchange,
         *              this.ST_CheerN(PassengerB, 5)),
         *      doorNode, passengerNode);
         *
         * Node nodestory = new DecoratorLoop (
         *                       new DecoratorForceStatus (RunStatus.Success,
         *                               new Sequence (nodeStory1, nodeStory2)));
         *
         * Node root = new SequenceParallel (root1,
         *                  nodeMonitorUI,
         *                  nodeMonitorState,
         *                  nodestory);*/
        /*
         * Node root = new SequenceParallel (
         *      new Sequence (
         *              new SequenceParallel (
         *                      new Sequence (nodeDanielOut, nodeFish),
         *                      nodeSteal,
         *                      nodeTomCall),
         *              nodeConverse,
         *              nodeChase,
         *              nodeExchange,
         *              this.ST_CheerN(PassengerB, 5)),
         *      doorNode, passengerNode, nodeLuren, nodePolice);
         */
        Node nodePolice1 = new DecoratorLoop(
            new DecoratorForceStatus(RunStatus.Success,
                                     // new SequenceParallel (
                                     new Sequence(this.ST_Repeatpolice(police1, wanderp11, wanderp12))));
        Node nodePolice2 = new DecoratorLoop(
            new DecoratorForceStatus(RunStatus.Success,
                                     // new SequenceParallel (
                                     new Sequence(this.ST_Repeatpolice(police2, wanderp21, wanderp22))));

        /*Node nodePolice3 = new DecoratorLoop (
         *      new DecoratorForceStatus (RunStatus.Success,
         *              // new SequenceParallel (
         *              new Sequence (this.ST_Repeatpolice (police3, wanderp31, wanderp32))));*/
        Node nodePolice4 = new DecoratorLoop(
            new DecoratorForceStatus(RunStatus.Success,
                                     // new SequenceParallel (
                                     new Sequence(this.ST_Repeatpolice(police4, wanderp41, wanderp42))));
        Node nodePolice5 = new DecoratorLoop(
            new DecoratorForceStatus(RunStatus.Success,
                                     // new SequenceParallel (
                                     new Sequence(this.ST_Repeatpolice(police5, wanderp51, wanderp52))));
        //new Sequence (this.ST_Repeatpolice (police2, wanderp21, wanderp22)),
        //new Sequence (this.ST_Repeatpolice (police3, wanderp31, wanderp32)),
        //new Sequence (this.ST_Repeatpolice (police4, wanderp41, wanderp42)),
        //new Sequence (this.ST_Repeatpolice (police5, wanderp51, wanderp52)))));

        Node Danielcontrol = new DecoratorLoop(
            new DecoratorForceStatus(RunStatus.Success,
                                     new Sequence(
                                         this.ST_ThinkUntilClickedLight(Daniel),
                                         this.clickLight(Daniel))));

        Node root = new SequenceParallel(
            this.gameOverNew(), Danielcontrol, doorNode, passengerNode, nodeLuren, nodePolice1, nodePolice2, nodePolice4, nodePolice5);

        return(root);
    }
示例#14
0
    protected Node Simplify(GameObject parta, GameObject partb, GameObject partc)
    {
        // A ask B turn off light
        // A ask C turn on TV

        //Val<bool> pp = Val.V (() => lamp.enabled);
        Func <bool> act     = () => (lamp.enabled);
        Node        trigger = new DecoratorLoop(new LeafAssert(act));

        Func <bool>      playerinRangeA = () => (parta.GetComponentInChildren <PlayerinRange>().playerinRange);
        Func <bool>      playerinRangeB = () => (partb.GetComponentInChildren <PlayerinRange>().playerinRange);
        Func <bool>      playerinRangeC = () => (partc.GetComponentInChildren <PlayerinRange>().playerinRange & (angryCount < 3));
        Func <RunStatus> switchinRange  = () => (lightSwitch.GetComponentInChildren <PlayerinRange>().PlayerInRange()?RunStatus.Success:RunStatus.Running);
        Func <bool>      clicked        = () => (Player.GetComponentInChildren <PlayerController>().clicked);

        Node triggerA      = new DecoratorLoop(new LeafAssert(playerinRangeA));
        Node triggerB      = new DecoratorLoop(new LeafAssert(playerinRangeB));
        Node triggerC      = new DecoratorLoop(new LeafAssert(playerinRangeC));
        Node triggerSwitch = new LeafInvoke(switchinRange);
        Node triggerClick  = new DecoratorLoop(new LeafAssert(clicked));

        Func <bool> angry        = () => (angryCount >= 3);
        Node        triggerAngry = new DecoratorLoop(new LeafAssert(angry));

        Node trigger_preAngry = new LeafAssert(LightOffRole);

        return(new SequenceParallel(
                   new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                              new SequenceParallel(
                                                                  triggerA,
                                                                  new Sequence(
                                                                      this.Greeting("A: ")
                                                                      // this.TextOn("Hi! I'm A",canvasTV, bubbleTextT)
                                                                      )
                                                                  ))
                                     ),
                   new SequenceParallel(
                       new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                                  new SequenceParallel(
                                                                      triggerB,
                                                                      new Sequence(
                                                                          this.Greeting("B: ")
                                                                          // this.TextOn("Hi! I'm B",canvasTV, bubbleTextT)
                                                                          )
                                                                      ))
                                         )),
                   new SequenceParallel(
                       new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                                  new SequenceParallel(
                                                                      triggerC,
                                                                      new Sequence(
                                                                          this.Greeting("C: ")
                                                                          // this.TextOn("Hi! I'm C",canvasTV, bubbleTextT)
                                                                          )
                                                                      ))
                                         )),
                   new SequenceParallel(
                       new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                                  new SequenceParallel(
                                                                      triggerAngry,
                                                                      new Sequence(
                                                                          // this.Greeting("C: ")
                                                                          this.TextOn("B: HEY!!!!!! STOP TOUCHING THE SWITCH!!!!!!", canvasTV, bubbleTextT)
                                                                          )
                                                                      ))
                                         )),
                   new SequenceParallel(

                       new DecoratorLoop(
                           new Sequence(
                               triggerSwitch,
                               new Sequence(this.LightOff(Player.GetComponent <BehaviorMecanim>()), new LeafInvoke(() => this.LightOffRole()))
                               // this.NPCLightOff()
                               )
                           )),
                   new SequenceParallel(
                       new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success,
                                                                  new SequenceParallel(
                                                                      triggerClick,
                                                                      new Sequence(
                                                                          Player.GetComponent <BehaviorMecanim>().Node_GoTo(Player.GetComponentInChildren <PlayerController>().dest)
                                                                          )
                                                                      ))
                                         ))
                   ));
    }
示例#15
0
        protected override bool ShouldGenerateClass(Node node)
        {
            DecoratorLoop decoratorLoop = node as DecoratorLoop;

            return(decoratorLoop != null);
        }
    protected Node BuildTreeRoot()
    {
        Node roaming = new DecoratorLoop(new SequenceShuffle(this.ST_ApproachAndWait(this.wander1), this.ST_ApproachAndWait(this.wander2), this.ST_ApproachAndWait(this.wander3)));

        return(roaming);
    }
示例#17
0
    protected Node BuildTreeRoot()
    {
        bathrooms = GameObject.FindGameObjectsWithTag("Bathroom");
        water     = GameObject.FindGameObjectsWithTag("Water");
        food      = GameObject.FindGameObjectsWithTag("Food");

        Node roaming = new DecoratorLoop(
            new SequenceShuffle(
                //this.WorkAtDesk(this.wander1),
                //this.GetFood(this.wander2),
                //this.ST_ApproachAndWait(this.wander1),
                this.ST_ApproachAndWait(this.wanderDesk),
                this.GetDrinkClosest(),

                this.GetFoodClosest()
                ));
        //return roaming;

        //Food related nodes/conditions
        Func <bool> actFood     = () => (hunger > 120);
        Node        getFood     = new Sequence(this.GetFoodClosest(), this.ST_ApproachAndWait(this.wanderDesk));
        Node        foodTrigger = new DecoratorLoop(new LeafAssert(actFood));

        //Water related nodes/conditions
        Func <bool> actWater     = () => (thirst > 110);
        Node        getWater     = new Sequence(this.GetDrinkClosest(), this.ST_ApproachAndWait(this.wanderDesk));
        Node        waterTrigger = new DecoratorLoop(new LeafAssert(actWater));

        //Bathroom related nodes/conditions
        Func <bool> actBathroom     = () => (bladder > 150);
        Node        goToBathroom    = new Sequence(this.GetBathroomClosest());
        Node        bathroomTrigger = new DecoratorLoop(new LeafAssert(actBathroom));



        //Desk related nodes/conditions
        Func <bool> actDesk      = () => ((thirst <= 110) && (bladder <= 100) && (hunger <= 120));
        Node        returnToDesk = new Sequence(this.ST_ApproachAndWait(this.wanderDesk));  //Add sitting animation
        Node        deskTrigger  = new DecoratorLoop(new LeafAssert(actDesk));

        Node root = new DecoratorLoop(new DecoratorForceStatus(RunStatus.Success, new Sequence(
                                                                   new DecoratorForceStatus(RunStatus.Success, (new SequenceParallel(foodTrigger, getFood))),
                                                                   new DecoratorForceStatus(RunStatus.Success, (new SequenceParallel(waterTrigger, getWater))),
                                                                   new DecoratorForceStatus(RunStatus.Success, (new SequenceParallel(bathroomTrigger, goToBathroom))),
                                                                   new DecoratorForceStatus(RunStatus.Success, (new SequenceParallel(deskTrigger, returnToDesk)))
                                                                   //new SequenceParallel(deskTrigger, this.ST_ApproachAndWait(this.wanderDesk))
                                                                   )));

        return(root);

        //Might need to actually use blackboard method if I can't figure out how to make a sequence continue after
        //condition is changed



        //Create a simple tree with staying at desk (possibly starting there), then moving to water and back when thirsty



        /*Val<float> pp = Val.V (() => police.transform.position.z);
         * Func<bool> act = () => (police.transform.position.z > 10) || (police.transform.position.z < -10);
         * Node roaming = new DecoratorLoop (
         *      new Sequence(
         *              this.ST_ApproachAndWait(this.wander1),
         *              this.ST_ApproachAndWait(this.wander2),
         *              this.ST_ApproachAndWait(this.wander3)));
         * Node trigger = new DecoratorLoop (new LeafAssert (act));
         * Node root = new DecoratorLoop (new DecoratorForceStatus (RunStatus.Success, new SequenceParallel(trigger, roaming)));
         * return root;*/
    }
示例#18
0
    protected Node BuildTreeRoot()
    {
        Node root = new DecoratorLoop(new Sequence(this.ST_HandShake(fighter1, fighter2)));

        return(root);
    }