Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D trig)
    {
        if (trig.tag == "largestBall" || trig.tag == "largeBall" || trig.tag == "mediumBall" || trig.tag == "smallBall" || trig.tag == "smallestBall")
        {
            DeactivateArrow();
        }

        /*
         * if (trig.tag == "topBrick") {
         *      if (this.gameObject.tag == "firstArrow") {
         *              PlayerController.instance.ShootOnce (true);
         *              this.gameObject.SetActive (false);
         *      } else if (this.gameObject.tag == "secondArrow") {
         *              PlayerController.instance.ShootTwice (true);
         *              this.gameObject.SetActive (false);
         *      } else if (this.gameObject.tag == "firstStickyArrow") {
         *              canShootStickyArrow = false;
         *              Vector3 targetPos = trig.transform.position;
         *              Vector3 temp = transform.position;
         *              targetPos.y -= 0.99f;
         *              temp.y = targetPos.y;
         *              transform.position = temp;
         *              AudioSource.PlayClipAtPoint (clip, transform.position);
         *              StartCoroutine ("ResetStickyArrow");
         *      } else if (this.gameObject.tag == "secondStickyArrow") {
         *              canShootStickyArrow = false;
         *              Vector3 targetPos = trig.transform.position;
         *              Vector3 temp = transform.position;
         *              targetPos.y -= 0.99f;
         *              temp.y = targetPos.y;
         *              transform.position = temp;
         *              AudioSource.PlayClipAtPoint (clip, transform.position);
         *              StartCoroutine ("ResetStickyArrow");
         *      }
         * }
         */
        if (
            trig.tag == "topBrick" || trig.tag == "unbreakableBrickTop" ||
            trig.tag == "unbreakableBrickBottom" || trig.tag == "unbreakableBrickLeft" ||
            trig.tag == "unbreakableBrickRight" || trig.tag == "unbreakableBrickBottomVertical"
            )
        {
            if (this.gameObject.tag == "firstArrow")
            {
                PlayerController.instance.ShootOnce(true);
                this.gameObject.SetActive(false);
            }
            else if (this.gameObject.tag == "secondArrow")
            {
                PlayerController.instance.ShootTwice(true);
                this.gameObject.SetActive(false);
            }
            else if (this.gameObject.tag == "firstStickyArrow")
            {
                canShootStickyArrow = false;
                Vector3 targetPos = trig.transform.position;
                Vector3 temp      = transform.position;

                if (trig.tag == "topBrick")
                {
                    targetPos.y -= 0.99f;
                }
                else if (
                    trig.tag == "unbreakableBrickTop" ||
                    trig.tag == "unbreakableBrickBottom" ||
                    trig.tag == "unbreakableBrickLeft" ||
                    trig.tag == "unbreakableBrickRight"
                    )
                {
                    targetPos.y -= 0.9f;
                }
                else if (trig.tag == "unbreakableBrickBottomVertical")
                {
                    targetPos.y -= 1.65f;
                }
                temp.y             = targetPos.y;
                transform.position = temp;
                AudioSource.PlayClipAtPoint(clip, transform.position);
                StartCoroutine("ResetStickyArrow");
            }
            else if (this.gameObject.tag == "secondStickyArrow")
            {
                canShootStickyArrow = false;
                Vector3 targetPos = trig.transform.position;
                Vector3 temp      = transform.position;

                if (trig.tag == "topBrick")
                {
                    targetPos.y -= 0.99f;
                }
                else if (
                    trig.tag == "unbreakableBrickTop" ||
                    trig.tag == "unbreakableBrickBottom" ||
                    trig.tag == "unbreakableBrickLeft" ||
                    trig.tag == "unbreakableBrickRight"
                    )
                {
                    targetPos.y -= 0.9f;
                }
                else if (trig.tag == "unbreakableBrickBottomVertical")
                {
                    targetPos.y -= 1.65f;
                }
                temp.y             = targetPos.y;
                transform.position = temp;
                AudioSource.PlayClipAtPoint(clip, transform.position);
                StartCoroutine("ResetStickyArrow");
            }
        }
        if (
            trig.tag == "brokenBrickTop" ||
            trig.tag == "brokenBrickBottom" ||
            trig.tag == "brokenBrickLeft" ||
            trig.tag == "brokenBrickRight"
            )
        {
            BrickController brick = trig.gameObject.GetComponentInParent <BrickController> ();
            brick.StartCoroutine(brick.BreakBrick());

            if (gameObject.tag == "firstArrow" || gameObject.tag == "firstStickyArrow")
            {
                PlayerController.instance.ShootOnce(true);
            }
            else if (gameObject.tag == "secondArrow" || gameObject.tag == "secondStickyArrow")
            {
                PlayerController.instance.ShootTwice(true);
            }

            gameObject.SetActive(false);
        }
    }