Example #1
0
    void Start()
    {
        GameObject SceneManager = GameObject.Find("_SceneManager");

        ChangeScene      = SceneManager.GetComponent <ChangeScene>();
        CustomizeStorage = SceneManager.GetComponent <CustomizeStorage>();
        AlertScript      = SceneManager.GetComponent <AlertScript>();

        // set bar
        int   expCap      = PlayerPrefs.GetInt("level") * 85;
        float capBarValue = 1f / expCap * PlayerPrefs.GetInt("exp");

        BarValue.fillAmount = capBarValue;

        // set stats
        bonusText.text  = "Bonus: " + PlayerPrefs.GetInt("bonus") * 5 + "%";
        packText.text   = "Packs opened: " + PlayerPrefs.GetInt("packs");
        easyText.text   = "Easy solved: " + PlayerPrefs.GetInt("easy");
        normalText.text = "Normal solved: " + PlayerPrefs.GetInt("normal");
        hardText.text   = "Hard solved: " + PlayerPrefs.GetInt("hard");

        // if premium?
        if (PlayerPrefs.GetInt("highscore") == 763)
        {
            Destroy(blocker);
            Destroy(BuyPremiumButton);
            PremiumAds.sprite = upgradedImage;
        }
    }
    void Start()
    {
        // get ChangeScene and CustomizeStorage
        GameObject SceneManager = GameObject.Find("_SceneManager");

        ChangeScene      = SceneManager.GetComponent <ChangeScene>();
        CustomizeStorage = SceneManager.GetComponent <CustomizeStorage>();
        AlertScript      = SceneManager.GetComponent <AlertScript>();

        // set up owned
        owned = PlayerPrefs.GetString("owned").ToCharArray();

        // set up buy button
        packCost          = (PlayerPrefs.GetInt("packs") * 50) + 200;
        packCostText.text = packCost + "";

        // create arrow buttons
        GameObject       clone;
        Image            ImageComponent;
        SkinButtonScript sbs;

        for (int i = 0; i < CustomizeStorage.arrowImage.Length; i++)
        {
            clone                 = Instantiate(SkinButton);
            ImageComponent        = clone.GetComponent <Image>();
            sbs                   = clone.GetComponent <SkinButtonScript>();
            ImageComponent.sprite = CustomizeStorage.arrowImage[i];  // change sprite image
            clone.transform.SetParent(SkinButtonsParent.transform);  // set parent

            sbs.sms      = this;
            sbs.idNumber = i; // give ID


            // change color
            if (i < 48 && owned[i].Equals('1')) // owned?
            {
                ImageComponent.color = CustomizeStorage.arrowColors[i];
            }
            else if (i == 48 && allOwned()) // qMark check
            {
                ImageComponent.color = CustomizeStorage.arrowColors[i];
            }
            else
            {
                ImageComponent.color = new Color(0, 0, 0);
            }
        }

        // set image select shower
        Image img = ImageSelect.GetComponent <Image>();

        img.sprite = CustomizeStorage.arrowImage[CustomizeStorage.selectedArrow];
        img.color  = CustomizeStorage.arrowColors[CustomizeStorage.selectedArrow];
    }
    private void Start()
    {
        cs = GameObject.Find("_SceneManager").GetComponent <CustomizeStorage>();

        // payment
        int packCost = (PlayerPrefs.GetInt("packs") * 50) + 200;

        PlayerPrefs.SetInt("stars", PlayerPrefs.GetInt("stars") - packCost);
        PlayerPrefs.SetInt("packs", PlayerPrefs.GetInt("packs") + 1);

        for (int i = 0; i < 3; i++)
        {
            openOneCard(i);
        }
    }
    // GENERATE puzzle and set up arrows
    void Start()
    {
        CustomizeStorage CustomizeStorage = GameObject.Find("_SceneManager").GetComponent <CustomizeStorage>();

        ChangeScene = GameObject.Find("_SceneManager").GetComponent <ChangeScene>();
        string thisSceneName = SceneManager.GetActiveScene().name;

        if (!thisSceneName.Equals("Tutorial"))
        {
            ChangeScene.tutorialIndex = 0;
        }

        bSize = ChangeScene.bSize;  // get bSize
        for (int i = 0; i < 8; i++)
        {
            degrees[i] = i * 45;
        }                                                       // set up degree values

        // if tutorial ?
        int tutorialIndex = ChangeScene.tutorialIndex;

        if (tutorialIndex != 0)
        {
            bSize      = 3;
            solution2d = new int[bSize, bSize];
            string tutorMessage = "";
            if (tutorialIndex == 1)
            {
                degree2d = new int[3, 3] {
                    { -1, 180, 180 }, { -1, -1, 90 }, { 0, 0, 90 }
                };
                tutorMessage = "Your goal is to activate all arrows, tapping on one will activate it.";
            }
            else if (tutorialIndex == 2)
            {
                degree2d = new int[3, 3] {
                    { 0, 270, 180 }, { -1, 270, -1 }, { 0, -1, 90 }
                };
                tutorMessage = "It's like jumping from arrow to arrow. You'd be on the last arrow you activated, and you can only jump to the ones which are in your direction, no matter how far.";
            }
            else if (tutorialIndex == 3)
            {
                degree2d = new int[3, 3] {
                    { 315, -1, 270 }, { -1, 45, 270 }, { 45, -1, 135 }
                };
                tutorMessage = "They can go in diagonal directions as well! If you activate the invalid arrow then everything will reset.";
            }
            else if (tutorialIndex == 4)
            {
                degree2d = new int[3, 3] {
                    { 315, -1, 270 }, { -1, 45, -1 }, { 0, 180, 135 }
                };
                tutorMessage = "It never hurts to just sit back and think. Hint: Start with the arrow at the center bottom!";
            }
            else if (tutorialIndex == 5)
            {
                degree2d = new int[3, 3] {
                    { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }
                };
                tutorMessage = "You have completed the tutorial! Here are some tips:\n\n" +
                               "The last activated arrow would blink.\n\n" +
                               "The puzzles are all random, but you can develop your own strategy to solve any puzzle.\n\n" +
                               "The higher the difficulty, the higher the reward. Want to level up fast? Avoid using hints!\n\n" +
                               "You can directly unlock items in shop with hint points!\n\n" +
                               "For every 5 levels up your bonus multiplier would increase, it can also be found by opening packs.";
            }
            GameObject.Find("solutiontext").GetComponent <TextMeshProUGUI>().text = tutorMessage;
        }
        else
        {
            setUpPlay();

            /*
             * // print solution (keep this) //////////////////////////////
             * string solu = "";
             * for (int i = 0; i < bSize; i++)
             * {
             *  string line = "";
             *  for (int j = 0; j < bSize; j++)
             *  {
             *      int l = solution2d[i, j];
             *      line += l + ((l < 10) ? "   " : "  ");
             *  }
             *  solu += line + "\n";
             * }
             *
             * GameObject.Find("solutiontext").GetComponent<TextMeshProUGUI>().text = solu;*/
        }

        Color c;

        // get the selected arrow skin and color
        if (thisSceneName.Equals("Tutorial"))
        {
            image = CustomizeStorage.arrowImage[0];
            c     = CustomizeStorage.arrowColors[0];
        }
        else
        {
            image = CustomizeStorage.arrowImage[CustomizeStorage.selectedArrow];
            c     = CustomizeStorage.arrowColors[CustomizeStorage.selectedArrow];
        }

        // cell size
        cellSize = 22f / bSize;        // default
        float s = 68 / (bSize - 0.2f); // for positioning

        // set up arrows
        for (int y = bSize - 1; y > -1; y--)
        {
            for (int x = 0; x < bSize; x++)
            {
                float deg = degree2d[y, x] + 0.0f;

                // y is SAV*speed +25   (speed is at ABMovement, update yPos)
                startAnimateValue = 20;
                // instantiate => position and rotation
                clone = Instantiate(arrowButton,
                                    new Vector3(s * (x - (bSize - 1) * 0.5f), -s * (y - (bSize - 1) * 0.5f) + startAnimateValue * 2 + 25, 0),
                                    Quaternion.Euler(0, 0, deg));

                // set parent
                clone.transform.SetParent(ArrowsBoard);

                // re-scale
                clone.transform.localScale = new Vector3(cellSize, cellSize, 0);

                // set image
                spriteHolder = clone.GetComponent <SpriteRenderer>();
                if (CustomizeStorage.selectedArrow == 48 && !thisSceneName.Equals("Tutorial"))  // (if random ? set new img and color)
                {
                    int randomSelect = Random.Range(0, 48);
                    image = CustomizeStorage.arrowImage[randomSelect];
                    c     = CustomizeStorage.arrowColors[randomSelect];
                }
                spriteHolder.sprite = image;
                spriteHolder.color  = c;

                // set data
                dataHolder = clone.GetComponent <ArrowData>();
                dataHolder.changePos(x, y);

                // TUTORIAL TWIST!
                if (tutorialIndex != 0 && deg == -1)
                {
                    Destroy(clone);
                }
            }
        }
    }