using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;

public class Announcments : MonoBehaviour
{
	[SerializeField] TextMeshProUGUI announcementText;

	private float remainingTime;

	void Update()
	{
		if (remainingTime > 0)
		{
			remainingTime -= Time.deltaTime;
		}
		else
		{
			announcementText.enabled = false;
			remainingTime = 0;
			enabled = false;
		}
	}

	public void AnnounceText(string text, float time)
	{
		announcementText.text = text;
		announcementText.enabled = true;
		remainingTime = time;
		enabled = true;
	}

	public void AnnounceText(string text)
	{
		announcementText.text = text;
		announcementText.enabled = true;
		enabled = false;
	}

	public void StopAnnouncement()
	{
		announcementText.text = String.Empty;
		remainingTime = 0;
		announcementText.enabled = false;
		enabled = false;
	}
}
