Exemple #1
0
    private bool checkPointsRow()
    {
        bool achievedPoints = false;

        for (int y = 0; y < maxY; ++y)
        {
            int sameColor = 1, start = 0;

            for (int x = 1; x < maxX; ++x)
            {
                tilesCompareState compState = compareTiles(tile[x, y], tile[x - 1, y]);

                if (compState == tilesCompareState.SAME)
                {
                    ++sameColor;

                    if (x == maxX - 1 && sameColor >= requiredTilesInLine)
                    {
                        achievedPoints = true;
                        removeRow(y, start, x);
                    }
                }
                else
                {
                    if (sameColor >= requiredTilesInLine)
                    {
                        achievedPoints = true;
                        removeRow(y, start, x - 1);
                    }

                    sameColor = 1;
                    start     = x;
                }
            }
        }

        return(achievedPoints);
    }
Exemple #2
0
    private bool checkPointsColumn()
    {
        bool achievedPoints = false;

        for (int x = 0; x < maxX; ++x)
        {
            int sameColor = 1, start = 0;

            for (int y = 1; y < maxY; ++y)
            {
                tilesCompareState compState = compareTiles(tile[x, y], tile[x, y - 1]);

                if (compState == tilesCompareState.SAME)
                {
                    ++sameColor;

                    if (y == maxY - 1 && sameColor >= requiredTilesInLine)
                    {
                        achievedPoints = true;
                        removeColumn(x, start, y);
                    }
                }
                else
                {
                    if (sameColor >= requiredTilesInLine)
                    {
                        achievedPoints = true;
                        removeColumn(x, start, y - 1);
                    }

                    sameColor = 1;
                    start     = y;
                }
            }
        }

        return(achievedPoints);
    }