Beispiel #1
0
 /// <summary>
 /// If the specified tile is mined, the mine will be moved to a different tile.
 /// </summary>
 public void MoveMine(int row, int col)
 {
     if (!tiles[row, col].Mined)
     {
         return;
     }
     for (int r = 0; r < height; r++)
     {
         for (int c = 0; c < width; c++)
         {
             if (!tiles[r, c].Mined)
             {
                 tiles[r, c].Mined = true;
                 for (AdjLoc l = new AdjLoc(this, r, c); l.Valid; l++)
                 {
                     tiles[l.Row, l.Col].Number++;
                 }
                 tiles[row, col].Mined = false;
                 for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
                 {
                     tiles[l.Row, l.Col].Number--;
                 }
                 return;
             }
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Reveals all tiles touching the specified tile.
 /// </summary>
 void RevealTouching(int row, int col)
 {
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (!tiles[l.Row, l.Col].Flagged)
         {
             tiles[l.Row, l.Col].Hidden = false;
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Returns a value indicating whether the specified tile is touching a hidden tile.
 /// </summary>
 public bool TouchingHiddenTile(int row, int col)
 {
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (tiles[l.Row, l.Col].Hidden && !tiles[l.Row, l.Col].Flagged)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
    /// <summary>
    /// Reveals the tiles surrounding the specified tile and returns a value indicating if any were mined and unflagged.
    /// </summary>
    public bool ClickSurrounding(int row, int col)
    {
        bool mineClicked = false;

        for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
        {
            if (Click(l.Row, l.Col))
            {
                mineClicked = true;
            }
        }
        return(mineClicked);
    }
Beispiel #5
0
    /// <summary>
    /// Returns a value indicating the number of flagged tiles the specified tile is touching.
    /// </summary>
    public int FlagsTouching(int row, int col)
    {
        int surroundingFlags = 0;

        for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
        {
            if (tiles[l.Row, l.Col].Flagged)
            {
                surroundingFlags++;
            }
        }
        return(surroundingFlags);
    }
Beispiel #6
0
    int TileNumber(int row, int col)
    {
        int accumulator = 0;

        for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
        {
            if (tiles[l.Row, l.Col].Mined)
            {
                accumulator++;
            }
        }
        return(accumulator);
    }
Beispiel #7
0
 int TileNumber(int row, int col)
 {
     int accumulator = 0;
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (tiles[l.Row, l.Col].Mined) accumulator++;
     }
     return accumulator;
 }
Beispiel #8
0
 /// <summary>
 /// Reveals all tiles touching the specified tile.
 /// </summary>
 void RevealTouching(int row, int col)
 {
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (!tiles[l.Row, l.Col].Flagged) tiles[l.Row, l.Col].Hidden = false;
     }
 }
Beispiel #9
0
 /// <summary>
 /// Returns a value indicating whether the specified tile is touching a hidden tile.
 /// </summary>
 public bool TouchingHiddenTile(int row, int col)
 {
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (tiles[l.Row, l.Col].Hidden && !tiles[l.Row, l.Col].Flagged) return true;
     }
     return false;
 }
Beispiel #10
0
 /// <summary>
 /// Returns a value indicating the number of flagged tiles the specified tile is touching.
 /// </summary>
 public int FlagsTouching(int row, int col)
 {
     int surroundingFlags = 0;
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (tiles[l.Row, l.Col].Flagged) surroundingFlags++;
     }
     return surroundingFlags;
 }
Beispiel #11
0
 /// <summary>
 /// Reveals the tiles surrounding the specified tile and returns a value indicating if any were mined and unflagged.
 /// </summary>
 public bool ClickSurrounding(int row, int col)
 {
     bool mineClicked = false;
     for (AdjLoc l = new AdjLoc(this, row, col); l.Valid; l++)
     {
         if (Click(l.Row, l.Col)) mineClicked = true;
     }
     return mineClicked;
 }