Beispiel #1
0
    void GroundFight()
    {
        if (input.attackPressed && isOnGround)
        {
            attackTime = Time.time + attackDuration;
            if (attackTime > Time.time)
            {
                isAttacking = true;
            }
            if (trippleAttack.Check())
            {
                animator.Play(animAttack3);
            }
            else if (doubleAttack.Check())
            {
                animator.Play(animAttack2);
            }
            else if (attack.Check())
            {
                animator.Play(animAttack1);
            }
        }
        else if (input.shootPressed && isOnGround)
        {
            attackTime = Time.time + attackDuration;
            if (attackTime > Time.time)
            {
                isAttacking = true;
            }
            if (shoot.Check())
            {
                animator.Play(animShoot);
            }
        }
        // No attacking, no shooting - isAttacking = false
        else if ((!input.attackPressed && attackTime < Time.time) || (!input.shootPressed && attackTime < Time.time))
        {
            isAttacking = false;
        }

        if (isAttacking)
        {
            xVelocity /= crouchSpeedDivisor;
        }
        animator.SetBool("isAttacking", isAttacking);
    }
Beispiel #2
0
 void AirFight()
 {
     if (input.attackPressed && !isOnGround)
     {
         attackTime = Time.time + attackDuration / 2;
         if (attackTime > Time.time)
         {
             isAttacking = true;
         }
         if (trippleAirAttack.Check())
         {
             input.attackButton.enabled = false;
             input.shootButton.enabled  = false;
             animator.Play(animAirAttack3);
             rigidBody.AddForce(new Vector2(0f, -jumpForce), ForceMode2D.Impulse);
         }
         else if (doubleAirAttack.Check())
         {
             animator.Play(animAirAttack2);
         }
         else if (airAttack.Check())
         {
             animator.Play(animAirAttack1);
         }
     }
     else if (input.shootPressed && !isOnGround)
     {
         attackTime = Time.time + attackDuration;
         if (attackTime > Time.time)
         {
             isAttacking = true;
         }
         if (airShoot.Check())
         {
             animator.Play(animAirShoot);
         }
     }
     // No attacking, no shooting - isAttacking = false
     else if ((!input.attackPressed && attackTime < Time.time) || (!input.shootPressed && attackTime < Time.time))
     {
         isAttacking = false;
     }
 }