Time for action – making the connection
Add the
PropagateWater()
method to the GameBoard class:public void PropagateWater(int x, int y, string fromDirection) { if ((y >= 0) && (y < GameBoardHeight) && (x >= 0) && (x < GameBoardWidth)) { if (boardSquares[x,y].HasConnector(fromDirection) && !boardSquares[x,y].Suffix.Contains("W")) { FillPiece(x, y); WaterTracker.Add(new Vector2(x, y)); foreach (string end in boardSquares[x,y].GetOtherEnds(fromDirection)) switch (end) { case "Left": PropagateWater(x - 1, y, "Right"); break; case "Right": PropagateWater(x + 1, y, "Left"); break; case "Top": PropagateWater(x, y - 1, "Bottom"); break; ...