Пример #1
0
 /* Renders tiles to the grid and invokes SetAdjacentTiles. */
 internal void LoadGrid(Size gridSize, int mines)
 {
     this.minesGenerated = false;
     /* Remove all controls from the grid. */
     this.Controls.Clear();
     this.gridSize = gridSize;
     this.mines    = this.flags = mines;
     this.Size     = new Size(gridSize.Width * Tile.LENGTH, gridSize.Height * Tile.LENGTH);
     /* Add tiles to the grid. */
     for (int x = 0; x < gridSize.Width; x++)
     {
         for (int y = 0; y < gridSize.Height; y++)
         {
             Tile tile = new Tile(x, y);
             /* Custom event listener triggered when the user clicks on a tile. */
             tile.MouseDown += Tile_MouseDown;
             this.Controls.Add(tile);
         }
     }
     /* Iterate over every tile in the grid. */
     foreach (Tile tile in this.Controls)
     {
         /* Add all adjacent tiles to the internal adjacent tile list. */
         tile.SetAdjacentTiles();
     }
 }
Пример #2
0
 internal void LoadGrid(Size gridSize, int mines)
 {
     this.minesGenerated = false;
     this.Controls.Clear();
     this.gridSize = gridSize;
     this.mines    = this.flags = mines;
     this.Size     = new Size(gridSize.Width * Tile.LENGTH, gridSize.Height * Tile.LENGTH);
     for (int i = 0; i < gridSize.Width; i++)
     {
         for (int j = 0; j < gridSize.Height; j++)
         {
             Tile tile = new Tile(i, j);
             tile.MouseDown += Tile_MouseDown;
             this.Controls.Add(tile);
         }
     }
     foreach (Tile tile in this.Controls)
     {
         tile.SetAdjacentTiles();
     }
 }
 public void LoadGrid(Size gridSize, int mines)
 {
     this.minesGenerated = false;
     this.Controls.Clear();
     this.gridSize = gridSize;
     this.mines    = this.flags = mines;
     this.Size     = new Size(gridSize.Width * Tile.LENGTH, gridSize.Height * Tile.LENGTH);
     for (int x = 0; x < gridSize.Width; x++)
     {
         for (int y = 0; y < gridSize.Height; y++)
         {
             Tile tile = new Tile(x, y);
             tile.MouseDown += Tile_MouseDown;
             this.Controls.Add(tile);
         }
     }
     foreach (Tile tile in this.Controls)
     {
         tile.SetAdjacentTiles();
     }
 }