add StepPuzzle and CyclicStepPuzzle
This commit is contained in:
35
Assets/Engine/Runtime/Modules/CyclicStepPuzzle.cs
Normal file
35
Assets/Engine/Runtime/Modules/CyclicStepPuzzle.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Modules
|
||||
{
|
||||
public class CyclicStepPuzzle : StepPuzzle
|
||||
{
|
||||
[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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user