From 0c955ad0576303aee0d22d20d72de7beeb1e8ee3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 29 Apr 2019 14:39:10 +0200 Subject: [PATCH] Add hp true max --- Assets/Scripts/Entity.cs | 8 +++++++- Assets/Scripts/FillAmountFromPlayerHP.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index c2cfe15..cae8daa 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -4,9 +4,14 @@ using UnityEngine; public class Entity : MonoBehaviour { - public float hpMax; + [BeforeStartAttribute] + public float hpTrueMax; + public bool overlappable = false; + [AfterStartAttribute] + public float hpMax; + [AfterStartAttribute] public float hp; @@ -30,6 +35,7 @@ public class Entity : MonoBehaviour map = gameController.GetComponentInChildren(); GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); messageBar = canvas.GetComponentInChildren(); + hpMax = hpTrueMax; hp = hpMax; } diff --git a/Assets/Scripts/FillAmountFromPlayerHP.cs b/Assets/Scripts/FillAmountFromPlayerHP.cs index be01f33..4c7fe47 100644 --- a/Assets/Scripts/FillAmountFromPlayerHP.cs +++ b/Assets/Scripts/FillAmountFromPlayerHP.cs @@ -7,6 +7,7 @@ public class FillAmountFromPlayerHP : MonoBehaviour { private EntityPlayer player; private Image image; + public bool max; private void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent(); @@ -14,6 +15,11 @@ public class FillAmountFromPlayerHP : MonoBehaviour } private void Update() { - image.fillAmount = player.hp / player.hpMax; + if(max) { + image.fillAmount = player.hpMax / player.hpTrueMax; + } + else { + image.fillAmount = player.hp / player.hpTrueMax; + } } }