IEnumerator ExplodeBalls (bool touchedGoldBall) { if (this.gameObject.tag == "LargestBall") { yield return null; } else { yield return StartCoroutine (MyCoroutine.WaitForRealSeconds (0.5f)); } if (gameObject.tag != "SmallestBall") { Vector3 position = transform.position; ball1.transform.position = position; ball1Script.SetMoveLeft (true); ball2.transform.position = position; ball2Script.SetMoveRight (true); ball1.SetActive (true); ball2.SetActive (true); if (transform.position.y > 1 && transform.position.y <= 1.3f) { ball1.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 3.5f); ball2.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 3.5f); } else if (transform.position.y > 1.3f) { ball1.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 2f); ball2.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 2f); } else if (transform.position.y < 1) { ball1.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 5.5f); ball2.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 5.5f); } } if (touchedGoldBall) { if (this.gameObject.tag != "SmallestBall") { ball1Script.Explode (true); ball2Script.Explode (true); } else { GameplayController.instance.CountSmallBalls (); } this.gameObject.SetActive (false); } else { if (this.gameObject.tag != "SmallestBall") { ball1Script.Explode (false); ball2Script.Explode (false); this.gameObject.SetActive (false); } } }