Exemple #1
0
    void ManageEmployeeExperience()
    {
        for (int i = 1; i < EmployeeList.Count; i++)
        {
            if (EmployeeList[i].Experience < EmployeeList[i].BaseInfo.LaborForce * 10 && EmployeeList[i].isWorking)
            {
                EmployeeList[i].Experience++;

                if (CompanyValueCall.CompanyName == CompanyManagerCall.PlayerCompanyName)
                {
                    if (PanelControllerCall.CurrentSidePanel != null)
                    {
                        if (PanelControllerCall.CurrentSidePanel.name == "WorkerPanel")
                        {
                            WorkerPanelController PanelComponent = PanelControllerCall.CurrentSidePanel.GetComponent <WorkerPanelController>();

                            if (PanelComponent.CurrentWorkerIndex == i)
                            {
                                PanelComponent.UpdateInfoPanel();
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
    void UpdateLaborForce()
    {
        List <EmployeeInfo> DeleteList = new List <EmployeeInfo>();

        foreach (var Employee in EmployeeList)
        {
            if (Employee.BaseInfo.LaborForceLossRate == 0)
            {
                continue;
            }

            if (Employee.Happiness <= 0)
            {
                DeleteList.Add(Employee);
                continue;
            }

            if (Employee.isWorking)
            {
                if (Employee.FatigueValue < Employee.BaseInfo.LaborForce)
                {
                    Employee.FatigueValue += Employee.BaseInfo.LaborForce * Employee.BaseInfo.LaborForceLossRate / 500;
                }
                else
                {
                    Employee.FatigueValue = Employee.BaseInfo.LaborForce;
                }
            }
            else if (Employee.isResting)
            {
                if (Employee.FatigueValue > 0)
                {
                    Employee.FatigueValue -= (Employee.BaseInfo.LaborForce * (Employee.CurrentSincerityRate / 500)) * Employee.CurrentDayRoom.CurrentPerformance;
                }

                if (Employee.FatigueValue < 0)
                {
                    Employee.FatigueValue = 0;
                }
            }

            if (Employee.FatigueValue > 0.3f && !Employee.isResting)
            {
                List <DayRoomInfo> AvaliableDayRoomList = new List <DayRoomInfo>();
                foreach (var DayRoom in DayRoomList)
                {
                    if (DayRoom.Info.ObjectActCall.WorkSpeed > 0f)
                    {
                        AvaliableDayRoomList.Add(DayRoom);
                    }
                }

                for (int i = AvaliableDayRoomList.Count - 1; i >= 0; i--)
                {
                    DayRoomInfo Target = AvaliableDayRoomList[Random.Range(0, AvaliableDayRoomList.Count)];
                    if (Target.DayRoomActCall.EmployeeCapacity > Target.DayRoomActCall.RestingEmployeeList.Count)
                    {
                        Target.DayRoomActCall.EmployeeEnroll(Employee);
                        // Debug.Log(Employee.BaseInfo.Name + " is going to rest " + Employee.FatigueValue);
                        break;
                    }
                    AvaliableDayRoomList.Remove(Target);
                }
            }

            if (TimeManagerCall.TimeValue % TimeManagerCall.Hour < TimeManagerCall.PlaySpeed)
            {
                if (Employee.FatigueValue >= 0.5f)
                {
                    if (Employee.CurrentLaborForce > Employee.BaseInfo.LaborForce / 4)
                    {
                        Employee.CurrentLaborForce -= 0.1f;
                    }
                    Employee.Happiness -= 0.05f;
                }
                else
                {
                    if (Employee.CurrentLaborForce < Employee.BaseInfo.LaborForce)
                    {
                        Employee.CurrentLaborForce += 0.5f;
                    }

                    if (Employee.Happiness < 1f)
                    {
                        Employee.Happiness += 0.005f;
                    }
                    else
                    {
                        Employee.Happiness = 1f;
                    }
                }

                if (CompanyValueCall.CompanyName == CompanyManagerCall.PlayerCompanyName)
                {
                    if (PanelControllerCall.CurrentSidePanel != null)
                    {
                        if (PanelControllerCall.CurrentSidePanel.name == "WorkerPanel")
                        {
                            WorkerPanelController PanelComponent = PanelControllerCall.CurrentSidePanel.GetComponent <WorkerPanelController>();
                            if (PanelComponent.CurrentWorkerIndex == GetEmployeeIndex(Employee))
                            {
                                PanelComponent.UpdateInfoPanel();
                            }
                        }
                    }
                }
            }
        }

        if (DeleteList.Count > 0)
        {
            string LeaveNameList = "";
            for (int i = 0; i < DeleteList.Count; i++)
            {
                LeaveNameList += DeleteList[i].BaseInfo.Name + " ";
                DeleteEmployee(DeleteList[i]);
            }

            if (CompanyValueCall.CompanyName == GameObject.Find("CompanyManager").GetComponent <CompanyManager>().PlayerCompanyName)
            {
                if (DeleteList.Count > 1)
                {
                    LeaveNameList += "are";
                }
                else
                {
                    LeaveNameList += "is";
                }

                GameObject.Find("NotificationManager").GetComponent <NotificationManager>().AddNews("Info", LeaveNameList + " Leave your factory.");
                // Debug.Log(LeaveNameList + " Leave your factory.");
            }

            DeleteList.Clear();
        }
    }