Exemplo n.º 1
0
 //recursively clear buttons that contain minefield spaces with a zero mineCount
 public void ClearZeroMineCounts(Space currentSpace, MineField mineField)
 {
     if (currentSpace.GetMineCount() == 0)
     {
         foreach (KeyValuePair <int, Point> location in currentSpace.parameter)
         {
             KeyValuePair <int, Space> adjacentSpace = mineField.GetSpace(location.Value);
             if (adjacentSpace.Value != null && buttonMap[adjacentSpace.Key].Enabled)
             {
                 buttonMap[adjacentSpace.Key].Enabled   = false;
                 buttonMap[adjacentSpace.Key].BackColor = Color.Chocolate;
                 mineField.MoveCloserToWinCondition();
                 if (adjacentSpace.Value.GetMineCount() != 0)
                 {
                     buttonMap[adjacentSpace.Key].Text = adjacentSpace.Value.GetMineCount().ToString();
                 }
                 if (adjacentSpace.Value.GetMineCount() == 0)
                 {
                     //recursive call
                     ClearZeroMineCounts(adjacentSpace.Value, mineField);
                 }
             }
         }
     }
 }