Exemplo n.º 1
0
        /// <summary>
        /// Draws the game field.
        /// </summary>
        /// <param name="minefield">The minefield to be drawn.</param>
        /// <param name="neighborMines">The minefield with all values of neighboring mines.</param>
        public void DrawGameField(CellImage[,] minefield, int[,] neighborMines)
        {
            if (minefield.GetLength(0) != neighborMines.GetLength(0) ||
                minefield.GetLength(1) != neighborMines.GetLength(1))
            {
                throw new ArgumentException("Matrices dimensions are not equal!");
            }

            this.boardGenerator.DrawGameField(minefield, neighborMines, this.minefieldTopLeft);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draws game minefield on screen via given IRenderer.
        /// </summary>
        /// <param name="minefield">Image of the minefield represented by two dimensional array of CellImage enumeration.</param>
        /// <param name="neighborMines">Two dimensional array of numbers representing neighbor mines for each cell.</param>
        /// <param name="topLeft">Top left coordinates of the board.</param>
        public void DrawGameField(CellImage[,] minefield, int[,] neighborMines, ICellPosition topLeft)
        {
            for (int row = 0; row < minefield.GetLength(0); row++)
            {
                for (int col = 0; col < minefield.GetLength(1); col++)
                {
                    int rowOnScreen = topLeft.Row + BoardOffsetByRow + row;
                    int colOnScreen = topLeft.Col + BoardOffsetByColumn + (col * CellSpaceOnScreen);

                    string symbol;
                    var symbolType = minefield[row, col];
                    if (symbolType == CellImage.Num)
                    {
                        int num = neighborMines[row, col];
                        symbol = (num == 0) ? EmptyCell : num.ToString();
                    }
                    else
                    {
                        symbol = this.symbols[symbolType];
                    }

                    this.DrawCell(rowOnScreen, colOnScreen, symbol);
                }
            }
        }