comment pass
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
@@ -30,10 +31,16 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
|
||||
public delegate void ButtonEventHandler(Button source, ButtonEventType e);
|
||||
|
||||
/// <summary>
|
||||
/// A general component for buttons that handles button events.
|
||||
/// </summary>
|
||||
public class Button : MonoBehaviour
|
||||
{
|
||||
public event ButtonEventHandler ButtonEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this button accepts input.
|
||||
/// </summary>
|
||||
[ShowNativeProperty]
|
||||
protected bool Active
|
||||
{
|
||||
@@ -50,6 +57,9 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this button is currently pressed.
|
||||
/// </summary>
|
||||
[ShowNativeProperty]
|
||||
protected bool Pressed
|
||||
{
|
||||
@@ -88,11 +98,15 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
|
||||
#region Debug Buttons
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Enable() => Active = true;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Disable() => Active = false;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Press() => Pressed = true;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void Release() => Pressed = false;
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Enable() => Active = true;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Disable() => Active = false;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Press() => Pressed = true;
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Release() => Pressed = false;
|
||||
[UsedImplicitly]
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void PressAndRelease()
|
||||
{
|
||||
|
||||
@@ -4,11 +4,19 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// A rotating crystal that can change colour.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Crystal : MonoBehaviour
|
||||
{
|
||||
[Required] public Light crystalLight;
|
||||
[Required]
|
||||
[BoxGroup("Internal")]
|
||||
public Light crystalLight;
|
||||
|
||||
/// <summary>
|
||||
/// Turns the crystal light on or off.
|
||||
/// </summary>
|
||||
public bool Active
|
||||
{
|
||||
set
|
||||
@@ -18,6 +26,9 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The crystal light and emission colours.
|
||||
/// </summary>
|
||||
public DynamicColor Color
|
||||
{
|
||||
set
|
||||
|
||||
@@ -6,13 +6,18 @@ using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Dispenser
|
||||
{
|
||||
/// <summary>
|
||||
/// The main component for the dispenser module.
|
||||
/// </summary>
|
||||
[SelectionBase]
|
||||
[RequireComponent(typeof(Animator), typeof(Emission))]
|
||||
public class Dispenser : ModuleState
|
||||
{
|
||||
private static readonly int Open = Animator.StringToHash("Open");
|
||||
|
||||
[Tooltip("The object this dispenser should produce.")]
|
||||
public Transform dispensable;
|
||||
[Tooltip("The time in seconds to wait until another object can be produced.")]
|
||||
[SerializeField] [Min(0)]
|
||||
private float cooldown;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
@@ -20,6 +25,9 @@ namespace EscapeRoomEngine.Desert.Runtime.Dispenser
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Button dispenseButton;
|
||||
|
||||
/// <summary>
|
||||
/// The dispenser does not produce any more objects when it is solved and changes colour.
|
||||
/// </summary>
|
||||
public bool Solved
|
||||
{
|
||||
set
|
||||
|
||||
@@ -10,8 +10,12 @@ namespace EscapeRoomEngine.Desert.Runtime.Dispenser
|
||||
public bool[] lights;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This component controls the grid of lights on the dispenser.
|
||||
/// </summary>
|
||||
public class DispenserLights : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Control the pattern of lights on a dispenser.")]
|
||||
[SerializeField]
|
||||
private DispenserLightRow[] lights;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
@@ -23,7 +27,6 @@ namespace EscapeRoomEngine.Desert.Runtime.Dispenser
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var position = transform.localPosition;
|
||||
for (var y = 0; y < gridDimensions.y; y++)
|
||||
{
|
||||
var row = lights[y].lights;
|
||||
|
||||
@@ -3,13 +3,23 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// A general component for controlling the emission of an object.
|
||||
/// </summary>
|
||||
public class Emission : MonoBehaviour
|
||||
{
|
||||
private static readonly int EmissionColorNameID = Shader.PropertyToID("_EmissionColor");
|
||||
|
||||
[Tooltip("The colour of the emission.")]
|
||||
[ColorUsage(false, true)]
|
||||
public Color color;
|
||||
[BoxGroup("Internal")] [Required]
|
||||
public MeshRenderer emissionRenderer;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the emission is on.
|
||||
/// </summary>
|
||||
internal bool active;
|
||||
[ColorUsage(false, true)] public Color color;
|
||||
[BoxGroup("Internal")] [Required] public MeshRenderer emissionRenderer;
|
||||
|
||||
private bool _previousActive;
|
||||
private Color _previousColor;
|
||||
|
||||
@@ -3,6 +3,9 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// A holographic <see cref="Button"/> that changes its colour when it is pressed.
|
||||
/// </summary>
|
||||
public class HoloButton : Button
|
||||
{
|
||||
private static readonly int FresnelColor = Shader.PropertyToID("_FresnelColor");
|
||||
|
||||
@@ -8,9 +8,13 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The main component for the orb throwing module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class Hoop : StatePuzzle
|
||||
{
|
||||
[Tooltip("How long to wait in seconds until the state is updated. Orbs that do not stay in the hoop should not be counted.")]
|
||||
public float updateDelay;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private List<Emission> rings;
|
||||
@@ -84,6 +88,7 @@ namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
base.SetModule(module);
|
||||
|
||||
// The hoop requires a related dispenser module
|
||||
var firstRelatedModule = Module.relatedModules[0];
|
||||
if (firstRelatedModule.State is Dispenser.Dispenser dispenser)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,9 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Portal
|
||||
{
|
||||
/// <summary>
|
||||
/// The desert theme includes its own version of a portal that changes colour when it is unlocked.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class DesertPortal : EscapeRoomEngine.Portal.Runtime.Portal
|
||||
{
|
||||
|
||||
@@ -3,10 +3,15 @@ using NaughtyAttributes;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
/// <summary>
|
||||
/// The main component for the symbol ball module.
|
||||
/// </summary>
|
||||
public class Ball : ModuleState
|
||||
{
|
||||
[BoxGroup("Internal")] [Required] public Emission statusLight;
|
||||
[BoxGroup("Internal")] [Required] public Ring ring;
|
||||
[BoxGroup("Internal")] [Required]
|
||||
public Emission statusLight;
|
||||
[BoxGroup("Internal")] [Required]
|
||||
public Ring ring;
|
||||
|
||||
public bool StatusLight
|
||||
{
|
||||
|
||||
@@ -6,12 +6,20 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
/// <summary>
|
||||
/// The rotating ring in the symbol ball module.
|
||||
/// </summary>
|
||||
public class Ring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Whether the ring is rotating.")]
|
||||
public bool rotating = true;
|
||||
[Tooltip("The current angle of the rotation.")]
|
||||
public float rotationAngle;
|
||||
[MinMaxSlider(-180, 180)] public Vector2 activeRange;
|
||||
[BoxGroup("Internal")] [Required] public Crystal crystal;
|
||||
[Tooltip("The range in degrees from the front of the module where a symbol should be lit up.")]
|
||||
[MinMaxSlider(-180, 180)]
|
||||
public Vector2 activeRange;
|
||||
[BoxGroup("Internal")] [Required]
|
||||
public Crystal crystal;
|
||||
[BoxGroup("Internal")]
|
||||
[ValidateInput("SymbolCount", "Must have same amount of symbols and slots.")]
|
||||
public List<Symbol> symbols;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
|
||||
@@ -27,13 +28,23 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
|
||||
public delegate void SymbolEventHandler(SymbolEventType e);
|
||||
|
||||
/// <summary>
|
||||
/// The main component for the symbols on the symbol ring module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Symbol : MonoBehaviour
|
||||
{
|
||||
public int symbolNumber, symbolPosition;
|
||||
[Tooltip("The number of the symbol in the puzzle solution.")]
|
||||
public int symbolNumber;
|
||||
[BoxGroup("Internal")]
|
||||
public int symbolPosition;
|
||||
[BoxGroup("Internal")]
|
||||
public float anglePosition;
|
||||
public event SymbolEventHandler SymbolEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the symbol is lit up. This is controlled by the <see cref="Ring"/>.
|
||||
/// </summary>
|
||||
public bool Active
|
||||
{
|
||||
set
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="HoloButton"/> that includes the number of its assigned symbol.
|
||||
/// </summary>
|
||||
public class SymbolButton : HoloButton
|
||||
{
|
||||
[Tooltip("The number of the symbol assigned to this button.")]
|
||||
public int symbolNumber;
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,16 @@ using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
/// <summary>
|
||||
/// The main component for the terminal module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class Terminal : CyclicStepPuzzle
|
||||
{
|
||||
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
|
||||
|
||||
[BoxGroup("Internal")] [Required] public Emission terminalLight;
|
||||
[BoxGroup("Internal")] [Required]
|
||||
public Emission terminalLight;
|
||||
[BoxGroup("Internal")]
|
||||
[ValidateInput("SymbolCount", "Must have same amount of symbols and slots.")]
|
||||
public List<SymbolButton> symbols;
|
||||
@@ -82,6 +86,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
base.SetModule(module);
|
||||
|
||||
// The terminal requires a related symbol ball module
|
||||
var firstRelatedModule = Module.relatedModules[0];
|
||||
if (firstRelatedModule.State is Ball ball)
|
||||
{
|
||||
@@ -95,15 +100,15 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
TurnOnLights();
|
||||
}
|
||||
|
||||
// required in animation
|
||||
[UsedImplicitly] internal void TurnOnLights()
|
||||
[UsedImplicitly] // required in animation
|
||||
internal void TurnOnLights()
|
||||
{
|
||||
terminalLight.active = true;
|
||||
_ball.StatusLight = true;
|
||||
}
|
||||
|
||||
// required in animation
|
||||
[UsedImplicitly] internal void TurnOffLights()
|
||||
[UsedImplicitly] // required in animation
|
||||
internal void TurnOffLights()
|
||||
{
|
||||
terminalLight.active = false;
|
||||
_ball.StatusLight = false;
|
||||
@@ -131,12 +136,19 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
|
||||
#region Debug Buttons
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void PressSymbol0() => PressedSymbol(0);
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void PressSymbol1() => PressedSymbol(1);
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)] public void PressSymbol2() => PressedSymbol(2);
|
||||
[UsedImplicitly]
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void PressSymbol0() => PressedSymbol(0);
|
||||
[UsedImplicitly]
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void PressSymbol1() => PressedSymbol(1);
|
||||
[UsedImplicitly]
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void PressSymbol2() => PressedSymbol(2);
|
||||
|
||||
#endregion
|
||||
|
||||
[UsedImplicitly] private bool SymbolCount(List<SymbolButton> list) => list.Count == symbolSlots.Count;
|
||||
[UsedImplicitly] // used for field validation
|
||||
private bool SymbolCount(List<SymbolButton> list) => list.Count == symbolSlots.Count;
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,12 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_B
|
||||
public List<int> stateIndices;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main component for the hexagon module.
|
||||
/// </summary>
|
||||
public class PuzzleB : StatePuzzle
|
||||
{
|
||||
[Tooltip("How many seconds the buttons should be disabled until another input is accepted.")]
|
||||
[SerializeField] [Min(0)]
|
||||
private float buttonCooldown;
|
||||
[ValidateInput("CorrectRotatorCount")]
|
||||
@@ -86,6 +90,9 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_B
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch all rotators specified by a given action.
|
||||
/// </summary>
|
||||
private void Switch(ButtonAction action)
|
||||
{
|
||||
for (var i = 0; i < action.stateIndices.Count; i++)
|
||||
@@ -99,7 +106,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_B
|
||||
}
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
[UsedImplicitly] // used for field validation
|
||||
private bool CorrectRotatorCount(List<Rotator> list) => list != null && list.Count == stateCount;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,18 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_B
|
||||
{
|
||||
/// <summary>
|
||||
/// The rotator component used by the hexagon module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Rotator : MonoBehaviour
|
||||
{
|
||||
[Range(0, 359)] public int angle;
|
||||
[Range(0, 1)] public float speed;
|
||||
[Tooltip("The angle this rotator should rotate towards.")]
|
||||
[Range(0, 359)]
|
||||
public int angle;
|
||||
[Tooltip("How quickly to rotate towards the target angle.")]
|
||||
[Range(0, 1)]
|
||||
public float speed;
|
||||
|
||||
public Emission Emission { get; private set; }
|
||||
|
||||
|
||||
@@ -3,9 +3,13 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_C
|
||||
{
|
||||
/// <summary>
|
||||
/// A hole used in the <see cref="Holes"/> module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission), typeof(Collider))]
|
||||
public class Hole : Button
|
||||
{
|
||||
[Tooltip("The number of this hole, starting from the bottom left.")]
|
||||
[Min(0)]
|
||||
public int number;
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_C
|
||||
{
|
||||
/// <summary>
|
||||
/// The main component for the orb grid module.
|
||||
/// </summary>
|
||||
public class Holes : StatePuzzle
|
||||
{
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
@@ -75,6 +78,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_C
|
||||
{
|
||||
base.SetModule(module);
|
||||
|
||||
// The holes require a related dispenser module
|
||||
var firstRelatedModule = Module.relatedModules[0];
|
||||
if (firstRelatedModule.State is Dispenser.Dispenser dispenser)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user