From d6fc2026917d55fa12713e3d00004ec461cc5971 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 30 Oct 2025 17:31:00 -0300 Subject: vários andares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Map/DungeonGenerator.cs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'scripts/Map/DungeonGenerator.cs') 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; @@ -35,16 +36,6 @@ public partial class DungeonGenerator : Node [Export] private int height = 60; - /// - /// Qual seed utilizar. - /// - [Export] - private ulong seed; - /// - /// Se será utilizada a nossa seed ou a seed padrão da classe RandomNumberGenerator. - /// - [Export] - private bool useSeed = true; /// /// Quantas iterações do algoritmo chamar. /// @@ -73,14 +64,6 @@ public partial class DungeonGenerator : Node #endregion #region Methods - public override void _Ready() - { - base._Ready(); - if (useSeed) - { - rng.Seed = seed; - } - } /// /// Gera um andar da masmorra. @@ -89,9 +72,12 @@ public partial class DungeonGenerator : Node /// /// Jogador. /// O mapa gerado. - 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; -- cgit v1.2.3