Time for action – manipulating the GameBoard
Add
public
methods to theGameBoard
class to interact withGamePieces
:Public Sub RotatePiece(x As Integer, y As Integer, clockwise As Boolean) boardSquares(x, y).RotatePiece(clockwise) End Sub Public Function GetSourceRect( x As Integer, y As Integer) As Rectangle Return boardSquares(x, y).GetSourceRectangle() End Function Public Function GetSquare(x As Integer, y As Integer) As String Return boardSquares(x, y).PieceType End Function Public Sub SetSquare(x As Integer, y As Integer, pieceType As String) boardSquares(x, y).SetPiece(pieceType) End Sub Public Function HasConnector(x As Integer, y As Integer, direction As String) As Boolean Return boardSquares(x, y).HasConnector(direction) End Function Public Sub RandomPiece(x As Integer, y As Integer) boardSquares(x, y).SetPiece(GamePiece.PieceTypes( rand.Next(0, GamePiece.MaxPlayablePieceIndex + 1))) End Sub
What just happened?
RotatePiece()
, GetSourceRect()
, GetSquare()
, SetSquare...