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; } }