using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class UI_CountdownWindow : MonoBehaviour
{
	[SerializeField]
	private TextFader _readyText;
	[SerializeField]
	private TextFader _setText;
	[SerializeField]
	private TextFader _battleText;

	void Start()
	{
		BattleController.Instance.OnPrepareBattle.AddListener(DoBattleText);
	}
	public void DoBattleText(BoidController inControllerA, BoidController inControllerB)
	{
		StartCoroutine(BattleTextRoutine());
	}
	private IEnumerator BattleTextRoutine()
	{
		_readyText.transform.localScale = Vector3.zero;
		_readyText.gameObject.SetActive(true);
		_readyText.transform.DOScale(1, .25f);

		yield return new WaitForSeconds(1);

		_readyText.transform.DOScale(0, .25f).OnComplete(() =>
		{
			_readyText.gameObject.SetActive(false);
			_readyText.enabled = true;
		});
		_setText.transform.localScale = Vector3.zero;
		_setText.gameObject.SetActive(true);
		_setText.transform.DOScale(1, .25f);

		yield return new WaitForSeconds(1);

		_setText.transform.DOScale(0, .25f).OnComplete(() =>
		{
			_setText.gameObject.SetActive(false);
			_setText.enabled = true;
		});
		_battleText.transform.localScale = Vector3.zero;
		_battleText.gameObject.SetActive(true);
		_battleText.transform.DOScale(1, .25f);

		yield return new WaitForSeconds(1);

		_battleText.transform.DOScale(0, .25f).OnComplete(() =>
		{
			_battleText.gameObject.SetActive(false);
			_battleText.enabled = true;
		});
	}
}
