<font style=
"color:rgb(51, 51, 51)"
>
using
Assets.Classes.com.system;
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
UnityEngine;
namespace
Assets.Classes.com.view.ui
{
enum
SKILLTYPE
{
Q_SKILL = 10,
W_SKILL = 20,
E_SKILL = 30,
R_SKILL = 100
}
class
SkillsMenu_UI
{
private
SKILLTYPE skillType;
private
bool
isSkill =
false
;
private
bool
isCooling =
false
;
private
float
coolingTime;
private
GameObject currentObj;
public
SkillsMenu_UI(GameObject skillsObj)
{
HandlerListener(
"Q_Skill"
, skillsObj);
HandlerListener(
"W_Skill"
, skillsObj);
HandlerListener(
"E_Skill"
, skillsObj);
HandlerListener(
"R_Skill"
, skillsObj);
}
private
void
HandlerListener(
string
skillName, GameObject go)
{
Transform Skill = go.transform.FindChild(skillName);
UIEventListener.Get(Skill.gameObject).onClick = OnClick;
}
private
void
OnClick(GameObject go)
{
Debug.Log(
"点击了技能按钮 : "
+ go.name);
switch
(go.name)
{
case
"Q_Skill"
: skillType = SKILLTYPE.Q_SKILL; HandlerSkill(skillType, go);
break
;
case
"W_Skill"
: skillType = SKILLTYPE.W_SKILL; HandlerSkill(skillType, go);
break
;
case
"E_Skill"
: skillType = SKILLTYPE.E_SKILL; HandlerSkill(skillType, go);
break
;
case
"R_Skill"
: skillType = SKILLTYPE.R_SKILL; HandlerSkill(skillType, go);
break
;
}
}
private
void
HandlerSkill(SKILLTYPE type, GameObject go)
{
if
(!isCooling || !isSkill)
{
currentObj = go;
skillType = type;
isSkill =
true
;
isCooling =
true
;
HandlerCoolingTimer(type);
Debug.Log(
"可以释放该技能了"
);
}
else
{
Debug.Log(
"不可释放技能"
);
}
}
private
void
HandlerCoolingTimer(SKILLTYPE type)
{
coolingTime = (
float
)type;
currentObj.transform.FindChild(
"Fore"
).gameObject.GetComponent<UISprite>().fillAmount = 1;
GameController.getInstance().addInterval(TimerCutting);
Debug.Log(
"开始倒计时"
);
}
private
void
TimerCutting(
float
t)
{
currentObj.transform.FindChild(
"Fore"
).gameObject.GetComponent<UISprite>().fillAmount -= (1.0f / coolingTime) * Time.deltaTime;
float
tempTime = currentObj.transform.FindChild(
"Fore"
).gameObject.GetComponent<UISprite>().fillAmount;
Debug.Log(
"------------coolingTime : "
+ tempTime);
if
(tempTime <= 0.01f)
{
isSkill =
false
;
isCooling =
false
;
GameController.getInstance().removedInterval(TimerCutting);
}
}
}
}</font>