relate terminal and ball

This commit is contained in:
2022-11-21 11:41:06 +01:00
parent eeb90ac24c
commit dbcb9c0a24
11 changed files with 55 additions and 76 deletions

View File

@@ -1,58 +1,13 @@
using System;
using EscapeRoomEngine.Engine.Runtime.Modules;
using EscapeRoomEngine.Engine.Runtime.Modules;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
{
[RequireComponent(typeof(Animator))]
public class Ball : PuzzleState
public class Ball : ModuleState
{
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;
}
public override void SetModule(Module module) {}
}
}