新增game hud字体
移除旧版血量控制
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using GameFramework;
|
||||
namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
// Handles health, damage, and death for entities
|
||||
@@ -27,15 +27,13 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
health -= damageAmount;
|
||||
|
||||
// Update UI if player
|
||||
if (isPlayer)
|
||||
HealthUI.Instance.UpdateHealthBar(maxHealth, health);
|
||||
|
||||
// If dead, reload scene if player, then die
|
||||
// If dead, trigger game over if player, then die
|
||||
if (health <= 0)
|
||||
{
|
||||
if (isPlayer)
|
||||
HealthUI.Instance.ReloadScene();
|
||||
{
|
||||
GameManager.GameOver();
|
||||
}
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c8e10d31f74f214b9b18e7e378bbb30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user