PuzzleMeasurement, add Realm, door ExitedFrom event
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EscapeRoomEngine.Engine.Runtime.Measurements;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
@@ -35,13 +36,17 @@ namespace EscapeRoomEngine.Engine.Runtime
|
||||
Logger.Log($"Skipping {this}...", LogType.PuzzleFlow);
|
||||
|
||||
_puzzles.ForEach(puzzle => puzzle.PuzzleState.Solve());
|
||||
|
||||
if (_puzzles.Count == 0)
|
||||
{
|
||||
exit.fromOut.DoorState.Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterRoom()
|
||||
{
|
||||
entrance.toIn.DoorState.ExitFrom();
|
||||
}
|
||||
|
||||
internal void AddPuzzle(PuzzleModule puzzle)
|
||||
{
|
||||
_puzzles.Add(puzzle);
|
||||
@@ -67,9 +72,18 @@ namespace EscapeRoomEngine.Engine.Runtime
|
||||
|
||||
private void OnDoorEvent(DoorModule door, DoorEventType type)
|
||||
{
|
||||
if (type == DoorEventType.Unlocked && door.Equals(exit.fromOut))
|
||||
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
|
||||
switch (type)
|
||||
{
|
||||
Engine.DefaultEngine.GenerateRoom();
|
||||
// generate a new room as soon as the player completes all puzzles in this one
|
||||
case DoorEventType.Unlocked when door.Equals(exit.fromOut):
|
||||
Engine.DefaultEngine.GenerateRoom();
|
||||
break;
|
||||
// start measurements on every puzzle as soon as the player enters this room
|
||||
case DoorEventType.ExitedFrom when door.Equals(entrance.toIn):
|
||||
_puzzles.ForEach(puzzle => Measure.StartMeasuring((PuzzleModuleDescription)puzzle.description));
|
||||
Engine.DefaultEngine.HidePreviousRoom();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user