mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Made Keys lock doors
This commit is contained in:
parent
902635e6a3
commit
e62b539a1e
2 changed files with 36 additions and 12 deletions
|
|
@ -124,6 +124,8 @@ public partial class RogueliteRoomManager : Node2D
|
|||
|
||||
RogueliteRoom lastRoom = spawnedBeginRoom;
|
||||
|
||||
bool lockNext = false;
|
||||
|
||||
for (int i = 0; i < DungeonLength; i++)
|
||||
{
|
||||
GD.Print($"Dungeon room {i}");
|
||||
|
|
@ -138,18 +140,16 @@ public partial class RogueliteRoomManager : Node2D
|
|||
continue;
|
||||
}
|
||||
|
||||
if (lockNext)
|
||||
{
|
||||
_connections.Last().IsLocked = true;
|
||||
lockNext = false;
|
||||
}
|
||||
|
||||
lastRoom = spawnedRoom;
|
||||
|
||||
// Spawn offshoot here
|
||||
|
||||
var offshootTypeToSpawn = shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()];
|
||||
|
||||
if (offshootTypeToSpawn is RoomType.Regular)
|
||||
{
|
||||
currentOffshoot++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Roll whether to go left or right, if direction is full go the other, if both are full do not spawn
|
||||
|
||||
var directions = new List<Direction>();
|
||||
|
|
@ -158,11 +158,13 @@ public partial class RogueliteRoomManager : Node2D
|
|||
if (lastRoom.RoomResource.DoorDirections.HasFlag(DoorDirections.West)) directions.Add(Direction.Left);
|
||||
|
||||
directions = directions.Shuffle().ToList();
|
||||
|
||||
var randOffshootStartIndex = SpawnedRooms.Count(x => x.RoomResource.Type is RoomType.Regular && x.RoomResource.HasDoors(DoorDirections.West | DoorDirections.East));
|
||||
|
||||
foreach (var direction in directions)
|
||||
{
|
||||
var randOffshootStartIndex = SpawnedRooms.Count(x => x.RoomResource.Type is RoomType.Regular && x.RoomResource.HasDoors(DoorDirections.West | DoorDirections.East));
|
||||
|
||||
var offshootTypeToSpawn = shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()];
|
||||
|
||||
int roomsInOffshot = offshootTypeToSpawn is RoomType.Secret or RoomType.Shop
|
||||
? 0
|
||||
: GD.RandRange(0, MaxBranchLength);
|
||||
|
|
@ -175,7 +177,22 @@ public partial class RogueliteRoomManager : Node2D
|
|||
if (res)
|
||||
{
|
||||
currentOffshoot++;
|
||||
break;
|
||||
// Try to spawn one the other direction too
|
||||
|
||||
// If key, lock the last connection
|
||||
if (offshootTypeToSpawn is RoomType.Key)
|
||||
{
|
||||
//lastConnection.IsLocked = true;
|
||||
// Need to lock the next connection
|
||||
lockNext = true;
|
||||
}
|
||||
|
||||
if (offshootTypeToSpawn is RoomType.Key && shuffledOffshoots[currentOffshoot % shuffledOffshoots.Count()] is RoomType.Key)
|
||||
{
|
||||
// Stop if next room is a key
|
||||
break;
|
||||
}
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,6 +212,12 @@ public partial class RogueliteRoomManager : Node2D
|
|||
{
|
||||
GD.PrintErr($"Could not spawn boss room {bossRoom}");
|
||||
}
|
||||
|
||||
if (lockNext)
|
||||
{
|
||||
_connections.Last().IsLocked = true;
|
||||
lockNext = false;
|
||||
}
|
||||
|
||||
foreach (var room in SpawnedRooms)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue