add: Player script with hp

add: player death handling and OnLevelFailed event
This commit is contained in:
KOSMOGOR
2025-04-25 13:40:23 +03:00
parent 202cdb5702
commit dc6707f2a9
9 changed files with 75 additions and 7 deletions
+19
View File
@@ -0,0 +1,19 @@
using UnityEngine;
public class Player : MonoBehaviour
{
public float maxHp = 100;
[SerializeField] float hp;
void Start() {
hp = maxHp;
}
public void DealDamage(float damage) {
hp -= damage;
if (hp <= 0) {
FindAnyObjectByType<LevelController>().OnPlayerDie();
}
}
}