Beispiel #1
0
    void StartJourney()
    {
        Map         map        = GameObject.FindGameObjectWithTag("Map").GetComponent <Map>();
        RouteFinder pathFinder = new RouteFinder(map);

        Cell currentCell = GetCurrentCell();

        if (currentCell == null)
        {
            ChangeBehavior(Behavior.Confusing);
            return;
        }
        if (CurrentBehavior == Behavior.Journey)
        {
            Route = pathFinder.getRandom(currentCell);
        }
        else
        {
            Route = pathFinder.getNearTarget(currentCell);
        }

        if (Route.Count > 0)
        {
            destinationCell = Route.ToArray()[Route.Count - 1];
            nextCell        = Route.Dequeue();
        }
        else
        {
            ChangeBehavior(Behavior.Confusing);
        }
    }