2024-11-14 18:15:51 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
|
|
public class DamageNum : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
public Text txtInfo;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
public float moveSpeed;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>λ<EFBFBD><CEBB>
|
|
|
|
|
public float moveOffset;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
public float hideSpeed;
|
|
|
|
|
//λ<><CEBB>
|
|
|
|
|
public RectTransform rec;
|
|
|
|
|
//<><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public CanvasGroup can;
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
private Vector2 startPos;
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
can.alpha = 1;
|
|
|
|
|
startPos = rec.localPosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
startPos.y += Time.deltaTime * moveSpeed;
|
|
|
|
|
if (startPos.y >= moveOffset)
|
|
|
|
|
{
|
|
|
|
|
startPos.y = moveOffset;
|
|
|
|
|
}
|
2024-11-21 18:05:42 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rec.localPosition = startPos;
|
|
|
|
|
}
|
2024-11-14 18:15:51 +08:00
|
|
|
|
|
2024-11-28 17:59:14 +08:00
|
|
|
|
if (startPos.y >= 100f)
|
2024-11-14 18:15:51 +08:00
|
|
|
|
{
|
2024-11-28 17:59:14 +08:00
|
|
|
|
can.alpha -= Time.deltaTime * hideSpeed;
|
|
|
|
|
if (can.alpha <= 0)
|
2024-11-14 18:15:51 +08:00
|
|
|
|
{
|
2024-11-21 18:05:42 +08:00
|
|
|
|
ResetData();
|
2024-11-14 18:15:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateTxtInfo(string str)
|
|
|
|
|
{
|
|
|
|
|
txtInfo.text=str;
|
|
|
|
|
}
|
2024-11-21 18:05:42 +08:00
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
public void ResetData()
|
|
|
|
|
{
|
|
|
|
|
can.alpha = 0;
|
|
|
|
|
rec.position = Vector3.zero;
|
2024-12-02 18:00:58 +08:00
|
|
|
|
rec.localScale = Vector3.one;
|
2024-11-21 18:05:42 +08:00
|
|
|
|
PoolMgr.Instance.PushObj(this.gameObject);
|
|
|
|
|
}
|
2024-11-14 18:15:51 +08:00
|
|
|
|
}
|