Exemplo n.º 1
0
    private IEnumerator RunBehavior(Repeator repeat)
    {
        Node.NodeState result = repeat.Evaluate();
        while (result == Node.NodeState.RUNNING)
        {
            Debug.Log(repeat.ToString() + " result: " + result);
            yield return(new WaitForSeconds(5f));

            result = repeat.Evaluate();
        }
    }
Exemplo n.º 2
0
    private void ConstructBehaviourTree()
    {
        OrderGenerator       orderGenerator     = new OrderGenerator(gameM.stockItems, gameM.nbItemsOrdered, this);
        ArriveAtPosition     arriveAtPosition   = new ArriveAtPosition(this);
        IsQueueSpotAvailable queueSpotAvailable = new IsQueueSpotAvailable(spawnM.availableQueue, gameM.playerTransform, this);
        GoToQueueSpot        goToQueueSpot      = new GoToQueueSpot(agent, this);
        IsLootSpotAvailable  lootSpotAvailable  = new IsLootSpotAvailable(spawnM.availableLoot, gameM.playerTransform, this);
        GoToLootSpot         goToLootSpot       = new GoToLootSpot(agent, this);
        RandomStateNode      randomStateNode    = new RandomStateNode(spawnM);
        ClientStateNode      clientStateNode    = new ClientStateNode(spawnM.clientOnly, gameM.nbClient, agent.speed, this);
        ThiefStateNode       thiefStateNode     = new ThiefStateNode(spawnM.thiefOnly, gameM.nbThief, agent.speed, this);
        FindState            findState          = new FindState(this);



        Sequence orderSequence = new Sequence(new List <Node> {
            orderGenerator
        });

        //Sequence goingToCounter = new Sequence(new List<Node> { goToQueueSpot, goToPosition);
        //Selector goToposition = new Selector(new List<Node> { orderSequence, goingToCounter });
        repeatMovingToSpot = new Repeator(goToQueueSpot);
        Sequence goToQueueSpotSequence = new Sequence(new List <Node> {
            queueSpotAvailable, repeatMovingToSpot, orderSequence
        });
        Sequence goToLootSpotSequence = new Sequence(new List <Node> {
            lootSpotAvailable, goToLootSpot
        });

        Sequence thiefSequence = new Sequence(new List <Node> {
            thiefStateNode, goToLootSpotSequence
        });
        Sequence clientSequence = new Sequence(new List <Node> {
            clientStateNode, goToQueueSpotSequence
        });

        Selector GoToStateSelector = new Selector(new List <Node> {
            clientSequence, thiefSequence
        });
        Sequence randomBoolSequence = new Sequence(new List <Node> {
            findState, GoToStateSelector
        });
        Sequence randomSequence = new Sequence(new List <Node> {
            randomBoolSequence, randomStateNode
        });

        topNode = new Selector(new List <Node> {
            randomSequence, clientSequence, thiefSequence
        });

        //Debug.Log(findState.Evaluate());
        //Debug.Log(clientSequence.Evaluate());
        //Debug.Log(randomBoolSequence.Evaluate());
    }
Exemplo n.º 3
0
 private void CheckIfRepeatRunning(Repeator repeat)
 {
     if (repeat.Evaluate() != Node.NodeState.RUNNING)
     {
         isInPosition = true;
     }
     else
     {
         isInPosition   = false;
         behavior       = StartCoroutine(RunBehavior(repeat));
         startBehaviour = true;
     }
 }