Пример #1
0
    private static void AddMonster(Vector3 position, int minLevel, int maxLevel)
    {
        var xRoll       = RNG.Float(position.x - 3, position.x + 3);
        var yRoll       = RNG.Float(position.z - 3, position.z + 3);
        var typeRoll    = RNG.Int(0, monsterTypes.Count);
        var name        = monsterTypes[typeRoll];
        int qualityRoll = RNG.Int(0, 100);
        int quality     = 0;

        if (qualityRoll < 50)
        {
            quality = 0;
        }
        else if (qualityRoll < 80)
        {
            quality = 1;
        }
        else if (qualityRoll < 95)
        {
            quality = 2;
        }
        else
        {
            quality = 3;
        }
        var data = new MonsterData(name, name, RNG.Int(minLevel, maxLevel + 1), quality, null);

        InstantiateMonster(data, xRoll, yRoll);
    }
Пример #2
0
 public static AbilityAttribute Generate(PassiveAbility ability, string attributeType)
 {
     for (int i = 0; i < 10000; i++)
     {
         AbilityAttribute attribute;
         if (simpleAttributes.Contains(attributeType))
         {
             attribute = new AbilityAttribute {
                 type = attributeType
             };
             attribute.priority = RNG.Float(12.5f, 100f);
             attribute.points   = AbilityAttributeAppraiser.Appraise(ability, attribute);
             return(attribute);
         }
         attribute = attributes[attributeType](ability);
         if (attribute != null)
         {
             attribute.priority = RNG.Float(12.5f, 100f);
             attribute.points   = AbilityAttributeAppraiser.Appraise(ability, attribute);
             return(attribute);
         }
     }
     Debug.Log("FAILED TO FIND VALID ATTRIBUTE FOR ABILITY!");
     return(null);
 }
Пример #3
0
    private void GetRemoveActivateAttribute(SoulGemEnhancement effect)
    {
        var attribute = ability.FindAttribute(effect.target);

        if (attribute != null)
        {
            attribute.priority = RNG.Float(0, 49f);
            ability.SortAttributes();
        }
    }
Пример #4
0
    private void GetRemoveRemoveDrawback(SoulGemEnhancement effect)
    {
        var attribute = AbilityAttributeGenerator.Generate(ability, effect.target);

        if (attribute != null)
        {
            ability.attributes.Add(attribute);
            attribute.priority = RNG.Float(50f, 100f);
            ability.SortAttributes();
        }
    }
Пример #5
0
        public List <IRandomizerObject> Evaluate()
        {
            this.unique.Clear();

            var result = new List <IRandomizerObject>();

            var enabled    = Contents.Where(item => item.Enabled).ToList();
            var guaranteed = enabled.Where(item => item.Guaranteed).ToList();

            foreach (var item in guaranteed)
            {
                PopulateResult(result, item);
            }

            var unguaranteedCount = Count - guaranteed.Count;

            if (unguaranteedCount <= 0)
            {
                return(result);
            }

            var unguaranteed = enabled.Where(item => !item.Guaranteed).ToList();

            unguaranteed = unguaranteed.DistinctBy(value => value.Probability).Count() == 1
                ? unguaranteed.Shuffle().ToList()
                : unguaranteed.OrderBy(item => item.Probability).ToList();

            var probabilitySum = unguaranteed.Sum(item => item.Probability);

            for (var i = 0; i < unguaranteedCount; i++)
            {
                var growingProbability = 0f;

                foreach (var item in unguaranteed)
                {
                    item.OnCheck();

                    growingProbability += item.Probability;

                    if (RNG.Float() * probabilitySum > growingProbability)
                    {
                        continue;
                    }

                    PopulateResult(result, item);
                    break;
                }
            }

            return(result);
        }
Пример #6
0
    private void AddBoss(Room room, float difficulty, List <bool> conceptsUsed)
    {
        difficulty  = RNG.Float(difficulty * 0.8f, difficulty * 1.2f);
        difficulty /= 22;
        var monsterType = RetrieveMonsterType(allMonsterTypes, allMonsterTypes, allMonsterTypes, difficulty);

        while (monsterType == "Energy Wisplet" || monsterType == "Kobold")
        {
            monsterType = RetrieveMonsterType(allMonsterTypes, allMonsterTypes, allMonsterTypes, difficulty);
        }
        var monster = new MonsterData(monsterType, monsterType, LevelGen.targetLevel, 4, null); //ConvertDifficultyToLevel(difficulty) // HARDCODING TO DIFF + 0 FOR NOW

        monster.associatedRooms.Add(room);
        monsters.Add(monster);
    }
Пример #7
0
    private void GetAddAttribute(SoulGemEnhancement effect)
    {
        var attribute = AbilityAttributeGenerator.Generate(ability, effect.target);

        if (attribute == null)
        {
            return;
        }
        if (attribute.priority < 50)
        {
            attribute.priority = RNG.Float(50f, 100f);
        }
        ability.attributes.Add(attribute);
        ability.SortAttributes();
        ability.points += attribute.points;
    }
