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;
        }
    }
Пример #3
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;
        }
    }
    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;
        }
    }
    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;
    }