Initial commit
This commit is contained in:
53
Assets/Scripts/UIManager.cs
Normal file
53
Assets/Scripts/UIManager.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user