public void OnNewDay(IScriptContext context) { if (context.D() == hiringEndingDate) { FinishHiring(); } if (currentProject == null) { return; } foreach (Employee employee in employees) { employeesManager.ApplyDayProgress(employee, context); } if (currentProject.OnDateModified(context.D())) { CompleteCurrentProject(); } }
public Employee GenerateRandomEmployee(IScriptContext context, HiringMethod hiringMethod, Names commonNames, Database.Database.DatabaseCollection <Skill> skillsCollection, out float hiringCost) { // Sex bool male = Random.value > 0.5f; // Name string firstName = commonNames.RandomFirstName(male); string lastName = commonNames.RandomLastName(); // Skills EmployeeSkill[] skills = new EmployeeSkill[hiringMethod.SkillsDistribution.Length]; for (int i = 0; i < hiringMethod.SkillsDistribution.Length; i++) { var skillDistribution = hiringMethod.SkillsDistribution[i]; string skillId = skillDistribution.Item1; Skill skillInfo = skillsCollection.FindById(skillId); if (skillInfo == null) { Debug.LogError($"Staff.GenerateRandomEmployee : invalid skill ID {skillId} in Hiring Method of ID {hiringMethod.Id}."); hiringCost = -1f; return(null); } int proficiency = Random.Range(skillDistribution.Item2, skillDistribution.Item3 + 1); // upper bound is inclusive by convention skills[i] = new EmployeeSkill(skillId, skillInfo.Name, proficiency); } // Game Object Creation Employee employee = Instantiate(employeeModel); Employee generated = new Employee(firstName, lastName, 0, context.D(), skills); // TODO : find other way employee.CopyEmployee(generated); employee.name = $"Employee_{generated.Id}"; context.SetCurrentEmployee(employee); // Hiring cost and salary hiringCost = ComputeEmployeeHiringCost(context); employee.Salary = ComputeEmployeeSalary(context); context.SetCurrentEmployee(null); employee.gameObject.SetActive(true); return(employee); }