Time for action – making the connection
Add the
PropagateWater()
method to theGameBoard
class:Public Sub PropagateWater(x As Integer, y As Integer, fromDirection As String) If (y >= 0) And (y <= GameBoardHeight) And (x >= 0) And (x <= GameBoardWidth) Then If boardSquares(x, y).HasConnector(fromDirection) And Not (boardSquares(x, y).PieceSuffix.Contains("W")) Then FillPiece(x, y) waterTracker.Add(New Vector2(x, y)) For Each pipeEnd As String In boardSquares(x, y).GetOtherEnds(fromDirection) Select Case pipeEnd Case "Left" PropagateWater(x - 1, y, "Right") Case "Right" PropagateWater(x + 1, y, "Left") Case "Top" PropagateWater(x, y - 1, "Bottom") Case "Bottom" PropagateWater(x, y + 1, "Top") End Select Next End If End If End Sub
Add the
GetWaterChain()
method to theGameBoard
class:Public Function GetWaterChain(y As Integer...