Files
HacknSlash/Assets/Scripts/UIManager.cs

53 lines
1.3 KiB
C#
Raw Normal View History

2026-06-18 16:37:02 +01:00
using UnityEngine;
using TMPro; // Required for TextMeshPro
public class UIManager : MonoBehaviour
{
public static UIManager Instance { get; private set; }
[Header("Player UI")]
public TextMeshProUGUI healthText;
[Header("Wave UI")]
public TextMeshProUGUI waveText;
public TextMeshProUGUI enemiesLeftText;
void Awake()
{
// Simple Singleton setup for the prototype
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public void UpdatePlayerHealth(int currentHealth, int maxHealth)
{
if (healthText != null)
{
healthText.text = $"HP: {currentHealth} / {maxHealth}";
}
}
public void UpdateWaveProgress(int currentWave, int totalWaves)
{
if (waveText != null)
{
// If totalWaves is 0, it means endless mode
string totalString = totalWaves > 0 ? totalWaves.ToString() : "???";
waveText.text = $"Wave: {currentWave} / {totalString}";
}
}
public void UpdateEnemiesRemaining(int enemiesAlive)
{
if (enemiesLeftText != null)
{
enemiesLeftText.text = $"Enemies Left: {enemiesAlive}";
}
}
}