using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class TurnSystemUI : MonoBehaviour
{
[SerializeField] private Button endTurnButton;
[SerializeField] private TextMeshProUGUI turnNumberTextMesh;
[SerializeField] private GameObject enemyTurnVisualGameObject;
[SerializeField] private TurnSystem turnSystem;
private void Start() {
UpdateTurnNumberText();
endTurnButton.onClick.AddListener(() => {
turnSystem.EndTurn();
});
turnSystem.OnTurnChanged += TurnSystem_OnTurnChanged;
UpdateEnemyTurnVisual();
UpdateEndTurnButtonVisibility();
}
public void TurnSystem_OnTurnChanged(object sender, EventArgs empty) {
UpdateTurnNumberText();
UpdateEnemyTurnVisual();
UpdateEndTurnButtonVisibility();
}
public void UpdateTurnNumberText() {
turnNumberTextMesh.text = $"TURN {turnSystem.GetTurnNumber()}";
}
private void UpdateEnemyTurnVisual() {
enemyTurnVisualGameObject.SetActive(!turnSystem.IsPlayerTurn());
}
private void UpdateEndTurnButtonVisibility() {
endTurnButton.gameObject.SetActive(turnSystem.IsPlayerTurn());
}
}