Exemple #1
0
    public CharacterData BuildRandomCharacter(Quirk quirkOverride = null, Spell spellOverride = null)
    {
        CharacterData randomCharacter = ScriptableObject.CreateInstance <CharacterData>();

        int    genderNum = Random.Range(0, 2);
        string gender    = genderNum == 0 ? "MALE" : "FEMALE";

        // todo bdsowers - add large window for taglines + bios, names
        // also pull from the NEUTRAL list for taglines + bios

        randomCharacter.age = GenerateCharacterAge();

        List <string> taglines = new List <string>();

        LocalizedText.GetKeysInListCopy("[NEUTRAL_TAGLINE]", taglines);
        LocalizedText.GetKeysInListCopy("[MALE_TAGLINE]", taglines);
        LocalizedText.GetKeysInListCopy("[FEMALE_TAGLINE]", taglines);

        List <string> bios = new List <string>();

        LocalizedText.GetKeysInListCopy("[NEUTRAL_BIO]", bios);
        LocalizedText.GetKeysInListCopy("[MALE_BIO]", bios);
        LocalizedText.GetKeysInListCopy("[FEMALE_BIO]", bios);

        // To get our repetition guards to work properly, things need to maintain positions.
        // But we still want to support gendered text, so create a temporary ignore list
        // that contains the previously used positions plus any gender-invalid positions
        List <int> ignoreList = new List <int>(previouslyUsedBios);
        string     invalid    = "[MALE";

        if (genderNum == 0)
        {
            invalid = "[FEMALE";
        }

        for (int i = 0; i < bios.Count; ++i)
        {
            if (bios[i].StartsWith(invalid))
            {
                ignoreList.Add(i);
            }
        }

        int bioAndTaglinePosition = bios.SamplePosition(ignoreList);

        randomCharacter.bio              = bios[bioAndTaglinePosition];
        randomCharacter.characterName    = LocalizedText.GetKeysInList("[" + gender + "_NAME]").Sample((genderNum == 0 ? previouslyUsedMaleNames : previouslyUsedFemaleNames));
        randomCharacter.levelRequirement = 1;

        List <CharacterModelData> unusableModels = new List <CharacterModelData>(previouslyUsedModels);

        unusableModels.Add(PlayerModel());

        CharacterModelData modelData = Game.instance.characterDataList.CharacterModelsWithGender(genderNum).Sample(unusableModels);

        randomCharacter.model             = modelData.model.name;
        randomCharacter.tagline           = taglines[bioAndTaglinePosition];
        randomCharacter.characterUniqueId = randomCharacter.characterName + ":::" + randomCharacter.bio + ":::" + randomCharacter.tagline + ":::" + randomCharacter.model;
        randomCharacter.quirk             = QuirksInLevel(Game.instance.playerData.attractiveness, -1, Game.instance.playerData.scoutLevel, -1).Sample(previouslyUsedQuirks).GetComponent <Quirk>();
        randomCharacter.spell             = SpellsInLevel(Game.instance.playerData.attractiveness, -1, Game.instance.playerData.scoutLevel, -1).Sample(previouslyUsedSpells).GetComponent <Spell>();
        randomCharacter.statBoost         = (CharacterStatType)Random.Range(1, 6);
        randomCharacter.statBoostAmount   = 1 + Random.Range(0, MaximumPassiveStatBoost(randomCharacter.statBoost) + 1);
        randomCharacter.material          = materials.Sample();

        if (quirkOverride != null)
        {
            randomCharacter.quirk = quirkOverride;
        }

        if (spellOverride != null)
        {
            randomCharacter.spell = spellOverride;
        }

        previouslyUsedQuirks.AddWindowed(randomCharacter.quirk, GAMEPLAY_REUSE_WINDOW_SIZE);
        previouslyUsedSpells.AddWindowed(randomCharacter.spell, GAMEPLAY_REUSE_WINDOW_SIZE);
        previouslyUsedModels.AddWindowed(modelData, GAMEPLAY_REUSE_WINDOW_SIZE);

        previouslyUsedBios.AddWindowed(bioAndTaglinePosition, TEXT_REUSE_WINDOW_SIZE);
        if (genderNum == 0)
        {
            previouslyUsedMaleNames.AddWindowed(randomCharacter.characterName, TEXT_REUSE_WINDOW_SIZE);
        }
        else
        {
            previouslyUsedFemaleNames.AddWindowed(randomCharacter.characterName, TEXT_REUSE_WINDOW_SIZE);
        }

        return(randomCharacter);
    }