You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
936 B
41 lines
936 B
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HpBar : IVTraceTarget
|
|
{
|
|
private Slider sldHp;
|
|
|
|
public override void SetCameraTarget(Camera cammain, Camera camui, RectTransform trfpr, Transform trftarget, float foffsety)
|
|
{
|
|
base.SetCameraTarget(cammain, camui, trfpr, trftarget, foffsety);
|
|
sldHp = GetComponent<Slider>();
|
|
}
|
|
|
|
public void ShowHpBar(float fhp)
|
|
{
|
|
if (fhp <= 0.06f)
|
|
sldHp.value = 0.06f;
|
|
else if (fhp <= 0)
|
|
sldHp.value = 0f;
|
|
else
|
|
sldHp.value = fhp;
|
|
|
|
if (!gameObject.activeSelf)
|
|
{
|
|
SetPosition();
|
|
gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
CancelInvoke(nameof(HideHpBar));
|
|
}
|
|
|
|
Invoke(nameof(HideHpBar), 0.6f);
|
|
}
|
|
|
|
public void HideHpBar()
|
|
{
|
|
CancelInvoke(nameof(HideHpBar));
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|