Add hp true max
This commit is contained in:
parent
1db2d0c22e
commit
0c955ad057
2 changed files with 14 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue