Example #1
0
    private int GetColumnsScore()
    {
        int columnsScore = 0;

        for (int x = 0; x < columnScores.Length; x++)
        {
            int   score     = 0;
            int   inARow    = 1;
            Color lastColor = GetSquare(x, 0).GetCurrentFace().color;
            for (int y = 1; y < ROWS; y++)
            {
                DieValueViewer currentSquare = GetSquare(x, y);

                Color thisColor = currentSquare.GetCurrentFace().color;
                if (thisColor == lastColor && !currentSquare.Unused())
                {
                    inARow++;
                }
                else
                {
                    score += scoringValues[inARow];
                    inARow = 1;
                }

                lastColor = thisColor;
            }
            score += scoringValues[inARow];

            if (score == 0)
            {
                score = -5;
            }

            columnScores[x].SetText(score.ToString());

            columnsScore += score;
        }

        return(columnsScore);
    }
Example #2
0
    private int GetRowsScore()
    {
        int rowsScore = 0;

        for (int y = 1; y < rowScores.Length; y++)
        {
            int   score     = 0;
            int   inARow    = 1;
            Color lastColor = GetSquare(0, y - 1).GetCurrentFace().color;
            for (int x = 1; x < COLUMNS; x++)
            {
                DieValueViewer currentSquare = GetSquare(x, y - 1);

                Color thisColor = currentSquare.GetCurrentFace().color;
                if (thisColor == lastColor && !currentSquare.Unused())
                {
                    inARow++;
                }
                else
                {
                    score += scoringValues[inARow];
                    inARow = 1;
                }

                lastColor = thisColor;
            }
            score += scoringValues[inARow];

            if (score == 0)
            {
                score = -5;
            }

            rowScores[y].SetText(score.ToString());

            rowsScore += score;
        }

        return(rowsScore);
    }
Example #3
0
    private int GetDiagonalScore()
    {
        int diagonalScore = 0;
        int x             = 0;
        int inARow        = 1;

        Color lastColor = GetSquare(x, ROWS - 1).GetCurrentFace().color;

        for (int y = ROWS - 2; y >= 0; y--)
        {
            x++;
            DieValueViewer currentSquare = GetSquare(x, y);

            Color thisColor = currentSquare.GetCurrentFace().color;
            if (thisColor == lastColor && !currentSquare.Unused())
            {
                inARow++;
            }
            else
            {
                diagonalScore += scoringValues[inARow];
                inARow         = 1;
            }

            lastColor = thisColor;
        }
        diagonalScore += scoringValues[inARow];

        if (diagonalScore == 0)
        {
            diagonalScore = -5;
        }
        rowScores[0].SetText(diagonalScore.ToString());

        return(diagonalScore);
    }