Example #1
0
    void switchOrbs(Orb orb1, Orb orb2)      //orb1 - moving orb | orb2 - stationary orb
    {
        int temp_index = orb2.getOrbIndex();

        orb2.setOrbIndex(orb1.getOrbIndex());
        moveOrbByIndex(orb2);

        orb1.setOrbIndex(temp_index);

        switchOrb   = null;
        switchOrb_S = null;
    }
Example #2
0
    public void moveOrbByIndex(Orb orbToMove)
    {
        int x, y;

        x = y = orbToMove.getOrbIndex() + 1;
        //get x
        while (x > BOARD_WRAP)
        {
            x = x - 6;
        }

        //get y
        y = getY(y);

        //Debug.Log (string.Format("displayBoard: Index: {2} X: {0} Y: {1}", x, y, orb.GetComponent<Orb>().index));

        orbToMove.setPosition(new Vector2(x * OFFSET, y * OFFSET));
    }
Example #3
0
    public void checkForMatches()
    {
        Debug.Log("Checking for Matches.");
        foreach (GameObject orb in orbs)
        {
            Orb orb_S   = orb.GetComponent <Orb>();
            Orb nextOrb = null;

            GameObject[] tmp = new GameObject[2];

            //horizontal check
            if (!checkIfEnd_Hor(orb_S.getOrbIndex()))
            {
                nextOrb = findOrbByIndex(orb_S.getOrbIndex() + 1);
            }
            if (nextOrb != null)
            {
                if (orb_S.getOrbColor().Equals(nextOrb.getOrbColor()))
                {
                    tmp[0] = orb_S.gameObject;
                    tmp[1] = nextOrb.gameObject;

                    if (orb_S.getOrbColor().Equals("red"))
                    {
                        matches_red_h.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("blue"))
                    {
                        matches_blue_h.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("green"))
                    {
                        matches_green_h.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("yellow"))
                    {
                        matches_yellow_h.Add(tmp);
                    }
                }
            }
            //vertical check
            if (!checkIfEnd_Vert(orb_S.getOrbIndex()))
            {
                nextOrb = findOrbByIndex(orb_S.getOrbIndex() + 1);
            }
            if (nextOrb != null)
            {
                if (orb_S.getOrbColor().Equals(nextOrb.getOrbColor()))
                {
                    tmp[0] = orb_S.gameObject;
                    tmp[1] = nextOrb.gameObject;

                    if (orb_S.getOrbColor().Equals("red"))
                    {
                        matches_red_v.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("blue"))
                    {
                        matches_blue_v.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("green"))
                    {
                        matches_green_v.Add(tmp);
                    }
                    if (orb_S.getOrbColor().Equals("yellow"))
                    {
                        matches_yellow_v.Add(tmp);
                    }
                }
            }
        }
    }