Пример #1
0
    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);
    }
Пример #2
0
    public void StartHiring(DateTime currentDate, HiringMethod method,
                            Action <List <Employee> > callback)
    {
        onHiringEnded = callback;

        int candidatesNumber = Random.Range(method.CandidatesDistribution.Item1,
                                            method.CandidatesDistribution.Item2 + 1); // upper bound is inclusive by convention

        if (candidatesNumber <= 0)
        {
            Debug.LogWarning($"GameDevCompany.StartHiring : no candidates with Method \"{method.Name}\".");
            callback(null);
        }
        List <Employee> candidates = new List <Employee>();

        for (int i = 0; i < candidatesNumber; i++)
        {
            Employee employee = null;
            candidates.Add(employee);
        }

        hiringEndingDate = currentDate.AddDays(method.DurationInDays);
    }