public void TakeDamage(int damage) { health -= damage; if (health <= 0) { scr_ui u = GameObject.FindGameObjectWithTag("ui").GetComponent <scr_ui>(); if (u != null) { u.ChangeScore(1); } Die(); } }
/*PlaySound(throwSound); * } * public void PlaySound(AudioClip clip) * { * audioSource.PlayOneShot(clip); * }*/ public void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "Key") { key += 1; Destroy(collision.collider.gameObject); //Debug.Log ("number of keys on hand " + key); } if (collision.collider.tag == "Chest") { Destroy(collision.collider.gameObject); scr_ui u = GameObject.FindGameObjectWithTag("ui").GetComponent <scr_ui>(); if (u != null) { u.ChangeScore(100); } //PlaySound(chestPickup); } if (collision.collider.tag == "Exit") { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); level++; } }