Files
Kursach_StealthAction/Assets/Scripts/PlayerHealth.cs
T

29 lines
765 B
C#
Raw Normal View History

2026-10-19 20:14:24 +03:00
using UnityEngine;
2026-10-11 19:16:11 +03:00
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;
2026-10-19 20:14:24 +03:00
public bool IsDead => currentHealth <= 0;
public float CurrentHealth => currentHealth;
void Start()
{
currentHealth = maxHealth;
}
2026-10-11 19:16:11 +03:00
public void TakeDamage(float damage)
2026-10-11 19:15:15 +03:00
{
2026-10-19 20:14:24 +03:00
if (IsDead) return;
2026-10-11 19:16:11 +03:00
currentHealth -= damage;
2026-10-19 20:14:24 +03:00
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
}
}