symbol buttons
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Escape_Room_Engine.Desert.Scripts;
|
||||
using Escape_Room_Engine.Engine.Scripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
|
||||
{
|
||||
[RequireComponent(typeof(MeshRenderer))]
|
||||
public class SymbolButton : Button
|
||||
{
|
||||
private static readonly int FresnelPower = Shader.PropertyToID("_FresnelPower");
|
||||
private static readonly int Color = Shader.PropertyToID("_Color");
|
||||
|
||||
public EngineTheme theme;
|
||||
|
||||
public override bool Pressed
|
||||
{
|
||||
get => base.Pressed;
|
||||
protected set
|
||||
{
|
||||
base.Pressed = value;
|
||||
|
||||
var color =
|
||||
Pressed ? theme.activeColor
|
||||
: Active ? theme.puzzleColor
|
||||
: theme.solvedColor;
|
||||
_material.SetColor(FresnelPower, color);
|
||||
_material.SetColor(Color, color);
|
||||
}
|
||||
}
|
||||
|
||||
private Material _material;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_material = GetComponent<MeshRenderer>().material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d6620bee0f14224b11a19808d537cbd
|
||||
timeCreated: 1668813872
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Escape_Room_Engine.Desert.Scripts;
|
||||
using Escape_Room_Engine.Engine.Scripts.Modules;
|
||||
using NaughtyAttributes;
|
||||
@@ -12,6 +13,7 @@ namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
|
||||
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
|
||||
|
||||
[BoxGroup("Internal")] [Required] public Emission light;
|
||||
[BoxGroup("Internal")] public List<SymbolButton> symbols;
|
||||
|
||||
private Animator _animator;
|
||||
|
||||
@@ -28,9 +30,11 @@ namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
|
||||
{
|
||||
case PuzzleEventType.Restarted:
|
||||
light.color = theme.puzzleColor;
|
||||
symbols.ForEach(symbol => symbol.Enable());
|
||||
break;
|
||||
case PuzzleEventType.Solved:
|
||||
light.color = theme.solvedColor;
|
||||
symbols.ForEach(symbol => symbol.Disable());
|
||||
break;
|
||||
case PuzzleEventType.WrongInput:
|
||||
light.color = theme.puzzleColor;
|
||||
|
||||
Reference in New Issue
Block a user