/// <summary> /// Generates the loot within all specified parameters, depending on level & difficulty. /// </summary> /// <returns>The loot.</returns> /// <param name="map">Map to get the levelNumber and difficulty from. If unspecified uses set values. </param> public GameItem[] GenerateLoot(Map map = null) { if (map != null) { SetLevelAndDifficulty(map); } //Set loot parameters depending on level & difficulty int maxDifficulty = Enum.GetValues(typeof(Settings.Difficulty)).Length - 1; int minItems_base = Mathf.RoundToInt(minItemsBase_hardest + minItemsBase_modifier * (maxDifficulty - difficulty)); int maxItems_base = Mathf.RoundToInt(maxItemsBase_hardest + maxItemsBase_modifier * (maxDifficulty - difficulty)); int levelsTillMinItemGain = Mathf.RoundToInt(levelsTillMinItemGain_easiest * Mathf.Pow(levelsTillMinItemGain_multiplier, difficulty)); int levelsTillMaxItemGain = Mathf.RoundToInt(levelsTillMaxItemGain_easiest * Mathf.Pow(levelsTillMaxItemGain_multiplier, difficulty)); int minItems_gain = (int)levelNumber / levelsTillMinItemGain; int maxItems_gain = (int)levelNumber / levelsTillMaxItemGain; int minItems = Mathf.Min(minItems_base + minItems_gain, minLootCap); int maxItems = Mathf.Min(maxItems_base + maxItems_gain, maxLootCap); if (minItems > maxItems) { minItems = maxItems; } //Rarity int minRarityBase = Mathf.RoundToInt((int)minRarityBase_hardest + minRarityBase_modifier * (maxDifficulty - difficulty)); int levelsTillMinRarityGain = Mathf.RoundToInt(levelsTillMinRarityGain_easiest * Mathf.Pow(levelsTillMinRarityGain_multiplier, difficulty)); int minRarity_gain = (int)levelNumber / levelsTillMinRarityGain; GameItem.ItemRarity minRarity = (GameItem.ItemRarity)Mathf.Min(minRarityBase + minRarity_gain, (int)minRarityCap); //Generate loot in secret room return(ItemSpawner.GenerateLootBag((int)Time.time, levelNumber, minItems, maxItems, minRarity, false, healthPotionChance)); }
public void TestGenerateLootBag() { GameItem[] loot = ItemSpawner.GenerateLootBag(5, 5); for (int i = 0; i < loot.Length; i++) { Assert.IsNotNull(loot[i]); } }