mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-02 18:21:16 +00:00
Made Keys lock doors
This commit is contained in:
parent
902635e6a3
commit
e62b539a1e
2 changed files with 36 additions and 12 deletions
|
|
@ -51,6 +51,7 @@ MaxBranchLength = 2
|
||||||
MaxKeys = 2
|
MaxKeys = 2
|
||||||
MaxSecrets = 1
|
MaxSecrets = 1
|
||||||
MaxTreasures = 1
|
MaxTreasures = 1
|
||||||
|
Seed = 2
|
||||||
|
|
||||||
[node name="CameraController" type="Camera2D" parent="."]
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,8 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
|
|
||||||
RogueliteRoom lastRoom = spawnedBeginRoom;
|
RogueliteRoom lastRoom = spawnedBeginRoom;
|
||||||
|
|
||||||
|
bool lockNext = false;
|
||||||
|
|
||||||
for (int i = 0; i < DungeonLength; i++)
|
for (int i = 0; i < DungeonLength; i++)
|
||||||
{
|
{
|
||||||
GD.Print($"Dungeon room {i}");
|
GD.Print($"Dungeon room {i}");
|
||||||
|
|
@ -138,18 +140,16 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lockNext)
|
||||||
|
{
|
||||||
|
_connections.Last().IsLocked = true;
|
||||||
|
lockNext = false;
|
||||||
|
}
|
||||||
|
|
||||||
lastRoom = spawnedRoom;
|
lastRoom = spawnedRoom;
|
||||||
|
|
||||||
// Spawn offshoot here
|
// 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
|
// 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>();
|
var directions = new List<Direction>();
|
||||||
|
|
@ -159,10 +159,12 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
|
|
||||||
directions = directions.Shuffle().ToList();
|
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)
|
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
|
int roomsInOffshot = offshootTypeToSpawn is RoomType.Secret or RoomType.Shop
|
||||||
? 0
|
? 0
|
||||||
: GD.RandRange(0, MaxBranchLength);
|
: GD.RandRange(0, MaxBranchLength);
|
||||||
|
|
@ -175,7 +177,22 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
currentOffshoot++;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,6 +213,12 @@ public partial class RogueliteRoomManager : Node2D
|
||||||
GD.PrintErr($"Could not spawn boss room {bossRoom}");
|
GD.PrintErr($"Could not spawn boss room {bossRoom}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lockNext)
|
||||||
|
{
|
||||||
|
_connections.Last().IsLocked = true;
|
||||||
|
lockNext = false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var room in SpawnedRooms)
|
foreach (var room in SpawnedRooms)
|
||||||
{
|
{
|
||||||
room.HandleDoors((doorEdge, pos) =>
|
room.HandleDoors((doorEdge, pos) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue