Пример #1
0
 /// <summary>
 /// 战斗输入事件
 /// </summary>
 /// <param name="action"></param>
 private void CombatInputEvent(INPUTACTION action)
 {
     animator.ResetTrigger();
     //if(lastAttack!=null)
     //{
     //    if(Time.time < (lastAttackTime + lastAttack.duration))
     //        return;
     //}
     if (action == INPUTACTION.SKILL1 && isGrounded)
     {
         DoAttack(skill1Data, UNITSTATE.SKILL1, INPUTACTION.SKILL1);
     }
     if (action == INPUTACTION.SKILL2 && isGrounded)
     {
         DoAttack(skill2Data, UNITSTATE.SKILL2, INPUTACTION.SKILL2);
     }
     if (action == INPUTACTION.CHARGE_START && isGrounded)
     {
         DoAttack(chargeStartData, UNITSTATE.CHARGE_START, INPUTACTION.CHARGE_START, false);
     }
     if (action == INPUTACTION.CHARGE_RELEASE && isGrounded)
     {
         DoAttack(chargeReleaseData, UNITSTATE.CHARGE_RELEASE, INPUTACTION.CHARGE_RELEASE);
     }
     //普攻
     if (action == INPUTACTION.GENERALATTACK && playerState.currentState != UNITSTATE.GENERALATTACK && isGrounded)
     {
         //continue to the next attack if the time is inside the combo window   最后一次攻击时间,最后一次攻击的持续时间,最后一次攻击连击的重置时间
         bool insideComboWindow = (lastAttack != null && Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime));
         if (insideComboWindow && !continueGeneralAttackCombo && attackNum < generalAttackCombo.Length - 1)
         {
             attackNum += 1;
         }
         else
         {
             attackNum = 0;
         }
         if (generalAttackCombo[attackNum] != null && generalAttackCombo[attackNum].animTrigger.Length > 0)
         {
             DoAttack(generalAttackCombo[attackNum], UNITSTATE.GENERALATTACK, INPUTACTION.GENERALATTACK);
         }
         return;
     }
     //如果在一次普攻动作进行中又按下了普攻键,则进行普攻连击
     if (action == INPUTACTION.GENERALATTACK && (playerState.currentState == UNITSTATE.GENERALATTACK) && Time.time > (lastAttackTime + lastAttack.duration - 0.1f) && !continueGeneralAttackCombo && isGrounded)
     {
         if (attackNum < generalAttackCombo.Length - 1)
         {
             continueGeneralAttackCombo = true;
             return;
         }
     }
 }