using TMPro; using UnityEngine; using UnityEngine.UI; using DG.Tweening; public class BloodSlider : MonoBehaviour { public Image blood1; public Image blood2; public TextMeshProUGUI enemyName; public GameObject damageUIPre; public Transform damageUIPos; private void Start() { if(blood1 == null) return; blood1.fillAmount = 1; blood2.fillAmount = 1; } public void CreateDamagePre(float damage, bool criticalHit) { GameObject damageUI = Instantiate(damageUIPre, transform); float offsetX = Random.Range(-100f, 100f); float offsetY = Random.Range(-40f, 25f); damageUI.transform.localPosition = damageUIPos.localPosition+new Vector3(offsetX,offsetY,0); damageUI.GetComponent().ShowDamage(damage, criticalHit); } public void SetName(string name) { enemyName.text = name; } public void SetValue(float value) { if (value <= 0) gameObject.SetActive(false); else gameObject.SetActive(true); blood1.fillAmount = value; } public void SetValue2(float currentBlood, float totalBlood) { float value = currentBlood / totalBlood; DOTween.To(() => blood2.fillAmount, x => blood2.fillAmount = x, value, 0.5f);//Ѫ���仯 blood1.fillAmount = value; } private void Update() { transform.parent.GetComponent().LookAt(GameInit.Ins.playerCam.transform); } }