summaryrefslogtreecommitdiff
path: root/scripts/Map
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Map')
-rw-r--r--scripts/Map/DungeonGenerator.cs66
1 files changed, 49 insertions, 17 deletions
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs
index 779675f..d9585a7 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,17 +17,40 @@ 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 = [
GD.Load<EnemyDefinition>("res://assets/definitions/actor/Skeleton.tres"),
GD.Load<EnemyDefinition>("res://assets/definitions/actor/morcegao.tres"),
GD.Load<EnemyDefinition>("res://assets/definitions/actor/Shadow.tres"),
+ GD.Load<EnemyDefinition>("res://assets/definitions/actor/toilet.tres")
];
private static readonly Godot.Collections.Array<ItemResource> items = [
GD.Load<ItemResource>("res://assets/definitions/Items/small_healing_potion.tres"),
- GD.Load<ItemResource>("res://assets/definitions/Items/mana_bolt_grimoire.tres")
+ GD.Load<ItemResource>("res://assets/definitions/Items/mana_bolt_grimoire.tres"),
+ GD.Load<ItemResource>("res://assets/definitions/Items/big_potion_of_heals.tres")
];
/// <summary>
@@ -47,24 +73,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 +261,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++)
{