Пример #8
0
    private void AddMonstersForRoom(Room room, float difficulty, List <bool> conceptsUsed, float individualMonsterLimit)
    {
        var conceptWeights  = new List <float>();
        int numConceptsUsed = 0;

        foreach (var concept in conceptsUsed)
        {
            if (!concept)
            {
                conceptWeights.Add(0);
            }
            else
            {
                float baseValue   = 1f / encounterThemes.Count;
                float fudgeFactor = RNG.Float(0.5f, 1.5f);
                conceptWeights.Add(baseValue * fudgeFactor);
                numConceptsUsed++;
            }
        }
        NormalizeConceptWeights(conceptWeights);
        float multipliedWeight = 1f;

        foreach (var weight in conceptWeights)
        {
            if (weight > 0)
            {
                multipliedWeight *= weight;
            }
        }
        var difficultyFactor    = Mathf.Pow(difficulty / multipliedWeight, 1f / numConceptsUsed);
        var conceptDifficulties = new List <float>();

        foreach (var weight in conceptWeights)
        {
            conceptDifficulties.Add(weight * difficultyFactor);
        }
        //Debug.Log("-----");
        //Debug.Log("intended difficulty is " + difficulty.ToString());
        //Debug.Log("difficulty multiplier for weights is " + difficultyFactor.ToString());
        for (int i = 0; i < conceptDifficulties.Count; i++)
        {
            if (conceptDifficulties[i] > 0)
            {
                AddMonstersForConcept(room, conceptDifficulties[i], encounterThemes[i], individualMonsterLimit);
            }
        }
    }
Пример #9
0
 public static Color Randomize(this Color original)
 {
     return(new Color(RNG.Float(), RNG.Float(), RNG.Float()));
 }
Пример #10
0
    private float AddMonsterUpToDifficulty(Room room, float difficultyLimit, string concept, float individualMonsterLimit)
    {
        difficultyLimit        = RNG.Float(difficultyLimit / 10f, difficultyLimit * 1.2f);
        individualMonsterLimit = RNG.Float(individualMonsterLimit / 2, individualMonsterLimit * 2);
        difficultyLimit        = Mathf.Min(difficultyLimit, individualMonsterLimit);
        var validMonsterTypes     = new List <string>();
        var secondaryMonsterTypes = new List <string>();

        switch (concept)
        {
        case "slowEnemies":
        default:
            validMonsterTypes = new List <string> {
                "Gelatinous Mass",
                "Ghost"
            };
            secondaryMonsterTypes = new List <string> {
                "Animated Statue",
                "Ankheg",
                "Bound Archon",
                "Corrupted Sorcerer",
                "Cyclops",
                "Dark Bishop",
                "Dark Knight",
                "Dragon",
                "Elder Dragon",
                //"Energy Wisplet",
                "Fire Elemental",
                "Ghoul",
                "GOBLIN",
                "Goblin Archer",
                "Goblin Rogue",
                "Golem",
                "Ice Elemental",
                "Imp",
                "Jittery Wisplet",
                "Kobold",
                "Land Squid",
                "Mimic",
                "Minotaur",
                "Mirror Mage",
                "Ogre",
                "Phantom Fungus",
                "Slime",
                "SPIDER",
                "Troll",
                "Warlock",
                "Young Dragon"
            };
            break;

        case "largePacks":
            difficultyLimit /= 4;
            break;

        case "differingEnemySpeeds":
            validMonsterTypes = new List <string> {
                "Bomber",
                "Gelatinous Mass",
                "Ghost",
                "Gremlin",
                "Cave Cheetah",
                "Wolf"
            };
            break;

        case "projectiles":
            validMonsterTypes = new List <string> {
                "Corrupted Sorcerer",
                "Dark Bishop",
                "Gelatinous Mass",
                "Goblin Archer",
                "Imp",
                "Jittery Wisplet",
                "Mirror Mage",
                "Warlock"
            };
            secondaryMonsterTypes = new List <string> {
                "Ankheg",
                "Dark Knight",
                "Dragon",
                "Elder Dragon",
                "Fire Elemental",
                "Ice Elemental",
                "Land Squid",
                "Young Dragon"
            };
            break;

        case "knockback":
            validMonsterTypes = new List <string> {
                "Cyclops"
            };
            secondaryMonsterTypes = new List <string> {
                "Minotaur",
                "Dark Knight"
            };
            break;

        case "pullAndChargeEffects":
            validMonsterTypes = new List <string> {
                "Minotaur",
                "Dark Knight"
            };
            secondaryMonsterTypes = new List <string> {
                "Cyclops"
            };
            break;

        case "elementalResistances":
            validMonsterTypes = new List <string> {
                "Animated Statue",
                "Fire Elemental",
                "Ice Elemental",
                "Imp",
                "Gremlin",
                "Land Squid",
                "Jittery Wisplet",
                "Young Dragon",
                "Dragon",
                "Elder Dragon",
                "Dark Knight",
                "Golem",
                "Ghoul",
                "Phantom Fungus",
                "Mimic",
                "Ghost",
                "Corrupted Sorcerer",
                "Slime",
                "Gelatinous Mass",
                "Bound Archon"
            };
            break;

        case "enemiesWithDangerousMeleeAttacks":
            validMonsterTypes = new List <string> {
                "Bomber",
                "Cyclops",
                "Dark Knight",
                "Ghoul",
                "Minotaur",
                "Troll"
            };
            secondaryMonsterTypes = new List <string> {
                "Ogre",
                "SPIDER"
            };
            break;

        case "healingOrRegeneration":
            validMonsterTypes = new List <string> {
                "Bound Archon",
                "Dark Bishop",
                "Troll"
            };
            break;

        case "suddenSpawns":
            validMonsterTypes = new List <string> {
                "Ghost",
                "Goblin Rogue",
                "Imp",
                "Mirror Mage",
                "Phantom Fungus",
                "Slime"
            };
            break;
        }
        var monsterType = RetrieveMonsterType(validMonsterTypes, secondaryMonsterTypes, allMonsterTypes, difficultyLimit);

        if (!localEnemyTypes.Contains(monsterType))
        {
            localEnemyTypes.Add(monsterType);
        }
        int qualityRoll = RNG.Int(0, 100);
        int quality     = 0;

        if (qualityRoll < 50)
        {
            quality = 0;
        }
        else if (qualityRoll < 80)
        {
            quality = 1;
        }
        else if (qualityRoll < 95)
        {
            quality = 2;
        }
        else
        {
            quality = 3;
        }
        var monster = new MonsterData(monsterType, monsterType, ConvertDifficultyToLevel(difficultyLimit), quality, null);

        monster.associatedRooms.Add(room);
        monsters.Add(monster);
        //Debug.Log("adding " + monsterType);
        return(GetMonsterDifficulty(monster));
    }
