private void OnCollisionEnter2D(Collision2D collision) { // if balls enter this collison if it isn't last ball destroy it. // if it is last ball look health if player has health change ball position to start point. // if hasn't health finish game write point to the screen if (collision.gameObject.CompareTag("ball")) { GameObject[] balls; balls = GameObject.FindGameObjectsWithTag("ball"); if (balls.Length == 1) { if (health > 1) { health = health - 1; play.CreateBall(); image2.SetActive(false); sS.PlaySound(0); Game.instance.StopSpeedChange(); } else if (health <= 1) { Time.timeScale = 0; sS.PlaySound(0); health -= 1; cont_ads_button.enabled = true; Game.instance.StopSpeedChange(); cont_ads_button.GetComponentInChildren <Text>().text = Lang.instance.text[14].text; if (PlayerPrefs.GetInt("GameOverCount", 0) == 3) { GP_AdManager.instance.Display_InsterstitialAD(); PlayerPrefs.SetInt("GameOverCount", 0); } else { PlayerPrefs.SetInt("GameOverCount", PlayerPrefs.GetInt("GameOverCount", 0) + 1); } gameOver.SetActive(true); } } else { Destroy(collision.gameObject); } } }