public void AddLaborInfo(FacilityValue.FacilityInfo Info) { if (Info.ObjectActCall.Info.Type == "DayRoom") { DayRoomInfo newInfo = new DayRoomInfo(); newInfo.Info = Info; newInfo.DayRoomActCall = Info.Object.GetComponent <DayRoomAct>(); DayRoomList.Add(newInfo); } else { LaborInfo newInfo = new LaborInfo(); newInfo.Info = Info; LaborInfoList.Add(newInfo); if (Info.ObjectActCall.Info.LaborRequirement > 0) { RequiredLabor += Info.ObjectActCall.Info.LaborRequirement; RotateTimer = RotateTimeLimit; } } if (CompanyValueCall.CompanyName == CompanyManagerCall.PlayerCompanyName) { PanelControllerCall.UpdateFactoryInfo("Employee", TotalLabor, RequiredLabor); } }
public void DeleteLaborInfo(FacilityValue.FacilityInfo Info) { if (Info.ObjectActCall.Info.Type == "DayRoom") { DayRoomInfo Target = null; foreach (var Supply in DayRoomList) { if (Supply.Info == Info) { Target = Supply; break; } } if (Target != null) { DayRoomList.Remove(Target); } } else { LaborInfo Target = null; foreach (var Usage in LaborInfoList) { if (Usage.Info == Info) { Target = Usage; break; } } if (Target != null) { LaborInfoList.Remove(Target); } if (Target.Info.ObjectActCall.Info.LaborRequirement != 0) { RotateTimer = RotateTimeLimit; } } if (CompanyValueCall.CompanyName == CompanyManagerCall.PlayerCompanyName) { PanelControllerCall.UpdateFactoryInfo("Employee", TotalLabor, RequiredLabor); } }
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(); } }