Exemplo n.º 1
0
 private void Update()
 {
     if (ctrl.attackHorizontal != 0 && ctrl.attackHorizontal != _oldHorizInput || // If we have new horizontal input
         ctrl.attackVertical != 0 && ctrl.attackVertical != _oldVertInput)        // or new vertical input
     {
         if (primaryAttack.state == AttackState.Ended)
         {
             primaryAttack.InitAttack();
             _attackStart = Time.time;
         }
         else if (_oldVertInput == 0 && _oldHorizInput == 0 || Time.time - _attackStart > TapThreshold * 2)
         {
             // but if we were already attacking and this is an entirely new attack input, or enough time has passed
             // that we know this isn't just them trying to do a diagonal, then start a buffer attack
             if (bufferAttack.initAttack != null)
             {
                 StopCoroutine(bufferAttack.initAttack);                                 // else might never stop
             }
             bufferAttack.InitAttack(true);
             _bufferAttackStart = Time.time;
         }
     }
     _oldHorizInput = ctrl.attackHorizontal;
     _oldVertInput  = ctrl.attackVertical;
 }