add: Player script with hp
add: player death handling and OnLevelFailed event
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9b2638aeb16f76429ff062f38f6d0be
|
||||
Reference in New Issue
Block a user