last room and puzzle order

This commit is contained in:
2022-12-08 14:04:00 +01:00
parent b3c53031c1
commit 429f9536a9
9 changed files with 91 additions and 71 deletions

View File

@@ -12,6 +12,8 @@ namespace EscapeRoomEngine.Engine.Runtime
{
internal Passage entrance, exit;
internal GameObject roomObject;
internal bool LastRoom => exit == null;
private readonly List<Space> _spaces = new();
private readonly List<PuzzleModule> _puzzles = new();
@@ -36,7 +38,7 @@ namespace EscapeRoomEngine.Engine.Runtime
Logger.Log($"Skipping {this}...", LogType.PuzzleFlow);
_puzzles.ForEach(puzzle => puzzle.PuzzleState.Solve());
if (_puzzles.Count == 0)
if (_puzzles.Count == 0 && !LastRoom)
{
exit.fromOut.DoorState.Unlock();
}
@@ -57,7 +59,11 @@ namespace EscapeRoomEngine.Engine.Runtime
{
if (type == PuzzleEventType.Solved)
{
if (_puzzles.All(p => p.PuzzleState.Solved))
if (LastRoom)
{
GameControl.Instance.StopGame();
}
else if (_puzzles.All(p => p.PuzzleState.Solved))
{
exit.fromOut.DoorState.Unlock();
}
@@ -73,7 +79,7 @@ namespace EscapeRoomEngine.Engine.Runtime
switch (type)
{
// generate a new room as soon as the player completes all puzzles in this one
case DoorEventType.Unlocked when door.Equals(exit.fromOut):
case DoorEventType.Unlocked when !LastRoom && door.Equals(exit.fromOut):
Engine.DefaultEngine.GenerateRoom();
break;
// start measurements on every puzzle as soon as the player enters the last room