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);
|
|
}
|
|
|
|
}
|