using System.Collections; using System.Collections.Generic; using UnityEngine; public class CDScripts : MonoBehaviour { public int cd_time = 2; //技能的冷却速度 public bool cd_isCan = false; //是否可以释放技能的标志位 private UISprite cd_sprite; private void Awake() { cd_sprite = GameObject.Find("Sprite").GetComponent<UISprite>(); } // Update is called once per frame void Update () { if(Input.GetKeyDown(KeyCode.A)&&cd_isCan==false) { cd_sprite.fillAmount = 1.0f; cd_isCan = true; } if(cd_isCan==true) { cd_sprite.fillAmount -= (1f / cd_time) * Time.deltaTime; //对技能的冷却效果进行减少 if (cd_sprite.fillAmount <= 0.05) { cd_sprite.fillAmount = 0f; cd_isCan = false; //技能的冷却时间满足了 } } } }