ChangeHealth Skript erstellt, darin wird der int maxHealth und int Health definiert, wo die Methode Die aufgerufen wird, sobald das Leben auf 0 dropen sollte. In Methode Die sind Kommentare angefügt, für kommende Features.
This commit is contained in:
8
Assets/Prefabs/Player Life.meta
Normal file
8
Assets/Prefabs/Player Life.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: edad4a651481cb24ab82da3eb69bb7f7
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
33
Assets/Scripts/Life/ChangeHealth.cs
Normal file
33
Assets/Scripts/Life/ChangeHealth.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ChangeHealth : MonoBehaviour
|
||||||
|
{
|
||||||
|
public int maxHealth;
|
||||||
|
public int health;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
health = maxHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Hit(int amount) {
|
||||||
|
health -= amount;
|
||||||
|
|
||||||
|
if (health < 0) {
|
||||||
|
health = 0; // no negatives
|
||||||
|
Debug.Log("Death");
|
||||||
|
Die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Die() {
|
||||||
|
// Saves current day
|
||||||
|
Debug.Log("Save the current day");
|
||||||
|
// Jumpscare
|
||||||
|
Debug.Log("Jumpscare! Boo!");
|
||||||
|
// After Jumpscare Delay Overlay appears
|
||||||
|
// Decline Overlay
|
||||||
|
Debug.Log("Return to Main Menue");
|
||||||
|
// Accept
|
||||||
|
Debug.Log("Get 1 heart back and get 25+ energy back");
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Life/ChangeHealth.cs.meta
Normal file
2
Assets/Scripts/Life/ChangeHealth.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d2c342d03f196db429843b7001a79f7d
|
||||||
Reference in New Issue
Block a user