Files
modular-vr/Assets/Desert/Runtime/Puzzle A/Ring.cs
2022-11-21 20:38:48 +01:00

34 lines
1.0 KiB
C#

using System.Collections.Generic;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
{
public class Ring : MonoBehaviour
{
public bool rotating = true;
public float rotationAngle;
[MinMaxSlider(-180, 180)] public Vector2 activeRange;
[Required] public Crystal crystal;
public List<Symbol> symbols;
private void Update()
{
if(rotating)
{
transform.localRotation = Quaternion.AngleAxis(rotationAngle, Vector3.forward);
var activeSymbol = false;
symbols.ForEach(symbol =>
{
var angle = (rotationAngle - symbol.anglePosition) % 360;
var active = angle > activeRange.x && angle < activeRange.y || angle > 360 + activeRange.x;
symbol.Active = active;
activeSymbol |= active;
});
crystal.Active = activeSymbol;
}
}
}
}