public Universe BuildUniverse() { Universe result = new Universe() { Name = "universe 1" }; List <SolarSystem> solarSystems = new List <SolarSystem>(); using (var db = new ASPNetOgameLikeTPContext()) { for (int i = 1; i < this.globalGameConfiguration.SolarSystemNb + 1; i++) { SolarSystem solarSystem = new SolarSystem(); for (int j = 1; j < this.globalGameConfiguration.PlanetsNb + 1; j++) { Planet planet = new Planet(); foreach (var item in this.globalPlanetConfiguration.BuildingsIds) { ResourceGenerator buildingTemp = ConfigurationsUtil.Instance.PlanetResourceGenerators(globalPlanetConfiguration).FirstOrDefault(x => x.Id == item); buildingTemp.Print = DEFAULT_DISPLAY_RESOURCE; buildingTemp.Id = null; planet.Buildings.Add(ClassUtil.Copy(buildingTemp)); } foreach (var item in this.globalPlanetConfiguration.ResourcesIds) { Resource resourceTemp = ConfigurationsUtil.Instance.PlanetResources(globalPlanetConfiguration).FirstOrDefault(x => x.Id == item); resourceTemp.LastUpdate = DateTime.Now; resourceTemp.LastQuantity = 0; resourceTemp.Print = DEFAULT_DISPLAY_RESOURCE; resourceTemp.Id = null; planet.Resources.Add(ClassUtil.Copy(resourceTemp)); } planet.CaseNb = MathUtil.DrawRandom(20 * j % 300, 30 * j % 300); planet.Name = $"Planet{j}"; planet.Print = DEFAULT_DISPLAY_RESOURCE; solarSystem.Planets.Add(planet); } solarSystem.Name = "système solaire " + i; solarSystems.Add(solarSystem); } } result.SolarSystems.AddRange(solarSystems); return(result); }
public List <Resource> PlanetResources(GlobalPlanetConfiguration globalPlanetConfiguration) { List <Resource> result = new List <Resource>(); foreach (var resourceId in globalPlanetConfiguration.ResourcesIds) { var data = Configuration.Resources.FirstOrDefault(x => x.Id == resourceId); data.Print = "Planet"; if (data.LastQuantity == null) { data.LastQuantity = 0; } result.Add(ClassUtil.Copy(data)); } return(result); }
public List <ResourceGenerator> PlanetResourceGenerators(GlobalPlanetConfiguration globalPlanetConfiguration) { List <ResourceGenerator> result = new List <ResourceGenerator>(); foreach (var buildingId in globalPlanetConfiguration.BuildingsIds) { var data = Configuration.ResourceGenerators.FirstOrDefault(x => x.Id == buildingId); data.Print = "Planet"; if (data.Level == null) { data.Level = 0; } result.Add(ClassUtil.Copy(data)); } return(result); }