protected override void onStart() { TerritoryData countryData = time.GetComponent <TerritoryData>(); //Load game content from the file Dictionary <string, int[]> populationData = JsonConvert.DeserializeObject <Dictionary <string, int[]> >(rawContent.text); // Réinitialiser les données de la nation pour être sûr de les synchroniser avec les données accumulées des régions for (int age = 0; age < countryData.popNumber.Length; age++) { countryData.popNumber[age] = 0; } foreach (GameObject territory in f_territories) { TerritoryData territoryData = territory.GetComponent <TerritoryData>(); territoryData.popNumber = populationData[territoryData.TerritoryName]; int total = 0; int max = 0; for (int age = 0; age < territoryData.popNumber.Length; age++) { total += territoryData.popNumber[age]; max = Mathf.Max(max, territoryData.popNumber[age]); // accumulation au niveau national countryData.popNumber[age] += territoryData.popNumber[age]; } territoryData.nbPopulation = total; // Calcul de la puissance de 10 immediatement supérieure au maximum int multipleOfThousand = 0; int reste = 0; while (max - 1000 > 0) { max -= 1000; multipleOfThousand++; reste = max % 10; } multipleOfThousand++; territoryData.maxNumber = Mathf.Max(10000, multipleOfThousand * 1000); } territorySelected = countryData; territoryName.text = territorySelected.TerritoryName; }