From e70f2031b94eddfa55a81ccdaebc649a46c10aa8 Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Fri, 25 May 2018 11:38:24 +0200 Subject: [PATCH] Reveal Bombs when loose --- CoopSweeper/GameTypes/Game.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/CoopSweeper/GameTypes/Game.cs b/CoopSweeper/GameTypes/Game.cs index 7bed2ec..70ee161 100644 --- a/CoopSweeper/GameTypes/Game.cs +++ b/CoopSweeper/GameTypes/Game.cs @@ -120,7 +120,7 @@ namespace CoopSweeper.GameTypes { field.State = FieldState.REVEALED; if (field.ContainsBomb) - GameFinished?.Invoke(false); + FinishGame(false); if (field.SurroundingBombs == 0) foreach (var surField in GetSorroundedFields(x, y)) @@ -130,7 +130,26 @@ namespace CoopSweeper.GameTypes } if (CheckGameFinished()) - GameFinished?.Invoke(true); + FinishGame(true); + } + + private void RevealBombs() + { + + for (int i = 0; i < Map.GetLength(0); i++) + { + for (int j = 0; j < Map.GetLength(1); j++) + { + if (Map[i, j].ContainsBomb) + Map[i, j].State = FieldState.REVEALED; + } + } + } + + private void FinishGame(bool isWon) + { + RevealBombs(); + GameFinished?.Invoke(isWon); } public void Reveal(int x, int y)