This commit is contained in:
Marvin Rohrbach
2018-05-26 09:13:03 +02:00

View File

@@ -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)