示例#1
0
    void ProbabilityRevision()
    {
        int survivablePlanetCount = 0;
        int planetCount           = 0;

        for (int i = 2; i <= 4; i++)
        {
            for (int j = 0; j < sectorTiles[i].onSector.transform.childCount; j++)
            {
                planetCount++;
                if (sectorTiles[i].onSector.transform.GetChild(j).GetComponent <PlanetBase>().canSurvive)
                {
                    survivablePlanetCount++;
                }
            }
        }

        while ((float)survivablePlanetCount / (float)planetCount < dm.GetCurrentSectorData(currentSector).minimumSuccessRate / 9.0f)
        {
            Sector     s = sectorTiles[Random.Range(2, 5)].onSector;
            PlanetBase p = s.transform.GetChild(Random.Range(0, s.transform.childCount)).GetComponent <PlanetBase>();
            if (p.canSurvive == false && p.isExplored == false)
            {
                p.SetData(planetFactory.GetScript(true), true);
                survivablePlanetCount++;
            }
        }
    }