private void OnTriggerEnter2D(Collider2D target) { if (target.tag == "LargestBall" || target.tag == "LargeBall" || target.tag == "MediumBall" || target.tag == "SmallBall" || target.tag == "SmallestBall") { if (gameObject.tag == "FirstArrow" || gameObject.tag == "FirstStickyArrow") { PlayerScript.instance.PlayerShootOnce(true); } else if (gameObject.tag == "SecondArrow" || gameObject.tag == "SecondStickyArrow") { PlayerScript.instance.PlayerShootTwice(true); } gameObject.SetActive(false); } if (target.tag == "TopBrick" || target.tag == "UnbreakableBrickTop" || target.tag == "UnbreakableBrickBottom" || target.tag == "UnbreakableBrickLeft" || target.tag == "UnbreakableBrickRight" || target.tag == "UnbreakableBrickBottomVertical") { if (this.gameObject.tag == "FirstArrow") { PlayerScript.instance.PlayerShootOnce(true); this.gameObject.SetActive(false); } else if (this.gameObject.tag == "SecondArrow") { PlayerScript.instance.PlayerShootTwice(true); this.gameObject.SetActive(false); } if (this.gameObject.tag == "FirstStickyArrow") { SetTheStickyArrowPosition(this.gameObject); } else if (this.gameObject.tag == "SecondStickyArrow") { SetTheStickyArrowPosition(this.gameObject); } } if (target.tag == "BrokenBrickTop" || target.tag == "BrokenBrickBottom" || target.tag == "BrokenBrickLeft" || target.tag == "BrokenBrickRight") { BrickScript brick = target.gameObject.GetComponentInParent <BrickScript>(); brick.StartCoroutine(brick.BreakTheBrick()); if (gameObject.tag == "FirstArrow" || gameObject.tag == "FirstStickyArrow") { PlayerScript.instance.PlayerShootOnce(true); } else if (gameObject.tag == "SecondArrow" || gameObject.tag == "SecondStickyArrow") { PlayerScript.instance.PlayerShootTwice(true); } gameObject.SetActive(false); } }
void OnTriggerEnter2D (Collider2D target) { if (target.tag == "LargestBall" || target.tag == "LargeBall" || target.tag == "MediumBall" || target.tag == "SmallBall" || target.tag == "SmallestBall") { if (gameObject.tag == "FirstArrow" || gameObject.tag == "FirstStickyArrow") { PlayerScript.instance.PlayerShootOnce (true); } else if (gameObject.tag == "SecondArrow" || gameObject.tag == "SecondStickyArrow") { PlayerScript.instance.PlayerShootTwice (true); } gameObject.SetActive (false); } // If the arrow hits a ball if (target.tag == "TopBrick" || target.tag == "UnbreakableBrickTop" || target.tag == "UnbreakableBrickBottom" || target.tag == "UnbreakableBrickLeft" || target.tag == "UnbreakableBrickRight" || target.tag == "UnbreakableBrickBottomVertical") { if (this.gameObject.tag == "FirstArrow") { PlayerScript.instance.PlayerShootOnce (true); this.gameObject.SetActive (false); } else if (this.gameObject.tag == "SecondArrow") { PlayerScript.instance.PlayerShootTwice (true); this.gameObject.SetActive (false); } if (this.gameObject.tag == "FirstStickyArrow") { canShootStickyArrow = false; Vector3 targetPos = target.transform.position; Vector3 temp = transform.position; if (target.tag == "TopBrick") { targetPos.y -= 0.989f; } else if (target.tag == "UnbreakableBrickTop" || target.tag == "UnbreakableBrickBottom" || target.tag == "UnbreakableBrickLeft" || target.tag == "UnbreakableBrickRight") { targetPos.y -= 0.75f; } else if (target.tag == "UnbreakableBrickBottomVertical") { targetPos.y -= 0.97f; } temp.y = targetPos.y; transform.position = temp; AudioSource.PlayClipAtPoint (clip, transform.position); StartCoroutine ("ResetStickyArrow"); } else if (this.gameObject.tag == "SecondStickyArrow") { canShootStickyArrow = false; Vector3 targetPos = target.transform.position; Vector3 temp = transform.position; if (target.tag == "TopBrick") { targetPos.y -= 0.989f; } else if (target.tag == "UnbreakableBrickTop" || target.tag == "UnbreakableBrickBottom" || target.tag == "UnbreakableBrickLeft" || target.tag == "UnbreakableBrickRight") { targetPos.y -= 0.75f; } else if (target.tag == "UnbreakableBrickBottomVertical") { targetPos.y -= 0.97f; } temp.y = targetPos.y; transform.position = temp; AudioSource.PlayClipAtPoint (clip, transform.position); StartCoroutine ("ResetStickyArrow"); } } // If the arrow hits the top brick or an unbreakable brick if (target.tag == "BrokenBrickTop" || target.tag == "BrokenBrickBottom" || target.tag == "BrokenBrickLeft" || target.tag == "BrokenBrickRight") { BrickScript brick = target.gameObject.GetComponentInParent<BrickScript> (); brick.StartCoroutine (brick.BreakTheBrick ()); if (gameObject.tag == "FirstArrow" || gameObject.tag == "FirstStickyArrow") { PlayerScript.instance.PlayerShootOnce (true); } else if (gameObject.tag == "SecondArrow" || gameObject.tag == "SecondStickyArrow") { PlayerScript.instance.PlayerShootTwice (true); } gameObject.SetActive (false); } // If the arrow hits a broken brick } // OnTriggerEnter2D