diff options
Diffstat (limited to 'scripts/Map')
| -rw-r--r-- | scripts/Map/DungeonGenerator.cs | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs index 779675f..7f57353 100644 --- a/scripts/Map/DungeonGenerator.cs +++ b/scripts/Map/DungeonGenerator.cs @@ -3,6 +3,9 @@ using TheLegendOfGustav.Entities.Actors; using TheLegendOfGustav.Entities; using TheLegendOfGustav.Entities.Items; using System; +using Godot.Collections; +using System.Diagnostics.Metrics; +using System.Numerics; namespace TheLegendOfGustav.Map; @@ -14,6 +17,27 @@ public partial class DungeonGenerator : Node { #region Fields /// <summary> + /// Chave: Andar mínimo + /// Valor: Número de máximo de monstros por sala + /// </summary> + private static readonly Dictionary<int, int> maxMonstersByFloor = new() + { + {1, 2}, + {4, 3}, + {6, 4}, + {10, 8} + }; + /// <summary> + /// Chave: Andar mínimo + /// Valor: Número de máximo de itens por sala + /// </summary> + private static readonly Dictionary<int, int> maxItemsByFloor = new() + { + {1, 1}, + {4, 2}, + {6, 3}, + }; + /// <summary> /// Coleção de todos os inimigos que o gerador tem acesso. /// </summary> private static readonly Godot.Collections.Array<EnemyDefinition> enemies = [ @@ -47,24 +71,30 @@ public partial class DungeonGenerator : Node /// </summary> [ExportCategory("RNG")] private RandomNumberGenerator rng = new(); - - /// <summary> - /// Quantidade máxima de inimigos por sala. - /// </summary> - [ExportCategory("Monster RNG")] - [Export] - private int maxMonstersPerRoom = 2; - - /// <summary> - /// Quantidade máxima de itens por sala. - /// </summary> - [ExportCategory("Loot RNG")] - [Export] - private int maxItemsPerRoom = 2; #endregion #region Methods + private int GetMaxIValueForFloor(Dictionary<int, int> valueTable, int currentFloor) { + int currentValue = 0; + + int? key = null; + + foreach (int theKey in valueTable.Keys) { + if (theKey > currentFloor) { + break; + } else { + key = theKey; + } + } + + if (key.HasValue) { + currentValue = valueTable[key.Value]; + } + + return currentValue; + } + /// <summary> /// Gera um andar da masmorra. /// Inimigos são colocados conforme configurações. @@ -229,9 +259,9 @@ public partial class DungeonGenerator : Node private void PlaceEntities(MapData data, Rect2I room) { // Define quantos monstros serão colocados na sala - int monsterAmount = rng.RandiRange(0, maxMonstersPerRoom); + int monsterAmount = rng.RandiRange(0, GetMaxIValueForFloor(maxMonstersByFloor, data.CurrentFloor)); // Define quantos itens serão colocados na sala. - int itemAmount = rng.RandiRange(0, maxItemsPerRoom); + int itemAmount = rng.RandiRange(0, GetMaxIValueForFloor(maxItemsByFloor, data.CurrentFloor)); for (int i = 0; i < monsterAmount; i++) { |
