void OnCollisionEnter2D(Collision2D c) { if (c.gameObject.CompareTag("1up")) { if (!isDead) { lives++; PlayerPrefs.SetInt("247127CurrentPlayerLives", lives); livesScript.playSound(transform.position); livesScript.UpdateLives(1); Destroy(c.gameObject); } } }
void OnCollisionEnter2D(Collision2D c) { if (c.gameObject.CompareTag("1up")) { if (!isDead) { lives++; PlayerPrefs.SetInt("247127CurrentPlayerLives", lives); livesScript.playSound(transform.position); livesScript.UpdateLives(1); Destroy(c.gameObject); } } if (c.gameObject.CompareTag("Coin")) { if (!isDead) { CoinScript CoinScript = c.gameObject.GetComponent <CoinScript> (); int value = CoinScript.value; CoinScript.PlaySound(); changeScore(value); Destroy(c.gameObject); } } if (c.gameObject.CompareTag("Heart")) { if (!isDead) { HeartScript hScript = c.gameObject.GetComponent <HeartScript> (); int value = hScript.value; if (health + value < 4) { healthScript.IncreaseHealth(value); health += value; PlayerPrefs.SetInt("247127CurrentPlayerHealth", health); } hScript.PlaySound(); Destroy(c.gameObject); } } }