add Puzzle A variants

This commit is contained in:
2022-11-22 00:10:26 +01:00
parent 7244ab470c
commit 593379dd36
66 changed files with 1524 additions and 882 deletions

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EscapeRoomEngine.Engine.Runtime.Modules;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using JetBrains.Annotations;
using NaughtyAttributes;
using UnityEngine;
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
@@ -15,15 +17,23 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
[BoxGroup("Internal")] [Required] public Emission terminalLight;
[BoxGroup("Internal")] public List<SymbolButton> symbols;
[BoxGroup("Internal")]
[ValidateInput("SymbolCount", "Must have same amount of symbols and slots.")]
public List<SymbolButton> symbols;
[BoxGroup("Internal")]
public List<Transform> symbolSlots;
private int _activeSymbol, _lastPressedSymbol;
private IOption<Symbol> _activeSymbol;
private Animator _animator;
private Ball _ball;
private void Awake()
{
_animator = GetComponent<Animator>();
List<SymbolButton> symbolInstances = new(symbols.Count);
symbolInstances.AddRange(symbols.Select((t, i) => Instantiate(t, symbolSlots[i], false)));
symbols = symbolInstances;
}
protected override void Start()
@@ -66,7 +76,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
_ball.ring.symbols.ForEach(symbol =>
{
symbol.SymbolEvent += type =>
_activeSymbol = type == SymbolEventType.Activated ? symbol.symbolNumber : -1;
_activeSymbol = type == SymbolEventType.Activated ? Some<Symbol>.Of(symbol) : None<Symbol>.New();
});
}
@@ -88,33 +98,36 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
}
// required in animation
internal void TurnOnLights()
[UsedImplicitly] internal void TurnOnLights()
{
terminalLight.active = true;
_ball.StatusLight = true;
}
// required in animation
internal void TurnOffLights()
[UsedImplicitly] internal void TurnOffLights()
{
terminalLight.active = false;
_ball.StatusLight = false;
}
internal void PressedSymbol(int number)
private void PressedSymbol(int number)
{
if (!Solved)
{
Logger.Log($"Pressed symbol {number} on {this}", LogType.PuzzleDetail);
if (number == _activeSymbol)
_activeSymbol.Match(some: symbol =>
{
CheckStep(number);
}
else
{
WrongInput();
}
if (number == symbol.symbolNumber)
{
CheckStep(symbol.symbolPosition);
}
else
{
WrongInput();
}
}, none: WrongInput);
}
}
@@ -125,5 +138,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
[Button(enabledMode: EButtonEnableMode.Playmode)] public void PressSymbol2() => PressedSymbol(2);
#endregion
[UsedImplicitly] private bool SymbolCount(List<SymbolButton> list) => list.Count == symbolSlots.Count;
}
}