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.
51 lines
1.2 KiB
51 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Skill : MonoBehaviour
|
|
{
|
|
// 定义一个遮罩
|
|
public GameObject mask;
|
|
|
|
public float t = 10; // 当前技能的冷却时间
|
|
private float coolTime = 0; // 当前冷却剩余时间
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
// 当前技能正在冷却的时候才会计算
|
|
if (coolTime > 0)
|
|
{
|
|
coolTime -= Time.deltaTime; // 逐帧递减冷却时间
|
|
if (coolTime < 0) coolTime = 0; // 当冷却时间小于零则设置为零
|
|
this.GetComponent<TextMeshProUGUI>().text = coolTime.ToString("0.0"); // 显示冷却时间
|
|
|
|
// 获取当前遮罩的对象上面的Image组件
|
|
// 修改fillAmount属性的值
|
|
mask.GetComponent<Image>().fillAmount = coolTime/t; //
|
|
|
|
}
|
|
}
|
|
// 技能效果:加速
|
|
public void Speed()
|
|
{
|
|
Debug.Log("speed");
|
|
if(coolTime == 0) {
|
|
// 技能效果
|
|
// 写你的技能效果代码
|
|
GameObject.Find("Camera").GetComponent<Status>().hp += 10;
|
|
|
|
// 当前进入冷却
|
|
coolTime = t;
|
|
}
|
|
}
|
|
}
|