Dungeon generation

This commit is contained in:
Marco 2025-04-22 18:21:53 +02:00
commit c3107fbce9
9 changed files with 494 additions and 130 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Cirno.Scripts.Components.FSM.Enemy;
using Cirno.Scripts.Enums;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Resources.Roguelite;
using Godot;
@ -22,6 +23,19 @@ public partial class RogueliteRoom : Node2D
return BottomLeft + new Vector2I(GD.RandRange(0, RoomResource.Size.X - 1), 0);
}
public Vector2I RandomExit(Direction direction)
{
return direction switch
{
Direction.Up => GridPosition + new Vector2I(GD.RandRange(0, RoomResource.Size.X - 1), 0),
Direction.Down => BottomLeft + new Vector2I(GD.RandRange(0, RoomResource.Size.X - 1), 0),
Direction.Left => GridPosition + new Vector2I(0, GD.RandRange(0, RoomResource.Size.Y - 1)),
Direction.Right => GridPosition + new Vector2I(RoomResource.Size.X - 1, 0) +
new Vector2I(0, GD.RandRange(0, RoomResource.Size.Y - 1)),
_ => throw new ArgumentOutOfRangeException(nameof(direction), direction, null)
};
}
[Export] public PackedScene DoorPrefab { get; private set; }
[Export] public PackedScene WallPrefab { get; private set; }