37 lines
884 B
C#
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);
|
|
}
|
|
}
|
|
} |