puzzle module framework, puzzle a ball module

This commit is contained in:
2022-11-18 02:10:05 +01:00
parent bd0934636f
commit 99e0452379
90 changed files with 4799 additions and 51 deletions

View File

@@ -1,19 +1,36 @@
using System;
using Escape_Room_Engine.Engine.Scripts.Utilities;
using NaughtyAttributes;
using Logger = Escape_Room_Engine.Engine.Scripts.Utilities.Logger;
using LogType = Escape_Room_Engine.Engine.Scripts.Utilities.LogType;
namespace Escape_Room_Engine.Engine.Scripts.Modules
{
public enum PuzzleEventType
{
Restarted, Solved
Restarted, Solved, WrongInput
}
public static class PuzzleEventExtensions
{
public static string Description(this PuzzleEventType type, PuzzleModule module)
{
return type switch
{
PuzzleEventType.Restarted => $"{module} has been restarted",
PuzzleEventType.Solved => $"{module} has been solved",
PuzzleEventType.WrongInput => $"Wrong input for {module}",
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};
}
}
public delegate void PuzzleEventHandler(PuzzleModule source, PuzzleEventType e);
public class PuzzleState : ModuleState
{
public event PuzzleEventHandler PuzzleEvent;
public EngineTheme theme;
private new PuzzleModule Module { get; set; }
public bool Solved
@@ -34,7 +51,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
private void OnPuzzleEvent(PuzzleEventType type)
{
Logger.Log($"{Module} has been {type}", LogType.PuzzleFlow);
Logger.Log(type.Description(Module), LogType.PuzzleFlow);
PuzzleEvent?.Invoke(Module, type);
}
@@ -62,5 +79,11 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules
{
Solved = false;
}
[Button("Trigger Wrong Input", EButtonEnableMode.Playmode)]
public void WrongInput()
{
OnPuzzleEvent(PuzzleEventType.WrongInput);
}
}
}