Files
modular-vr/Assets/Desert/Runtime/Puzzle A/Ball.cs
2022-11-20 12:52:22 +01:00

58 lines
1.7 KiB
C#

using System;
using EscapeRoomEngine.Engine.Runtime.Modules;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
{
[RequireComponent(typeof(Animator))]
public class Ball : PuzzleState
{
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
[BoxGroup("Internal")] [Required] public Emission ringLight;
[BoxGroup("Internal")] [Required] public Ring ring;
private Animator _animator;
private void Awake()
{
_animator = GetComponent<Animator>();
}
private void Start()
{
PuzzleEvent += (_, type) =>
{
switch (type)
{
case PuzzleEventType.Restarted:
ring.Solved = false;
TurnOffRingLight();
break;
case PuzzleEventType.Solved:
ring.Solved = true;
ringLight.color = theme.solvedColor;
TurnOnRingLight();
break;
case PuzzleEventType.WrongInput:
ringLight.color = theme.puzzleColor;
_animator.SetTrigger(LightFlash);
break;
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
};
}
public void TurnOnRingLight()
{
ringLight.active = true;
}
public void TurnOffRingLight()
{
ringLight.active = false;
}
}
}