void FixedUpdate() { //Checks if the time sice this scritpt stated is greater that current_time if (Time.time > next_time) { population_growth_factor = 0; //Changes the rate of population growth depending on the amount of food if (data_manager_script.Check_Resources(3) >= data_manager_script.Check_Pop_Total() * 10) { population_growth_factor += 20; } else if (data_manager_script.Check_Resources(3) >= data_manager_script.Check_Pop_Total() * 5) { population_growth_factor += 10; } else if (data_manager_script.Check_Resources(3) <= data_manager_script.Check_Pop_Total() * 3) { population_growth_factor -= 20; } if (data_manager_script.Check_Beds_Total() > data_manager_script.Check_Pop_Total() * 1.5) { population_growth_factor += 20; } else if (data_manager_script.Check_Beds_Total() > data_manager_script.Check_Pop_Total() * 1.1) { population_growth_factor += 10; } else if (data_manager_script.Check_Beds_Total() < data_manager_script.Check_Pop_Total() * 0.7) { population_growth_factor -= 10; } //Changes the population population_growth = Mathf.Ceil(data_manager_script.Check_Pop_Total() / 300 * population_growth_factor); data_manager_script.Change_Pop(population_growth); //Add the current time to varible add_time next_time = Time.time + add_time; } //If unemployment goes below zero run the method. if (data_manager_script.Get_Unemployed() < 0) { Unemployment_Controller(); } //When all the citizens die end the game if (data_manager_script.Check_Pop_Total() <= 0) { //SceneManager.LoadScene(1); } }
void FixedUpdate() { //Checks if the time sice this scritpt stated is greater that current_time if (Time.time > next_time) { //Takes away resources from inventory data_manager_script.Change_Resources(3, -Mathf.Floor(data_manager_script.Check_Pop_Total() / 1)); //If the ammount of food goes below 0 if (data_manager_script.Check_Resources(3) < 0) { //Remove population proptional to a quarter of the deficit of food data_manager_script.Change_Pop(Mathf.Floor(data_manager_script.Check_Resources(3) / 4)); //Change the amount of food back to zero data_manager_script.Change_Resources(3, -data_manager_script.Check_Resources(3)); } //Add the current time to varible add_time next_time = Time.time + add_time; } }