Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

62 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Variables;
public class SneakyTextController : MonoBehaviour
{
[SerializeField]
private Reference<float> m_lightLevel;
[SerializeField]
private Reference<bool> m_freezePlayer;
[SerializeField]
private float m_time = 10;
[SerializeField]
private TMPro.TextMeshProUGUI m_text;
private bool m_hasTriggered = false;
private void OnEnable()
{
m_lightLevel.OnValueChanged += OnLightChange;
}
private void OnDisable()
{
m_lightLevel.OnValueChanged -= OnLightChange;
}
private void Start()
{
m_text.gameObject.SetActive(false);
}
private void OnLightChange(float value)
{
Color color = m_text.color;
color.a = 1 - m_lightLevel;
m_text.color = color;
if (!m_hasTriggered && !m_freezePlayer)
{
m_hasTriggered = true;
StartCoroutine(Timer( m_time));
}
}
private IEnumerator Timer(float time)
{
Debug.Log("here");
m_text.gameObject.SetActive(true);
yield return new WaitForSeconds(time);
m_text.gameObject.SetActive(false);
}
}