예제 #1
0
    public static Contract[] GenerateContracts(int contracts)
    {
        int team_size = Company.MyCompany == null ? 1 : Company.MyCompany.TeamSize;
        //int reputation = Company.MyCompany == null ? Character.MyCharacter.Reputation : Company.MyCompany.Reputation;
        //reputation = Mathf.Clamp(reputation, 0, 100);
        int reputation = 100;

        Contract[] generated_contracts = new Contract[contracts];

        int char_name_val = Character.MyCharacter.Name.Aggregate(0, (current, c) => current + c);

        Random.InitState(TimeManager.Week * TimeManager.Year * (char_name_val + 1));

        int contract_difficulty = team_size == 1 ? 1 : Mathf.CeilToInt(Mathf.Log(team_size, 2.0f));

        Debug.Log(contract_difficulty);

        for (int i = 0; i < generated_contracts.Length; i++)
        {
            int          days_to_complete = Random.Range(7, 28);
            var          template         = ContractTemplate.GetRandomTemplate();
            SkillLevel[] skills_needed    = new SkillLevel[template.SkillsNeeded.Length];

            for (int j = 0; j < skills_needed.Length; j++)
            {
                int skill_sum = 0;
                for (int d = 0; d < days_to_complete; d++)
                {
                    skill_sum += contract_difficulty * Random.Range(2, 8);
                }
                skills_needed[j] = new SkillLevel(template.SkillsNeeded[j], skill_sum);
            }

            var contract_reqs = new SkillList(skills_needed);

            int payout = Mathf.CeilToInt(skills_needed.Sum(x => x.Level) * 8 * Random.Range(0.8f, 1.2f));
            if (reputation < 10)
            {
                payout = Mathf.CeilToInt(payout * 0.5f);
            }
            if (reputation > 90)
            {
                payout = Mathf.CeilToInt(payout * 2.0f);
            }
            payout = 10 * ((payout + 9) / 10);

            generated_contracts[i] = new Contract(
                template.ContractName,
                contract_reqs,
                days_to_complete,
                payout,
                contract_difficulty * 2);
        }

        return(generated_contracts);
    }