diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-25 18:00:26 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-25 18:00:26 -0300 |
| commit | a3103718796a472da76838bf6fd72ba5d8409d79 (patch) | |
| tree | 2884fac7017e3b592ae542840015df8e998f89d0 | |
| parent | 5f0098b04fe71059471cf82730f341ce06c9fe68 (diff) | |
Gritos de dor e desespero
| -rw-r--r-- | scripts/map/DungeonGenerator.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/scripts/map/DungeonGenerator.cs b/scripts/map/DungeonGenerator.cs index 6e9223c..9a2ceae 100644 --- a/scripts/map/DungeonGenerator.cs +++ b/scripts/map/DungeonGenerator.cs @@ -83,9 +83,8 @@ public partial class DungeonGenerator : Node { first = false; player.GridPosition = room.GetCenter(); - } else { - PlaceEntities(data, room); } + PlaceEntities(data, room); } return data; @@ -94,23 +93,25 @@ public partial class DungeonGenerator : Node private void PlaceEntities(MapData data, Rect2I room) { int monsterAmount = rng.RandiRange(0, maxMonsterPerRoom); - Vector2I position = new( - rng.RandiRange(room.Position.X, room.End.X - 1), - rng.RandiRange(room.Position.Y, room.End.Y - 1) - ); + for (int i = 0; i < monsterAmount; i++) { + Vector2I position = new( + rng.RandiRange(room.Position.X, room.End.X - 1), + rng.RandiRange(room.Position.Y, room.End.Y - 1) + ); - bool canPlace = true; - foreach (Actor actor in data.Actors) { - if (actor.GridPosition == position) { - canPlace = false; - break; + bool canPlace = true; + foreach (Actor actor in data.Actors) { + if (actor.GridPosition == position) { + canPlace = false; + break; + } } - } - if (canPlace) { - ActorDefinition definition = enemies.PickRandom(); - Enemy enemy = new Enemy(position, data, definition); - data.InsertActor(enemy); + if (canPlace) { + ActorDefinition definition = enemies.PickRandom(); + Enemy enemy = new Enemy(position, data, definition); + data.InsertActor(enemy); + } } } |
