Example #1
0
 void OnTriggerEnter2D(Collider2D playerCollider)
 {
     if (playerCollider.gameObject.tag == "Player")
     {
         if (healthItem.gameObject.tag == "Health Pack")
         {
             Debug.Log("touched health");
             player       = GameObject.FindGameObjectWithTag("Player");
             playerHealth = player.GetComponent <PlayerHealth>();
             playerHealth.HealPlayer();
             FindObjectOfType <AudioManager>().Play("Heal");
             Destroy(healthItem);
             Score.scoreValue += 525;
         }
         else if (healthItem.gameObject.tag == "Oxygen Bubble")
         {
             Debug.Log("oxy bubble");
             player       = GameObject.FindGameObjectWithTag("Player");
             playerHealth = player.GetComponent <PlayerHealth>();
             playerHealth.Breathe();
             FindObjectOfType <AudioManager>().Play("Bubbles");
             Destroy(healthItem);
             Score.scoreValue += 350;
         }
         else
         {
             Debug.Log("unknown item");
         }
     }
 }