Files
Kursach_StealthAction/Assets/Scripts/MutantHealth.cs
T
2026-10-19 20:14:24 +03:00

37 lines
884 B
C#

using UnityEngine;
public class MutantHealth : MonoBehaviour
{
public float maxHealth = 50f;
private float currentHealth;
public bool IsDead => currentHealth <= 0;
public float CurrentHealth => currentHealth;
private BlindMutantAI mutantAI;
void Awake()
{
currentHealth = maxHealth;
mutantAI = GetComponent<BlindMutantAI>();
}
public void TakeDamage(float damage, Transform attacker = null)
{
if (IsDead) return;
currentHealth -= damage;
Debug.Log($"Мутант получил урон: {damage}! Осталось: {currentHealth}");
if (mutantAI != null && attacker != null)
{
mutantAI.OnDamagedByPlayer(attacker);
}
if (currentHealth <= 0)
{
Debug.Log("МУТАНТ УМЕР!");
Destroy(gameObject);
}
}
}