Completed course 2 adn 3, working on 4

This commit is contained in:
2026-03-20 17:34:22 +00:00
parent 623ad6f509
commit db966bab55
507 changed files with 67348 additions and 4667 deletions

View File

@@ -0,0 +1,31 @@
using UnityEngine;
using UnityEngine.UI;
public class UnitHealthBar : MonoBehaviour
{
public GameObject healthContainer;
public RectTransform healthFill;
private float maxSize;
void Awake()
{
maxSize = healthFill.sizeDelta.x;
healthContainer.SetActive(false);
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void UpdateHealthBar(int curHp, int maxHp)
{
healthContainer.SetActive(true);
float healthPercentage = (float)curHp / (float)maxHp;
healthFill.sizeDelta = new Vector2(maxSize * healthPercentage, healthFill.sizeDelta.y);
}
}