puzzle module framework, puzzle a ball module

This commit is contained in:
2022-11-18 02:10:05 +01:00
parent bd0934636f
commit 99e0452379
90 changed files with 4799 additions and 51 deletions

View File

@@ -0,0 +1,58 @@
using System;
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 RingLight 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;
}
}
}