UNITY之技能CD脚本
2016-08-25 14:19
267 查看
using UnityEngine;
using System.Collections;
public class SkillCD : MonoBehaviour {
private float currentTime;
public float SkillTime1;
private float hasTime;
private bool isCanAttack=true;
public UISprite mySp;
public UILabel myLab;
// Use this for initialization
void Start () {
currentTime = 0;
SkillTime1 = 5;
}
// Update is called once per frame
void Update () {
if (mySp.fillAmount.Equals(1)) {
return;
}
currentTime += Time.deltaTime;
hasTime = SkillTime1 - Mathf.FloorToInt (currentTime);
myLab.text = hasTime.ToString ();
mySp.fillAmount = currentTime / SkillTime1;
if (currentTime>=SkillTime1) {
currentTime = 0;
isCanAttack = true;
myLab.enabled = false;
this.GetComponent<UIButton> ().enabled = true;
}
}
void OnClick(){
if (isCanAttack) {
mySp.fillAmount = 0;
isCanAttack = false;
myLab.enabled = true;
this.GetComponent<UIButton> ().enabled = false;
}
}
}
using System.Collections;
public class SkillCD : MonoBehaviour {
private float currentTime;
public float SkillTime1;
private float hasTime;
private bool isCanAttack=true;
public UISprite mySp;
public UILabel myLab;
// Use this for initialization
void Start () {
currentTime = 0;
SkillTime1 = 5;
}
// Update is called once per frame
void Update () {
if (mySp.fillAmount.Equals(1)) {
return;
}
currentTime += Time.deltaTime;
hasTime = SkillTime1 - Mathf.FloorToInt (currentTime);
myLab.text = hasTime.ToString ();
mySp.fillAmount = currentTime / SkillTime1;
if (currentTime>=SkillTime1) {
currentTime = 0;
isCanAttack = true;
myLab.enabled = false;
this.GetComponent<UIButton> ().enabled = true;
}
}
void OnClick(){
if (isCanAttack) {
mySp.fillAmount = 0;
isCanAttack = false;
myLab.enabled = true;
this.GetComponent<UIButton> ().enabled = false;
}
}
}
相关文章推荐
- Unity 利用NGUI2.6.3做技能冷却的CD效果
- 【小松教你手游开发】【unity实用技能】控制摄像头脚本
- unity制作UI技能的定时器完整脚本
- 【Unity】NGUI实现技能冷却脚本
- Unity手游开发--NGUI实现冷却技能(CD)功能
- Unity制作游戏中技能使用后转CD的场景
- Unity 利用NGUI2.6.3做技能冷却的CD效果
- 【unity实用技能】控制摄像头脚本
- Unity 3D 技能释放的脚本 技能冷却时间
- Unity 利用NGUI2.6.3做技能冷却的CD效果
- Unity 3D笔记——脚本让camera转动起来
- Unity脚本中各函数成员的生命周期
- Unity不同脚本之间的执行顺序
- 【Unity技能】做一个简单的NPC
- Unity 用C#脚本读取JSON文件数据
- Unity编辑脚本(启动指南)-脚本对象
- 【小松教你手游开发】【unity实用技能】NGUI字体描边
- Linux shell脚本让命令行提示符cd到工作目录
- 【unity实用技能】unity编辑器工具之加载预制(Prefab)和场景(Scene)
- Max动画分割脚本 Unity 自动识别动画分割信息