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.
43 lines
1.0 KiB
43 lines
1.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class CoolDown : MonoBehaviour
|
|
{
|
|
public float MaxTime = 10; // 当前技能最大冷却时间
|
|
private float CoolTime = 0; // 当前冷却的时间
|
|
public UnityEngine.UI.Image mask; // 当前遮罩的image组件
|
|
|
|
// Start is called before the first frame update
|
|
void Update()
|
|
{
|
|
if(CoolTime>0)
|
|
{
|
|
CoolTime -= Time.deltaTime;
|
|
CoolShow();
|
|
}
|
|
else
|
|
{
|
|
CoolTime = 0;
|
|
GetComponentInChildren<TextMeshProUGUI>().SetText("");
|
|
}
|
|
}
|
|
|
|
public void InUse() {
|
|
if (CoolTime == 0)
|
|
{
|
|
CoolTime = MaxTime;
|
|
Camera.main.GetComponent<Player>().Hp += 10;
|
|
Camera.main.GetComponent<Player>().SetHp();
|
|
}
|
|
}
|
|
|
|
void CoolShow() {
|
|
GetComponentInChildren<TextMeshProUGUI>().SetText(CoolTime.ToString("F2"));
|
|
mask.fillAmount = CoolTime/MaxTime;
|
|
}
|
|
}
|