1
Fork 0

Add hp true max

This commit is contained in:
Steffo 2019-04-29 14:39:10 +02:00
parent 1db2d0c22e
commit 0c955ad057
2 changed files with 14 additions and 2 deletions

View file

@ -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<Map>();
GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");
messageBar = canvas.GetComponentInChildren<MessageBar>();
hpMax = hpTrueMax;
hp = hpMax;
}

View file

@ -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<EntityPlayer>();
@ -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;
}
}
}