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;
        }
    }
예제 #2
0
    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;
        }
    }