fgm24/Assets/Scripts/UI/DamageText.cs

30 lines
771 B
C#
Raw Normal View History

2024-02-04 01:25:59 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class DamageText : MonoBehaviour
{
[SerializeField] AnimationCurve damageToSize;
2024-02-04 02:11:43 +01:00
[SerializeField] TextMeshPro damageText;
[SerializeField]
private Color normalColor, critColor, superCritColor;
[SerializeField]
private float critThreshold, superCritThreshold;
2024-02-04 01:25:59 +01:00
public void Init(float damage)
{
2024-02-04 02:11:43 +01:00
transform.localScale = Vector3.one * damageToSize.Evaluate(damage);
damageText.color = normalColor;
if (damage > critThreshold)
damageText.color = critColor;
if (damage > superCritThreshold)
damageText.color = superCritColor;
2024-02-04 08:27:38 +01:00
damageText.text = ((int)damage).ToString();
2024-02-04 01:25:59 +01:00
}
}