This commit is contained in:
JA
2026-06-27 03:36:46 +08:00
parent aec4e97d27
commit 7a8d4a5d83
1215 changed files with 48271 additions and 146052 deletions

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
namespace IndianOceanAssets.Engine2_5D
{
// Handles updating and displaying the health UI
public class HealthUI : MonoBehaviour
{
[SerializeField] private Image healthFill; // UI image for health bar
public static HealthUI Instance; // Singleton instance
// Assigns singleton instance
private void Awake()
{
Instance = this;
}
// Updates the health bar fill based on health values
public void UpdateHealthBar(float maxHealth, float currentHealth)
{
healthFill.fillAmount = currentHealth / maxHealth;
}
// Starts coroutine to reload scene
public void ReloadScene()
{
StartCoroutine(_ReloadScene());
}
// Waits and reloads current scene
IEnumerator _ReloadScene()
{
yield return new WaitForSeconds(1f);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
}