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
+1 -2
View File
@@ -12,8 +12,7 @@ public class CameraMovement : MonoBehaviour
void Start() {
cam = GetComponentInChildren<Camera>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
GameController.SetCursorState(true);
}
void Update() {
+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();
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f9b2638aeb16f76429ff062f38f6d0be