/// <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; } } } }
/// <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; } } }
/// <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); }
/// <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); }
/// <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); }
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); }
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; }
/// <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; } }
/// <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; }
/// <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; }
/// <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; }