Files
Kursach_StealthAction/Assets/Scripts/PlayerHealth.cs
T

21 lines
627 B
C#
Raw Normal View History

2026-10-11 19:16:11 +03:00
using UnityEngine;
public class PlayerHealth : MonoBehaviour
2026-10-11 19:15:15 +03:00
{
2026-10-11 19:16:11 +03:00
public float maxHealth = 100f;
private float currentHealth;
void Start() { currentHealth = maxHealth; }
public void TakeDamage(float damage)
2026-10-11 19:15:15 +03:00
{
2026-10-11 19:16:11 +03:00
currentHealth -= damage;
Debug.Log("Игрок получил урон! Осталось здоровья: " + currentHealth);
2026-10-11 19:15:15 +03:00
2026-10-11 19:16:11 +03:00
if (currentHealth <= 0)
{
Debug.Log("ИГРОК МЕРТВ! Конец игры.");
// Здесь позже можно будет добавить перезагрузку уровня
}
2026-10-11 19:15:15 +03:00
}
}