Exemple #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name.StartsWith("Bomb"))
     {
         BombOmb bombOmb = other.gameObject.GetComponent <BombOmb>();
         if (bombOmb.isHit && !isInvunrable)
         {
             clockTimer.ResetTimer();
             wasHit = true;
             FindObjectOfType <AudioManager>().Play("Explosion");
             FindObjectOfType <AudioManager>().Play("BowserHit");
             isInvunrable = true;
             health--;
             Instantiate(smokePrefab, other.transform.position, Quaternion.identity);
             if (health <= 0)
             {
                 Death();
                 originPosition = transform.position;
             }
             else if (health == 1)
             {
                 hasOneHealth = true;
                 animator.SetBool("IsHit", true);
                 koopaClownCarAnimator.SetBool("IsHit", true);
                 StartCoroutine(ResetInvunrability());
             }
             else
             {
                 hasAttackedOnce = false;
                 animator.SetBool("IsHit", true);
                 koopaClownCarAnimator.SetBool("IsHit", true);
                 StartCoroutine(ResetInvunrability());
             }
             Destroy(other.gameObject);
         }
     }
 }