refactor modules
This commit is contained in:
63
Assets/Station46/Modules/Holes/Scripts/Hole.cs
Normal file
63
Assets/Station46/Modules/Holes/Scripts/Hole.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Station46.Dispenser.Scripts;
|
||||
using Station46.Runtime;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Station46.Holes.Scripts
|
||||
{
|
||||
/// <summary>
|
||||
/// A hole used in the <see cref="Holes"/> module.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Emission), typeof(Collider))]
|
||||
public class Hole : Button
|
||||
{
|
||||
[Tooltip("The number of this hole, starting from the bottom left.")]
|
||||
[Min(0)]
|
||||
public int number;
|
||||
|
||||
public Emission Emission { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Emission = GetComponent<Emission>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
Emission.active = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var orb = other.GetComponent<DispenserOrb>();
|
||||
if (orb != null)
|
||||
{
|
||||
if (Active)
|
||||
{
|
||||
var color = EscapeRoomEngine.Engine.Runtime.Engine.Theme.activeColor;
|
||||
|
||||
orb.Color = color.hdr;
|
||||
Emission.color = color.hdr;
|
||||
Press();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
var orb = other.GetComponent<DispenserOrb>();
|
||||
if (orb != null)
|
||||
{
|
||||
var color = EscapeRoomEngine.Engine.Runtime.Engine.Theme.puzzleColor;
|
||||
|
||||
if (Active)
|
||||
{
|
||||
Release();
|
||||
Emission.color = color.hdr;
|
||||
}
|
||||
orb.Color = color.hdr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user