mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-09-11 08:17:01 +00:00
Aquaphobia spirits
This commit is contained in:
11 files changed
+1332
-33
No files matched your search
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
// @MindfulMinun
|
||||
public class Health : MonoBehaviour {
|
||||
public int startingHealth;
|
||||
public int currentHealth;
|
||||
public bool isInvincible;
|
||||
public bool isDead;
|
||||
public UnityEvent OnDead;
|
||||
public UnityEvent OnHit;
|
||||
|
||||
void Start() {
|
||||
OnDead = new UnityEvent();
|
||||
OnHit = new UnityEvent();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (Input.GetKeyDown(KeyCode.E)) {
|
||||
takeHit();
|
||||
OnHit.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
void takeHit() {
|
||||
if (isInvincible) return;
|
||||
currentHealth = Mathf.Clamp(currentHealth - 1, 0, startingHealth);
|
||||
isDead = currentHealth <= 0;
|
||||
if (isDead) OnDead.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user