add Puzzle A variants
This commit is contained in:
@@ -68,7 +68,7 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
|
||||
private bool _active = true, _pressed;
|
||||
|
||||
protected virtual void Awake()
|
||||
protected virtual void Start()
|
||||
{
|
||||
ButtonEvent += (_, type) =>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
@@ -8,6 +9,7 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
|
||||
internal bool active;
|
||||
[ColorUsage(false, true)] public Color color;
|
||||
[BoxGroup("Internal")] [Required] public MeshRenderer emissionRenderer;
|
||||
|
||||
private bool _previousActive;
|
||||
private Color _previousColor;
|
||||
@@ -15,7 +17,7 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_material = GetComponent<Renderer>().material;
|
||||
_material = emissionRenderer.material;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using JetBrains.Annotations;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,8 +11,28 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
public bool rotating = true;
|
||||
public float rotationAngle;
|
||||
[MinMaxSlider(-180, 180)] public Vector2 activeRange;
|
||||
[Required] public Crystal crystal;
|
||||
[BoxGroup("Internal")] [Required] public Crystal crystal;
|
||||
[BoxGroup("Internal")]
|
||||
[ValidateInput("SymbolCount", "Must have same amount of symbols and slots.")]
|
||||
public List<Symbol> symbols;
|
||||
[BoxGroup("Internal")]
|
||||
public List<Transform> symbolSlots;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var angleDistance = 360f / symbols.Count;
|
||||
List<Symbol> symbolInstances = new(symbols.Count);
|
||||
|
||||
for (var i = 0; i < symbols.Count; i++)
|
||||
{
|
||||
var symbol = Instantiate(symbols.RandomElement(), symbolSlots[i], false);
|
||||
symbol.symbolPosition = i;
|
||||
symbol.anglePosition = i * angleDistance;
|
||||
symbolInstances.Add(symbol);
|
||||
}
|
||||
|
||||
symbols = symbolInstances;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -29,5 +51,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
crystal.Active = activeSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
[UsedImplicitly] private bool SymbolCount(List<Symbol> list) => list.Count == symbolSlots.Count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Symbol : MonoBehaviour
|
||||
{
|
||||
public int symbolNumber;
|
||||
public int symbolNumber, symbolPosition;
|
||||
public float anglePosition;
|
||||
public event SymbolEventHandler SymbolEvent;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using EscapeRoomEngine.Engine.Runtime;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(MeshRenderer))]
|
||||
public class SymbolButton : Button
|
||||
{
|
||||
private static readonly int FresnelColor = Shader.PropertyToID("_FresnelColor");
|
||||
@@ -11,12 +11,18 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
|
||||
public int symbolNumber;
|
||||
public EngineTheme theme;
|
||||
[BoxGroup("Internal")] [Required] public MeshRenderer holoRenderer;
|
||||
|
||||
private Material _material;
|
||||
|
||||
private void Start()
|
||||
private void Awake()
|
||||
{
|
||||
_material = GetComponent<MeshRenderer>().material;
|
||||
_material = holoRenderer.material;
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
ButtonEvent += (_, type) =>
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user