Esempio n. 1
0
    int visitedAmount;            // to check if visited all

    // -----------------------------------------------
    // For gameplay >>>>>>

    public void resetAll()
    {
        playVisited        = 0;
        lastPressed        = null;
        lastPressedTintObj = null;

        var arrows = GameObject.FindGameObjectsWithTag("ArrowItem");

        // loops through all arrowItems
        foreach (var arrowItem in arrows)
        {
            ArrowData dataHolder = arrowItem.GetComponent <ArrowData>();
            if (dataHolder.activated)
            {
                arrowItem.GetComponent <UpdateTint>().setShrink(0.6f);
                dataHolder.activated = false;
            }
        }
    }
Esempio n. 2
0
    public void newPlayMove(ArrowData obj, UpdateTint tintObj)
    {
        bool correct = false; // qualified to be activated

        // not the first arrow to be pressed? => futher check
        if (playVisited > 0)
        {
            // not within the direction of last object => return
            bool q            = Mathf.Abs(lastPressed.cx - obj.cx) == Mathf.Abs(lastPressed.cy - obj.cy);
            int  lastArrowDeg = degree2d[lastPressed.cy, lastPressed.cx];
            // up
            if (lastArrowDeg == 90)
            {
                correct = obj.cx == lastPressed.cx && obj.cy < lastPressed.cy;
            }
            // down
            else if (lastArrowDeg == 270)
            {
                correct = obj.cx == lastPressed.cx && obj.cy > lastPressed.cy;
            }
            // left
            else if (lastArrowDeg == 180)
            {
                correct = obj.cy == lastPressed.cy && obj.cx < lastPressed.cx;
            }
            // right
            else if (lastArrowDeg == 0)
            {
                correct = obj.cy == lastPressed.cy && obj.cx > lastPressed.cx;
            }
            // up right
            else if (lastArrowDeg == 45)
            {
                correct = q && obj.cy <lastPressed.cy && obj.cx> lastPressed.cx;
            }
            // down right
            else if (lastArrowDeg == 315)
            {
                correct = q && obj.cy > lastPressed.cy && obj.cx > lastPressed.cx;
            }
            // down left
            else if (lastArrowDeg == 225)
            {
                correct = q && obj.cy > lastPressed.cy && obj.cx < lastPressed.cx;
            }
            // up left
            else if (lastArrowDeg == 135)
            {
                correct = q && obj.cy < lastPressed.cy && obj.cx < lastPressed.cx;
            }
        }
        else
        {
            correct = true;
        }
        if (!correct)
        {
            if (PlayerPrefs.GetString("sound").Equals("on"))
            {
                incorrectSound.Play();
            }
            resetAll();
        }
        else  // CORRECT!
        {
            if (PlayerPrefs.GetString("sound").Equals("on"))
            {
                correctSound.Play();
            }
            obj.activated = true;
            playVisited++;
            lastPressed        = obj;
            lastPressedTintObj = tintObj;
            blinkTimer         = 150; //// set timer for blinking

            // check win (IF TUTORIAL ELSE NORMAL PLAY)
            if (ChangeScene.tutorialIndex != 0 && playVisited == 6)
            {
                won = true;
            }
            else if (playVisited == bSize * bSize)
            {
                won = true;
                ChangeScene.adsPopCount -= 1;

                // add to solves
                if (bSize == 3)
                {
                    PlayerPrefs.SetInt("easy", PlayerPrefs.GetInt("easy") + 1);
                }
                else if (bSize == 4)
                {
                    PlayerPrefs.SetInt("normal", PlayerPrefs.GetInt("normal") + 1);
                }
                else if (bSize == 5)
                {
                    PlayerPrefs.SetInt("hard", PlayerPrefs.GetInt("hard") + 1);
                }
            }
        }
    }