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() { //If Collector_Change is greater than zero and bool is true if (data_manager_script.Get_Collector_Change() > 0 && selected == true) { //Subtracts that worker from the employer slots data_manager_script.Change_Collector_Amount(-1); //Sets bool to true harvested = true; //Creates a time delay next_time = Time.time + add_time; } //If bool is true and time delay has run out if (harvested == true && Time.time > next_time) { //Checks to see if it will go over the maximum storage. if (data_manager_script.Check_Resources(4) + 10 <= data_manager_script.Get_Max_Storage()) { //Add resources to inventory data_manager_script.Change_Resources(4, 10); } //Add one to the Collector_Amount data_manager_script.Change_Collector_Amount(1); //Destroys the gameobject Destroy(gameObject); } }
void FixedUpdate() { //Check if there is and local jobs available and if there is any workers available if (local_employed < max_employed && data_manager_script.Check_Employer_Slots(0) > 0) { //Subtracts that worker from the employer slots data_manager_script.Change_Employer_Slots(0, -1); //Add a worker to the local_employed local_employed += 1; } //Checks if there is a local worker and that the employer slots are negative if (local_employed > 0 && data_manager_script.Check_Employer_Slots(0) < 0) { //Adds a worker to the employer slots data_manager_script.Change_Employer_Slots(0, 1); //Subtracts a worker to the local_employed local_employed -= 1; } //Checks if the time sice this scritpt stated is greater that current_time if (Time.time > next_time) { //Checks to see if it will go over the maximum storage. if (data_manager_script.Check_Resources(1) + 6 * local_employed / max_employed <= data_manager_script.Get_Max_Storage()) { //Add resources to inventory data_manager_script.Change_Resources(1, 6 * local_employed / max_employed); } //Add the current time to varible add_time next_time = Time.time + add_time; } }
void FixedUpdate() { //Check if there is and local jobs available and if there is any workers available if (local_employed < max_employed && data_manager_script.Check_Employer_Slots(2) > 0) { //Subtracts that worker from the employer slots data_manager_script.Change_Employer_Slots(2, -1); //Add a worker to the local_employed local_employed += 1; } //Checks if there is a local worker and that the employer slots are negative if (local_employed > 0 && data_manager_script.Check_Employer_Slots(2) < 0) { //Adds a worker to the employer slots data_manager_script.Change_Employer_Slots(2, 1); //Subtracts a worker to the local_employed local_employed -= 1; } //Checks if the time sice this scritpt stated is greater that current_time if (Time.time > next_time) { //Checks to see it adding this resource will put it over the max_storage if (data_manager_script.Check_Resources(3) + Mathf.Ceil(area * local_employed / max_employed) * 1000 <= data_manager_script.Get_Max_Storage()) { //Add resources to inventory data_manager_script.Change_Resources(3, Mathf.Ceil(area * local_employed / max_employed) * 1000); } //Add the current time to varible add_time next_time = Time.time + add_time; } }
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; } }
void Update() { //If you are not clicking then button_pressed equals false if (Input.GetMouseButton(0) == false) { button_pressed = false; } //If a button is pressed run the method in the brackets button_house.onClick.AddListener(House_Button); button_road.onClick.AddListener(Road_Button); button_warehouse.onClick.AddListener(Warehouse_Button); button_market_stall.onClick.AddListener(Market_Stall_Button); button_forestry.onClick.AddListener(Forestry_Button); button_mine.onClick.AddListener(Mine_Button); button_farm.onClick.AddListener(Farm_Button); button_collect_all.onClick.AddListener(Collect_All_Button); button_collect_wood.onClick.AddListener(Collect_Wood_Button); button_collect_stone.onClick.AddListener(Collect_Stone_Button); button_collect_iron.onClick.AddListener(Collect_Iron_Button); button_market_trade.onClick.AddListener(Market_Trade_Button); button_politics.onClick.AddListener(Politics_Button); button_inventory.onClick.AddListener(Inventory_Button); button_data.onClick.AddListener(Data_Button); button_bulldoze.onClick.AddListener(Bulldoze_Button); general_buildings_button.onClick.AddListener(General_Buildings_Button); utility_buildings_button.onClick.AddListener(Utility_Buildings_Button); resource_buildings_button.onClick.AddListener(Resource_Buildings_Button); resource_collection_button.onClick.AddListener(Resource_Collection_Button); market_trade_button.onClick.AddListener(Market_Trade_Button); politics_button.onClick.AddListener(Politics_Button); //Calls methods if buttons are pressed button_increase_builder.onClick.AddListener(Builder_Increase_Button); button_decrease_builder.onClick.AddListener(Builder_Decrease_Button); button_increase_forester.onClick.AddListener(Forester_Increase_Button); button_decrease_forester.onClick.AddListener(Forester_Decrease_Button); button_increase_miner.onClick.AddListener(Miner_Increase_Button); button_decrease_miner.onClick.AddListener(Miner_Decrease_Button); button_increase_farmer.onClick.AddListener(Farmer_Increase_Button); button_decrease_farmer.onClick.AddListener(Farmer_Decrease_Button); button_increase_trader.onClick.AddListener(Trader_Increase_Button); button_decrease_trader.onClick.AddListener(Trader_Decrease_Button); //Changes Text to the type plus the amount in storage //Converts the data obtained to a string text_wood.text = ("Wood: " + data_manager_script.Check_Resources(1)); text_stone.text = ("Stone: " + data_manager_script.Check_Resources(2)); text_iron.text = ("Iron: " + data_manager_script.Check_Resources(4)); text_income.text = ("Income: " + data_manager_script.Check_Total_Income()); text_gold.text = ("Gold: " + data_manager_script.Check_Resources(0)); text_food.text = ("Food: " + data_manager_script.Check_Resources(3)); text_population.text = ("Population: " + data_manager_script.Check_Pop_Total()); text_homeless.text = ("Homeless " + data_manager_script.Get_Homeless()); //Get the total number of citizens without jobs text_unemployed.text = ("Unemployed: " + data_manager_script.Get_Unemployed()); //Changes the text to total employed / total jobs for each specific job text_builder.text = ("Builder: " + (data_manager_script.Check_Total_Employed(4) + "/" + data_manager_script.Check_Jobs(4))); text_forester.text = ("Forester: " + data_manager_script.Check_Total_Employed(0) + "/" + data_manager_script.Check_Jobs(0)); text_miner.text = ("Miner: " + data_manager_script.Check_Total_Employed(1) + "/" + data_manager_script.Check_Jobs(1)); text_farmer.text = ("Farmer: " + data_manager_script.Check_Total_Employed(2) + "/" + data_manager_script.Check_Jobs(2)); text_trader.text = ("Trader: " + data_manager_script.Check_Total_Employed(3) + "/" + data_manager_script.Check_Jobs(3)); }
public void Building_Placer_Controller() { //Calls function Get_Mouse_Pos and returns vector3 mouse_pos = mouse_position_script.Get_Mouse_Pos(); //Makes sure that the object isnt inside another object //Checks to see if you have enough resources in the inventory //Makes sure you arent clicking a button if (Input.GetMouseButtonUp(0) && ui_manager_script.Get_Button_Pressed() == false && is_colliding == false && gold_cost <= data_manager_script.Check_Resources(0) && wood_cost <= data_manager_script.Check_Resources(1) && stone_cost <= data_manager_script.Check_Resources(2) && iron_cost <= data_manager_script.Check_Resources(3)) { //Places a building at mouse Instantiate(perm_building, mouse_pos, rot_building); //Takes away the correct amount of resoucrces for the building data_manager_script.Change_Resources(1, -gold_cost); data_manager_script.Change_Resources(1, -wood_cost); data_manager_script.Change_Resources(2, -stone_cost); data_manager_script.Change_Resources(1, -iron_cost); //Changes the amount of that type of building in the list by 1 data_manager_script.Change_Building(current_building_key, 1); } else { //Destroys the old tempereary building and creates new one at the mouse Destroy(temp_building_object); temp_building_object = Instantiate(temp_building, mouse_pos, rot_building); } //If R is pressed call the method if (Input.GetKeyDown("r") == true) { Building_Rotation(); } //Every time the script is run it resets the bool to false is_colliding = false; }