45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
|
|
{
|
|
public class Ring : MonoBehaviour
|
|
{
|
|
public float rotationAngle;
|
|
[MinMaxSlider(-180, 180)] public Vector2 activeRange;
|
|
[Required] public Crystal crystal;
|
|
public List<Symbol> symbols;
|
|
|
|
public bool Solved
|
|
{
|
|
set
|
|
{
|
|
_solved = value;
|
|
crystal.Active = !_solved;
|
|
symbols.ForEach(symbol => symbol.Active = !_solved);
|
|
}
|
|
}
|
|
|
|
private bool _solved;
|
|
|
|
private void Update()
|
|
{
|
|
if(!_solved)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|