コード例 #1
0
    private void AddChallenges()
    {
        if (challenges.Count == 0)
        {
            return;
        }
        float totalChallengeRating = challengeRating * levelIndexMultiplier;
        int   iterations           = 9999;

        while (totalChallengeRating > 0 && iterations > 0)
        {
            iterations--;
            challenges = RandomUtil.ShuffleHostList(challenges.Cast <IGeneratedHostInhabitant>().ToList()).Cast <IChallenge>().ToList();
            IChallenge challenge = challenges.Find(c => c.GetChallengeRating() <= totalChallengeRating);
            if (challenge == null)
            {
                break;
            }
            if (!GetSpawnDirectory(out Directory directory, challenge as IGeneratedHostInhabitant))
            {
                continue;
            }
            EntityHandler.I.CreateChallengeAt(directory, challenge, out IChallenge newChallenge);
            totalChallengeRating -= challenge.GetChallengeRating();
        }
    }