summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-10-30 17:40:29 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-10-30 17:40:29 -0300
commit3ff30a242d36c894ebea2540893ad77d265c5593 (patch)
tree0f6a1ebac5c27ed3ee40584f7621bab9ef57eebc
parenta17dee5fb0f9248a6735af15cace7d8418324f28 (diff)
Um pouquinho mais aleatório
-rw-r--r--scenes/Game.tscn3
-rw-r--r--scripts/Map/DungeonGenerator.cs16
2 files changed, 14 insertions, 5 deletions
diff --git a/scenes/Game.tscn b/scenes/Game.tscn
index e9bd9d2..d215312 100644
--- a/scenes/Game.tscn
+++ b/scenes/Game.tscn
@@ -19,13 +19,14 @@
script = ExtResource("1_cpr0p")
[node name="Map" type="Node2D" parent="."]
+position = Vector2(-1, 0)
script = ExtResource("3_cpr0p")
[node name="Generator" type="Node" parent="Map"]
script = ExtResource("4_78awf")
width = 30
height = 20
-useSeed = false
+iterations = 6
[node name="FieldOfView" type="Node" parent="Map"]
script = ExtResource("5_s0nni")
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs
index 2b24e8a..f7a3f4d 100644
--- a/scripts/Map/DungeonGenerator.cs
+++ b/scripts/Map/DungeonGenerator.cs
@@ -90,7 +90,9 @@ public partial class DungeonGenerator : Node
// Coloca os corredores.
TunnelDivisions(data, root);
- Rect2I lastRoom = new(0, 0, 0, 0);
+ Vector2I lastRoom = new(0, 0);
+
+ bool placedStair = false;
// Cria as salas com base nas divisões geradas.
foreach (MapDivision division in root.GetLeaves())
@@ -113,13 +115,19 @@ public partial class DungeonGenerator : Node
first = false;
player.GridPosition = room.GetCenter();
}
+ else if (!placedStair && rng.RandiRange(0, 100) > 25)
+ {
+ lastRoom = room.GetCenter();
+ placedStair = true;
+ } else if (!placedStair) {
+ lastRoom = room.GetCenter();
+ }
+
// Colocamos os inimigos na sala.
PlaceEntities(data, room);
-
- lastRoom = room;
}
- data.DownstairsLocation = lastRoom!.GetCenter();
+ data.DownstairsLocation = lastRoom;
Tile downTile = data.GetTile(data.DownstairsLocation);
downTile.Key = TileType.DOWN_STAIRS;