void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "PlayerAttack")
     {
         WasAttackedByPlayer();
     }
     else if (other.gameObject.tag == "Player")
     {
         audioManager.playMissPunchMusic();
     }
 }
Пример #2
0
    // Handler attack
    void manageAttack()
    {
        if (attacking)
        {
            next_attack_time = Mathf.Max(0, next_attack_time - Time.deltaTime);
            trigger_time     = Mathf.Max(0, trigger_time - Time.deltaTime);

            if (trigger_time == 0)
            {
                attack_vector [dir].enabled = true;
            }

            if (next_attack_time == 0)
            {
                attacking = false;
                anim.SetBool("Attack", false);

                foreach (BoxCollider2D bc in attack_vector)
                {
                    bc.enabled = false;
                }
                attacking = false;
            }
        }
        else
        {
            updateDir();
            anim.SetInteger("Dir", dir);

            if (Input.GetKeyDown(KeyCode.Space))
            {
                attacking = true;
                anim.SetBool("Attack", true);

                //audio
                audioManager.playMissPunchMusic();

                next_attack_time = attack_cooldown;
                trigger_time     = trigger_delay;
            }
        }
    }