Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name == "Player")
     {
         theScoreManager.AddCoin(scoreToGive);
         gameObject.SetActive(false);
     }
 }
Exemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         Score.AddCoin();
         Destroy(gameObject);
     }
 }