механики
This commit is contained in:
1 parent
dd5a95a4d3
commit
11d57bec19
129 files changed
+21889
-62
No files matched your search
@@ -1,21 +1,37 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class MutantHealth : MonoBehaviour
|
||||
{
|
||||
public float maxHealth = 50f;
|
||||
private float currentHealth;
|
||||
|
||||
void Start() { currentHealth = maxHealth; }
|
||||
public bool IsDead => currentHealth <= 0;
|
||||
public float CurrentHealth => currentHealth;
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
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("Мутант получил урон! Осталось: " + currentHealth);
|
||||
|
||||
Debug.Log($"Мутант получил урон: {damage}! Осталось: {currentHealth}");
|
||||
|
||||
if (mutantAI != null && attacker != null)
|
||||
{
|
||||
mutantAI.OnDamagedByPlayer(attacker);
|
||||
}
|
||||
|
||||
if (currentHealth <= 0)
|
||||
{
|
||||
Debug.Log("МУТАНТ УМЕР!");
|
||||
Destroy(gameObject); // Уничтожаем модельку мутанта
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user