Exemplo n.º 1
0
    void SelectNextHop()
    {
        lastHop = nextHop;
        var nextHopScript = nextHop.GetComponent <PlanetScript>();
        var forwardOption = nextHopScript.OutgoingPlanets;
        var detour        = new List <GameObject>();

        detour.AddRange(nextHopScript.incomingPlanets);
        detour.AddRange(forwardOption);

        int cnt = forwardOption.Count;

        if (cnt == 0)
        {
            inFlight = false;
            gui.IncDamage();
        }
        else
        {
            foreach (var planet in detour)
            {
                if (planet.GetComponent <PlanetScript>().planetState == PlanetState.Detour)
                {
                    nextHop = planet;
                    return;
                }
            }

            nextHop = forwardOption[UnityEngine.Random.Range(0, cnt)];
        }
    }