Time for action – water in the pipes

  1. Add a method to the GameBoard class to clear the water marker from all pieces:
      public void ResetWater()
      {
          for (int y = 0; y < GameBoardHeight; y++)
              for (int x = 0; x < GameBoardWidth; x++)
                  boardSquares[x,y].RemoveSuffix("W");
      }
  2. Add a method to the GameBoard class to fill an individual piece with water:
      public void FillPiece(int X, int Y)
      {
          boardSquares[X,Y].AddSuffix("W");
      }

What just happened?

The ResetWater() method simply loops through each item in the boardSquares array and removes the W suffix from the GamePiece. Similarly, to fill a piece with water, the FillPiece() method adds the W suffix to the GamePiece. Recall that by having a W suffix, the GetSourceRect() method of GamePiece shifts the source rectangle ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.