예제 #1
0
        public Galaxy Generate(GalaxyGeneratorSettings settings)
        {
            // TODO: Validate settings

            if (CalculatePlanetCapacity(settings) < settings.PlanetCount)
            {
                throw new OutOfSpaceException($"Not enough space for planets in the galaxy.");
            }

            Galaxy galaxy = new Galaxy()
            {
                Bounds = new GalaxyBounds(settings.GalaxySize)
            };

            var planets = RandomPositions(settings)
                          .Take(settings.PlanetCount)
                          .Select(CreatePlanet);

            galaxy.Planets.AddRange(planets);

            return(galaxy);
        }
예제 #2
0
 private int CalculatePlanetCapacity(GalaxyGeneratorSettings settings)
 {