public static List <PlanetDto> CreatePlanets(int randomValue, double starTemperature) { var result = new List <PlanetDto>(); var rand = new Random(randomValue * Settings.Seed); var value = rand.Next(); var numberOfPlanets = Settings.PlanetNumberMinimum + value % (Settings.PlanetNumberMaximum - Settings.PlanetNumberMinimum); for (int i = 0; i < numberOfPlanets; i++) { var mass = Settings.PlanetMassMinimum + rand.NextDouble() * (Settings.PlanetMassMaximum - Settings.PlanetMassMinimum); var radius = Settings.PlanetRadiusMinimum + rand.NextDouble() * (Settings.PlanetRadiusMaximum - Settings.PlanetRadiusMinimum); var distanceToStar = Settings.PlanetDistanceToStarMinimum + rand.NextDouble() * (Settings.PlanetDistanceToStarMaximum - Settings.PlanetDistanceToStarMinimum); var planet = new PlanetDto { Mass = mass, Radius = radius, DistanceToStar = distanceToStar, MinTemperature = Calculate.CalculatePlanetTemperatureMinimum(Settings, mass, distanceToStar, starTemperature), MaxTemperature = Calculate.CalculatePlanetTepmeratureMaximum(Settings, distanceToStar, starTemperature), GravitationalAcceleration = Calculate.CalculatePlanetGravitationalAcceleration(mass, radius), Moons = CreateMoons(value), Name = GeneratePlanetName(randomValue, value), Population = 0, Resources = new ResourcesDto(), Buildings = new BuildingsDto() }; planet.Triats = GenerateTriatsForPlanet(planet, value); result.Add(planet); } return(result); }
private static TriatsDto GenerateTriatsForPlanet(PlanetDto planet, int value) { var rand = new Random(value * Settings.Seed); var triats = new TriatsDto(); triats.Rocky = true; if (Calculate.CalculateIsPlanetGasGiant(planet.Mass, planet.Radius)) { triats.GasGiant = true; triats.Rocky = false; } else if (Calculate.CalculateIsPlanetHasDenseAtmosphere(Settings, planet.Mass, planet.MaxTemperature)) { triats.DenseAtmosphere = true; } else if (!Calculate.CalculateIsPlanetHasAtmosphere(Settings, planet.Mass, planet.MaxTemperature)) { triats.NoAtmosphere = true; } var number = rand.Next() % _modulo; if (triats.Rocky && !triats.NoAtmosphere && number < Settings.PlanetFriendlyAtmosphereChance) { triats.FriendlyAtmosphere = true; } number = rand.Next() % _modulo; if (triats.Rocky && !triats.NoAtmosphere && number < Settings.PlanetToxicAtmosphereChance) { triats.ToxicAtmosphere = true; } number = rand.Next() % _modulo; if (number < Settings.PlanetStrongRadiationChance) { triats.StrongRadiation = true; } number = rand.Next() % _modulo; if (triats.Rocky && number < Settings.PlanetHightVolcanicActivityChance) { triats.HightVolcanicActivity = true; } if ((planet.MinTemperature + planet.MaxTemperature) / 2 > Settings.PlanetHotTreshold) { triats.Hot = true; } else if ((planet.MinTemperature + planet.MaxTemperature) / 2 < Settings.PlanetColdTreshold) { triats.Cold = true; } return(triats); }
public static bool CheckIfSolarSystemExist(int x, int y, int z) { var rand = new Random(Calculate.CalculateProceruralSeed(Settings, x, y, z)); var value = rand.Next() % _modulo; if (value > _modulo - Settings.ChanceToSolarSystemExist) { return(true); } return(false); }
public static StarDto CreateStar(int randomValue) { var rand = new Random(randomValue * Settings.Seed); var value = rand.Next() % (_modulo * 10); var mass = Settings.StarMassMinimum + (value * _modulo * 10) / (Settings.StarMassMaximum - Settings.StarMassMinimum); value = rand.Next() % (_modulo * 10); var radius = Settings.StarRadiusMinimum + (value * _modulo * 10) / (Settings.StarRadiusMaximum - Settings.StarRadiusMinimum); var star = new StarDto { Mass = mass, Radius = radius, Temperature = Calculate.CalculateStarTemeperature(Settings, mass, radius) }; return(star); }
public static SolarSystemDto CreateSolarSystem(int x, int y, int z) { var rand = new Random(Calculate.CalculateProceruralSeed(Settings, x, y, z)); var value = rand.Next() % _modulo; var solarSystem = new SolarSystemDto { CordX = x, CordY = y, CordZ = z }; solarSystem.Star = CreateStar(value); solarSystem.Planets = CreatePlanets(value, solarSystem.Star.Temperature); return(solarSystem); }