コード例 #1
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Zucchini")
     {
         StartCoroutine(ShowHitRed(colorChangeSecondsWait));
         health  -= damage.GetZucchiniDamage();
         hitSound = FindObjectOfType <HitSound>();
         hitSound.GetComponent <AudioSource>().Play();
         Destroy(col.transform.parent.gameObject);
     }
     else if (col.tag == "Axe")
     {
         StartCoroutine(ShowHitRed(colorChangeSecondsWait));
         health  -= damage.GetAxeDamage();
         hitSound = FindObjectOfType <HitSound>();
         hitSound.GetComponent <AudioSource>().Play();
         Destroy(col.transform.parent.gameObject);
     }
     else if (col.tag == "Ball")
     {
         StartCoroutine(ShowHitRed(colorChangeSecondsWait));
         health  -= damage.GetBallDamage();
         hitSound = FindObjectOfType <HitSound>();
         hitSound.GetComponent <AudioSource>().Play();
         Destroy(col.transform.parent.gameObject);
     }
     if (health <= 0)
     {
         TriggerDeathVFX();
         Destroy(gameObject);
     }
 }