コード例 #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("enemy_attack") && scriptVida.vivo == true)
     {
         AudioSource.PlayClipAtPoint(soundEnemy1, transform.position);
         AudioSource.PlayClipAtPoint(soundDano, transform.position);
         scriptVida.alterarVida(5);
     }
     if (other.gameObject.CompareTag("enemy_attack_skeleton") && scriptVida.vivo == true)
     {
         AudioSource.PlayClipAtPoint(soundEnemy2, transform.position);
         AudioSource.PlayClipAtPoint(soundDano, transform.position);
         scriptVida.alterarVida(10);
     }
     if (other.gameObject.CompareTag("enemy_attack_hellhound") && scriptVida.vivo == true)
     {
         AudioSource.PlayClipAtPoint(soundEnemy3, transform.position);
         AudioSource.PlayClipAtPoint(soundDano, transform.position);
         scriptVida.alterarVida(8);
     }
     if (other.gameObject.CompareTag("enemy_attack_boss") && scriptVida.vivo == true)
     {
         AudioSource.PlayClipAtPoint(soundEnemy3, transform.position);
         AudioSource.PlayClipAtPoint(soundDano, transform.position);
         scriptVida.alterarVida(15);
     }
     if (other.gameObject.CompareTag("life"))
     {
         scriptVida.alterarVida(-100);
     }
     if (other.gameObject.CompareTag("queda"))
     {
         scriptVida.alterarVida(100);
         this.GetComponent <CapsuleCollider2D>().enabled = false;
         this.GetComponent <SpriteRenderer>().color      = new Color(1, 0, 0, .5f);
         if (i == 0)
         {
             rb2d.AddForce(new Vector2(0f, 1900f));
             AudioSource.PlayClipAtPoint(soundQueda, transform.position);
             StartCoroutine(WaitAndAnimate(1.5f));
             i++;
         }
     }
 }