Files
modular-vr/Assets/Escape Room Engine/Desert/Modules/Puzzle A/Scripts/Ball.cs

59 lines
1.7 KiB
C#

using System;
using Escape_Room_Engine.Desert.Scripts;
using Escape_Room_Engine.Engine.Scripts.Modules;
using NaughtyAttributes;
using UnityEngine;
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
[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;
}
}
}