Exemple #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);
        }
Exemple #2
0
 private int CalculatePlanetCapacity(GalaxyGeneratorSettings settings)
 {