// Update is called once per frame
    void Update()
    {
        if (!instantiateChildStars)
        {
            transform.Translate((targetX - transform.position.x) * .1f, (targetY - transform.position.y) * .1f, 0, Space.World);
        }
        if (!instantiateChildStars && Mathf.Abs(targetX - transform.position.x) < .05f && Mathf.Abs(targetY - transform.position.y) < .05f)
        {
            instantiateChildStars = true;
            timeStamp             = Time.time;
            moveRight             = true;
        }

        if (instantiateChildStars && childStarCount < 12)
        {
            childStarCount++;
            if (!tutorialLevel && powerPercentageController.IsWithinPercentage() && !bombInstantiated)
            {
                bombInstantiated = true;
                InstantiateBombSeekingChildStars();
            }
            else
            {
                InstantiateChildStars();
            }
            timeStamp = Time.time;
            if (childStarCount == 12)
            {
                cooldown    = .4f;
                timeStamp   = Time.time;
                startDecent = true;
            }
        }

        if (startDecent && Time.time > timeStamp + cooldown)
        {
            foreach (GameObject a in childStarArray)
            {
                childStarMovement = a.GetComponent <RockLevelChildStarMovement> ();
                childStarMovement.StartDecent();
            }
            soundHandler.PlayPowerShot();
            fiveInARow.GetMotherStarList().Remove(gameObject);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
    private void CheckTouch(Vector3 pos)
    {
        Vector3 wp       = Camera.main.ScreenToWorldPoint(pos);
        Vector2 touchPos = new Vector2(wp.x, wp.y);

        hit = Physics2D.OverlapPoint(touchPos);

        if (swapCooldown)
        {
            return;
        }

        if (/*!swapJewels.GetPauseTouchForSwap () &&*/ hit != null && !PowerStarTracker.ContainsJewel(hit.gameObject) /*&& !checkForMatches.JewelOkayToMove (hit.gameObject)*/ && HasCorrectTags(hit.gameObject) && hit.gameObject.name != "Slug Meal" && fiveInARow.GetMotherStarList().Count == 0 && corners.GetCornerStarGreaterThan10() && fiveInARow.GetChildStarList().Count == 0 && fourInARow.GetHomingStarList().Count == 0 && firstPressed == null /*&& deleteJewels.OkayToMoveAgain ()*/)
        {
            jewelMovement = hit.gameObject.GetComponent <RockLevelJewelMovement> ();
            if (!jewelMovement.GetToBeDestroyed() && !jewelMovement.GetMoving() && jewelMovement.GetOnPlatform() && !checkForMatches.deleteList.Contains(hit.gameObject))
            {
                if (tutorialLevel2 && hit.gameObject.name != "Level Two Tutorial Jewel")
                {
                    return;
                }
                firstPressed = hit.gameObject;
            }
        }
        else if (/*!swapJewels.GetPauseTouchForSwap () &&*/ hit != null && !PowerStarTracker.ContainsJewel(hit.gameObject) /*&& !checkForMatches.JewelOkayToMove (hit.gameObject) */ && HasCorrectTags(hit.gameObject) && hit.gameObject.name != "Slug Meal" /*&& deleteJewels.OkayToMoveAgain () */ && corners.GetCornerStarGreaterThan10() && fiveInARow.GetMotherStarList().Count == 0 && fiveInARow.GetChildStarList().Count == 0 && firstPressed != null && secondPressed == null && hit.gameObject != firstPressed && fourInARow.GetHomingStarList().Count == 0 &&
                 //((jewelMovement.GetRow () == hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetRow () && Mathf.Abs (jewelMovement.GetCol () - hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetCol ()) == 1) ||
                 //(jewelMovement.GetCol () == hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetCol () && Mathf.Abs (jewelMovement.GetRow () - hit.gameObject.GetComponent<RockLevelJewelMovement> ().GetRow ()) == 1)))
                 Mathf.Abs(hit.gameObject.transform.position.x - firstPressed.transform.position.x) < .66 &&
                 Mathf.Abs(hit.gameObject.transform.position.y - firstPressed.transform.position.y) < .66 && (Mathf.Abs(hit.gameObject.transform.position.x - firstPressed.transform.position.x) < .1 || Mathf.Abs(hit.gameObject.transform.position.y - firstPressed.transform.position.y) < .1))
        {
            //{

            jewelMovement = hit.gameObject.GetComponent <RockLevelJewelMovement> ();
            if (!jewelMovement.GetToBeDestroyed() && !jewelMovement.GetMoving() && jewelMovement.GetOnPlatform() && !checkForMatches.deleteList.Contains(hit.gameObject))
            {
                if (tutorialLevel2 && hit.gameObject.name != "Level Two Tutorial Jewel")
                {
                    return;
                }
                secondPressed = hit.gameObject;
                swapCooldown  = true;
                timeStamp     = Time.time;
                swapJewels.Swap(firstPressed, secondPressed, false);
            }
        }
    }