HPbarzissou

This commit is contained in:
ohgushiyuga
2026-08-27 17:59:06 +09:00
parent 52341100ed
commit 9864b95a91
48 changed files with 3379 additions and 19467 deletions

View File

@@ -7,8 +7,10 @@ public class EnemyHealth : MonoBehaviour, IDamageable
[SerializeField] private float knockbackDuration = 0.5f;
public float CurrentHealth { get; private set; }
public float MaxHealth => maxHealth;
public bool IsDead { get; private set; }
public event Action<float, float> OnHealthChanged; // ★追加:HP変更イベント(現在HP, 最大HP)
public event Action<float> OnKnockbackRequested;
public event Action OnDeath;
@@ -26,6 +28,11 @@ public class EnemyHealth : MonoBehaviour, IDamageable
col = GetComponent<Collider>();
}
private void Start()
{
OnHealthChanged?.Invoke(CurrentHealth, maxHealth);
}
private void OnEnable()
{
if (enemyAI != null)
@@ -49,6 +56,7 @@ public class EnemyHealth : MonoBehaviour, IDamageable
if (IsDead) return;
CurrentHealth = Mathf.Max(0f, CurrentHealth - damageInfo.amount);
OnHealthChanged?.Invoke(CurrentHealth, maxHealth); // ★HP変更をUIに通知
if (CurrentHealth <= 0f)
{