diff options
Diffstat (limited to 'td/Assets/Scripts/gameStats.cs')
-rw-r--r-- | td/Assets/Scripts/gameStats.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/td/Assets/Scripts/gameStats.cs b/td/Assets/Scripts/gameStats.cs index af13f99..daeb3cf 100644 --- a/td/Assets/Scripts/gameStats.cs +++ b/td/Assets/Scripts/gameStats.cs @@ -9,13 +9,16 @@ public class gameStats : MonoBehaviour { GameObject canvas; Text txtMoney; Text txtScore; + Text txtHp; int displayedScore; int displayedMoney; + int displayedHealth; void Start() { canvas = transform.GetChild (0).gameObject; txtMoney = canvas.transform.Find ("playerMoney").gameObject.GetComponent <Text>(); txtScore = canvas.transform.Find ("playerScore").gameObject.GetComponent <Text>(); + txtHp = canvas.transform.Find ("playerHealth").gameObject.GetComponent <Text>(); } void Update () { @@ -30,6 +33,11 @@ public class gameStats : MonoBehaviour { updateScore (displayedScore); } + if (Player.health () != displayedHealth) { + displayedHealth = Player.health (); + updateHealth (displayedHealth); + } + } void updateScore(int newScore) { @@ -40,4 +48,8 @@ public class gameStats : MonoBehaviour { txtMoney.text = ("Money: " + newMoney.ToString () + "$"); } + void updateHealth(int newHp) { + txtHp.text = ("HP: " + newHp.ToString ()); + } + } |