using TowerDefense.Level; using UnityEngine; using UnityEngine.UI; namespace TowerDefense.UI.HUD { /// /// A class for displaying the wave feedback /// [RequireComponent(typeof(Canvas))] public class WaveUI : MonoBehaviour { /// /// The text element to display information on /// public Text display; public Image waveFillImage; /// /// The total amount of waves for this level /// protected int m_TotalWaves; protected Canvas m_Canvas; /// /// cache the total amount of waves /// Update the display /// and Subscribe to waveChanged /// protected virtual void Start() { m_Canvas = GetComponent(); m_Canvas.enabled = false; m_TotalWaves = LevelManager.instance.waveManager.totalWaves; } /// /// Write the current wave amount to the display /// protected void UpdateDisplay() { m_Canvas.enabled = true; int currentWave = 0; string output = string.Format("{0}/{1}", currentWave, m_TotalWaves); display.text = output; } protected virtual void Update() { } /// /// Unsubscribe from events /// protected void OnDestroy() { } } }