40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
|
{
|
|
/// <summary>
|
|
/// A <see cref="StepPuzzle"/> whose steps are considered a cycle that can be started anywhere and must be stepped through once.
|
|
/// </summary>
|
|
public class CyclicStepPuzzle : StepPuzzle
|
|
{
|
|
[Tooltip("The current step in the cycle.")]
|
|
[BoxGroup("Step Puzzle")] [Min(0)]
|
|
public int cycleStep;
|
|
|
|
protected override void CheckStep(int step)
|
|
{
|
|
if (!Solved)
|
|
{
|
|
if (currentStep == 0)
|
|
{
|
|
// begin at any step
|
|
cycleStep = NextInCycle(step);
|
|
Step();
|
|
}
|
|
else if (step == cycleStep)
|
|
{
|
|
// next step in cycle
|
|
cycleStep = NextInCycle(cycleStep);
|
|
Step();
|
|
}
|
|
else
|
|
{
|
|
WrongInput();
|
|
}
|
|
}
|
|
}
|
|
|
|
private int NextInCycle(int step) => (step + 1) % totalSteps;
|
|
}
|
|
} |