From 12f21516ffd7caacfec259d6771677769384ffe8 Mon Sep 17 00:00:00 2001 From: Mikkel Bybjerg Date: Sat, 27 Apr 2019 11:14:45 +0200 Subject: enemy collision and health --- nGJ2019/Assets/Scripts/HealthBar.cs | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 nGJ2019/Assets/Scripts/HealthBar.cs (limited to 'nGJ2019/Assets/Scripts/HealthBar.cs') diff --git a/nGJ2019/Assets/Scripts/HealthBar.cs b/nGJ2019/Assets/Scripts/HealthBar.cs new file mode 100644 index 0000000..4c30b42 --- /dev/null +++ b/nGJ2019/Assets/Scripts/HealthBar.cs @@ -0,0 +1,54 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class HealthBar : MonoBehaviour +{ + public GameObject crystalPrefab; + public Material liveCrystal; + public Material deadCrystal; + + public int lives; + + private int currentHealth; + public int health + { + get{return currentHealth;} + set + { + currentHealth = value; + updateCrystals(); + } + } + + private List crystals = new List(); + + private void updateCrystals() + { + for(int i=0; i i) + crystals[i].material = liveCrystal; + else + crystals[i].material = deadCrystal; + } + } + + void Start() + { + for(int i=0; i()); + } + + health = lives; + updateCrystals(); + } + + // Update is called once per frame + void Update() + { + + } +} -- cgit v1.2.3