Пример #11
0
    private void CreateEncounterPath(VaultPath path, int targetLevel)
    {
        var   difficulties       = new List <float>();
        var   conceptsUsed       = new List <List <bool> >();
        var   conceptsIntroduced = new List <bool>();
        var   numConcepts        = encounterThemes.Count;
        var   numPathEncounters  = GetPathEncounterNumber(path);
        float scaleFactor        = 1;

        // determine difficulty of each encounter
        for (int i = 1; i < targetLevel; i++)
        {
            scaleFactor *= 1.44f;
        }
        for (int i = 0; i < numPathEncounters; i++)
        {
            var currentDifficulty = nishikadoBaseDifficultyLookup[targetLevel - 1] * nishikadoEncounterDifficultyLookup[i] * scaleFactor;
            var fudgeFactor       = RNG.Float(0.75f, 1.25f);
            difficulties.Add(currentDifficulty * fudgeFactor);
        }

        // determine which concepts to use in each encounter
        for (int i = 0; i < numConcepts; i++)
        {
            conceptsIntroduced.Add(false);
        }
        conceptsIntroduced[0] = true;
        var conceptList = new List <bool> {
            true
        };

        for (int i = 1; i < numConcepts; i++)
        {
            conceptList.Add(false);
        }
        conceptsUsed.Add(conceptList);
        for (int i = 1; i < numPathEncounters; i++)
        {
            conceptList = new List <bool>();
            float chanceOfNew = i / numPathEncounters;
            float roll        = RNG.Float(0, 1);
            if (roll <= chanceOfNew && HasUnintroducedConcepts(conceptsIntroduced))
            {
                //introduce new concept
                var conceptIndex = conceptsIntroduced.IndexOf(false);
                conceptsIntroduced[conceptIndex] = true;
                for (int j = 0; j < numConcepts; j++)
                {
                    if (j == conceptIndex)
                    {
                        conceptList.Add(true);
                    }
                    else
                    {
                        conceptList.Add(false);
                    }
                }
                conceptsUsed.Add(conceptList);
            }
            else
            {
                //use existing concepts
                conceptList = new List <bool>();
                foreach (var concept in conceptsIntroduced)
                {
                    if (!concept)
                    {
                        conceptList.Add(false);
                    }
                    else
                    {
                        var roll2 = RNG.Int(0, 3);
                        if (roll2 == 0)
                        {
                            conceptList.Add(false);
                        }
                        else
                        {
                            conceptList.Add(true);
                        }
                    }
                }
                ValidateConceptSet(conceptList);
                conceptsUsed.Add(conceptList);
            }
        }

        // create monsters for each encounter
        int encounterNumber = 0;

        foreach (var room in path.rooms)
        {
            if (room is VaultRoom vaultRoom)
            {
                if (vaultRoom.hasEncounter)
                {
                    AddMonstersForRoom(room, difficulties[encounterNumber], conceptsUsed[encounterNumber], scaleFactor);
                    encounterNumber++;
                }
            }
            else if (room is BossRoom)
            {
                AddBoss(room, difficulties[encounterNumber], conceptsUsed[encounterNumber]);
                encounterNumber++;
            }
        }
    }