void OnTriggerEnter2D(Collider2D collisionObject) { if (collisionObject.gameObject.tag == "Coin") { GetComponent<AudioSource>().pitch = Random.Range(0.95f, 1.05f); GetComponent<AudioSource>().PlayOneShot(coinSound, 0.25f); scoreMan.AddCoin(); Destroy(collisionObject.transform.parent.gameObject); } if (collisionObject.gameObject.tag == "Health") { //GetComponent<AudioSource>().pitch = Random.Range(0.95f, 1.05f); //GetComponent<AudioSource>().PlayOneShot(coinSound, 0.25f); if (curHealth != maxHealth) { curHealth++; Destroy(collisionObject.transform.parent.gameObject); } } if (collisionObject.gameObject.tag == "Gem") { GetComponent<AudioSource>().pitch = Random.Range(0.95f, 1.05f); GetComponent<AudioSource>().PlayOneShot(coinSound, 0.25f); playerLvl.AddEXP(5.0f); Destroy(collisionObject.gameObject); } if (collisionObject.gameObject.tag == "Enemy") { print("HurtPlayer"); curHealth--; GetComponent<AudioSource>().pitch = Random.Range(0.9f, 1.1f); GetComponent<AudioSource>().PlayOneShot(hurtSound, 0.25f); shake.DoShake(); StartCoroutine(HurtPlayer(0.2f)); } if (collisionObject.gameObject.tag == "EnemyArrow") { print("HurtPlayer"); curHealth--; GetComponent<AudioSource>().pitch = Random.Range(0.9f, 1.1f); GetComponent<AudioSource>().PlayOneShot(hurtSound, 0.25f); shake.DoShake(); StartCoroutine(HurtPlayer(0.2f)); } if (collisionObject.gameObject.tag == "Hurt") { GetComponent<AudioSource>().pitch = Random.Range(0.9f, 1.1f); GetComponent<AudioSource>().PlayOneShot(hurtSound, 0.25f); print("HurtPlayer"); curHealth--; shake.DoShake(); StartCoroutine(HurtPlayer(0.2f)); } if (collisionObject.gameObject.tag == "Gear") { print("KillPlayer"); ReloadLevel(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Player") { theScoreManager.AddCoin(scoreToGive); gameObject.SetActive(false); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { Score.AddCoin(); Destroy(gameObject); } }