教程中关于comboIndex归零的处理太麻烦,而且会丢失一次点击响应,我的代码很简单:
public void ReleaseNormalAtk()
{
if(entitySelfPlayer.currentAniState==AniState.Attack)
{
//在500ms内进行第二次点击,存数据
double nowAtkTime = TimerSvc.Instance.GetNowTime();
if(nowAtkTime-lastAtkTime<Constants.ComboSpace&&lastAtkTime!=0)
{
//索引自动归零
comboIndex =(comboIndex+1)%comboArr.Length;
entitySelfPlayer.comboQue.Enqueue(comboArr[comboIndex]);
lastAtkTime = nowAtkTime;
}
}
else if(entitySelfPlayer.currentAniState==AniState.Idle||entitySelfPlayer.currentAniState==AniState.Move)
{
lastAtkTime = TimerSvc.Instance.GetNowTime();
entitySelfPlayer.Attack(comboArr[0]);
}
PECommon.Log("Click Normal Attack");
}