public MinerGame(string playerName, int heigh, int width, int bombs) { this.playerName = playerName; Height = heigh; Width = width; gameField = new OneCell[heigh, width]; for (int row = 0; row < heigh; row++) { for (int col = 0; col < width; col++) { gameField[row, col] = new OneCell(); } } Random randomNumber = new Random(); for (int i = 0; i < bombs; i++) { SetBomb(randomNumber.Next(0, heigh - 1), randomNumber.Next(0, width - 1)); } }
void _DrawO(Graphics g, OneCell cell) { Pen pen = new Pen(Color.Black); pen.Width = _penWidth; int stepX = _w / 3; int stepY = _h / 3; Rectangle rectangle = new Rectangle(stepX * cell.j + _offset, stepY * cell.i + _offset, stepX - _offset * 2, stepY - _offset * 2); g.DrawArc(pen, rectangle, 0, 360); }
void _DrawX(Graphics g, OneCell cell) { Pen pen = new Pen(Color.Black); pen.Width = _penWidth; int stepX = _w / 3; int stepY = _h / 3; Point p1_1 = new Point(stepX * cell.j + _offset, stepY * cell.i + _offset); Point p1_2 = new Point(stepX * cell.j + stepX - _offset, stepY * cell.i + stepY - _offset); Point p2_1 = new Point(stepX * cell.j + stepX - _offset, stepY * cell.i + _offset); Point p2_2 = new Point(stepX * cell.j + _offset, stepY * cell.i + stepY - _offset); g.DrawLine(pen, p1_1, p1_2); g.DrawLine(pen, p2_1, p2_2); }
void _DrawCell(Graphics g, OneCell cell) { PrototypeDrawCell func; if (cell.value == X) func = _DrawX; else if (cell.value == O) func = _DrawO; else return; func(g, cell); }