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 class Entity : MonoBehaviour
{ {
public float hpMax; [BeforeStartAttribute]
public float hpTrueMax;
public bool overlappable = false; public bool overlappable = false;
[AfterStartAttribute]
public float hpMax;
[AfterStartAttribute] [AfterStartAttribute]
public float hp; public float hp;
@ -30,6 +35,7 @@ public class Entity : MonoBehaviour
map = gameController.GetComponentInChildren<Map>(); map = gameController.GetComponentInChildren<Map>();
GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");
messageBar = canvas.GetComponentInChildren<MessageBar>(); messageBar = canvas.GetComponentInChildren<MessageBar>();
hpMax = hpTrueMax;
hp = hpMax; hp = hpMax;
} }

View file

@ -7,6 +7,7 @@ public class FillAmountFromPlayerHP : MonoBehaviour
{ {
private EntityPlayer player; private EntityPlayer player;
private Image image; private Image image;
public bool max;
private void Start() { private void Start() {
player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>();
@ -14,6 +15,11 @@ public class FillAmountFromPlayerHP : MonoBehaviour
} }
private void Update() { private void Update() {
image.fillAmount = player.hp / player.hpMax; if(max) {
image.fillAmount = player.hpMax / player.hpTrueMax;
}
else {
image.fillAmount = player.hp / player.hpTrueMax;
}
} }
} }