第一种技能
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SkillOne : MonoBehaviour
{
public Image MaskImage;
public Button MaskButton;
public Text CDTimeText;
//累加器
private float Times = 0f;
public float CD_Time = 0f;//技能时间
private bool ButtonMashSwitch = false;
void Start()
{
MaskImage.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (ButtonMashSwitch)//通过一个开关来判定是不是进入冷却阶段
{
Times += Time.deltaTime;
MaskImage.fillAmount = Times / CD_Time;
CDTimeText.text = Math.Round(CD_Time - Times, 1).ToString();
if (Times >= CD_Time)
{
CDTimeText.text = null;
ButtonMashSwitch = false;
MaskImage.fillAmount = 1;
Times = 0f;
//MaskButton.interactable = true;
MaskButton.enabled = true;
MaskImage.gameObject.SetActive(false);
}
}
}
public void OnClickBtn()
{
MaskImage.gameObject.SetActive(true);
//MaskButton.interactable = false;//使Button失效并且变灰
MaskButton.enabled = false;//仅仅使Button失效
ButtonMashSwitch = true;
}
}
image.png
4.gif
网友评论