diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-30 17:31:00 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-30 17:31:06 -0300 |
| commit | d6fc2026917d55fa12713e3d00004ec461cc5971 (patch) | |
| tree | 54fc79f9f8a217b2477721e21875e74c1736564e /scripts/Map/DungeonGenerator.cs | |
| parent | e40bc38dcc17ebeb40722bedb94a6459e47b9aeb (diff) | |
vários andares
Diffstat (limited to 'scripts/Map/DungeonGenerator.cs')
| -rw-r--r-- | scripts/Map/DungeonGenerator.cs | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs index 2d5ef8d..2b24e8a 100644 --- a/scripts/Map/DungeonGenerator.cs +++ b/scripts/Map/DungeonGenerator.cs @@ -2,6 +2,7 @@ using Godot; using TheLegendOfGustav.Entities.Actors; using TheLegendOfGustav.Entities; using TheLegendOfGustav.Entities.Items; +using System; namespace TheLegendOfGustav.Map; @@ -36,16 +37,6 @@ public partial class DungeonGenerator : Node private int height = 60; /// <summary> - /// Qual seed utilizar. - /// </summary> - [Export] - private ulong seed; - /// <summary> - /// Se será utilizada a nossa seed ou a seed padrão da classe RandomNumberGenerator. - /// </summary> - [Export] - private bool useSeed = true; - /// <summary> /// Quantas iterações do algoritmo chamar. /// </summary> [Export] @@ -73,14 +64,6 @@ public partial class DungeonGenerator : Node #endregion #region Methods - public override void _Ready() - { - base._Ready(); - if (useSeed) - { - rng.Seed = seed; - } - } /// <summary> /// Gera um andar da masmorra. @@ -89,9 +72,12 @@ public partial class DungeonGenerator : Node /// </summary> /// <param name="player">Jogador.</param> /// <returns>O mapa gerado.</returns> - public MapData GenerateDungeon(Player player) + public MapData GenerateDungeon(Player player, int currentFloor) { + rng.Seed = (ulong)DateTimeOffset.Now.ToUnixTimeMilliseconds(); + MapData data = new MapData(width, height, player); + data.CurrentFloor = currentFloor; // Divisão mestre que engloba o mapa inteiro. MapDivision root = new MapDivision(0, 0, width, height); @@ -104,6 +90,8 @@ public partial class DungeonGenerator : Node // Coloca os corredores. TunnelDivisions(data, root); + Rect2I lastRoom = new(0, 0, 0, 0); + // Cria as salas com base nas divisões geradas. foreach (MapDivision division in root.GetLeaves()) { @@ -127,8 +115,14 @@ public partial class DungeonGenerator : Node } // Colocamos os inimigos na sala. PlaceEntities(data, room); + + lastRoom = room; } + data.DownstairsLocation = lastRoom!.GetCenter(); + Tile downTile = data.GetTile(data.DownstairsLocation); + downTile.Key = TileType.DOWN_STAIRS; + // Feito o mapa, inicializamos o algoritmo de pathfinding. data.SetupPathfinding(); return data; |
