Project_WL/Assets/Script/HUD/HUDDMGUI.cs

55 lines
1.7 KiB
C#

using TMPro;
using UnityEngine;
public class HUDDMGUI : HUDBase
{
public TextMeshProUGUI[] dmgs;
private float moveSpeed = 1.0f;
private float alphaSpeed = 0.5f;
private float destroyTime = .9f;
bool usedmg2;
public void Set(Transform _target, string TextColor, double Damage, eStat Critical)
{
if (NewGameUI.Ins.m_BangchiUI.isActiveAndEnabled || !OptionInfo.Ins.go_check[0].activeSelf)
{
Off();
return;
}
gameObject.SetActive(true);
Set_Target(_target);
Vector3 randomPosition = new Vector3(
Random.Range(-25f, 25f), // x 축 랜덤 범위
Random.Range(-25f, 25f) // y 축 랜덤 범위
);
dmgs[0].transform.localPosition = dmgs[1].transform.localPosition = randomPosition;
//dmgs[0].transform.localPosition = dmgs[1].transform.localPosition = Vector3.zero;
dmgs[0].alpha = dmgs[1].alpha = 1f;
dmgs[0].text = dmgs[1].text = DSUtil.Format("{0}{1}", TextColor, NumberFormatter.FormatNumber(Damage));
usedmg2 = Critical == eStat.CRI || Critical == eStat.M_CRI;
if (usedmg2)
{
dmgs[0].gameObject.SetActive(false);
dmgs[1].gameObject.SetActive(true);
}
else
{
dmgs[0].gameObject.SetActive(true);
dmgs[1].gameObject.SetActive(false);
}
Set_Coroutine(Off, destroyTime);
}
private void LateUpdate()
{
int index = usedmg2 ? 1 : 0;
dmgs[index].transform.Translate(new Vector3(0, moveSpeed * Time.deltaTime, 0)); // 텍스트 위치
dmgs[index].alpha = Mathf.Lerp(dmgs[index].alpha, 0, Time.deltaTime * alphaSpeed); // 텍스트 알파값
}
}