Exemple #1
0
 // Load event handler, instantiates certain form variables needed during ship placement
 // Creates physical placement board for user, and displays useful info on form
 private void frmShipPlacement_Load(object sender, EventArgs e)
 {
     currentInternalBoard = new InternalBoard();
     currentShip          = currentPlayer.getShips()[shipNumber];
     board = BoardHandler.GenerateBoard(pnlShipPlacementBoard, Button_MouseClickPlacement);
     lblCurrentPlayerPlacement.Text = currentPlayer.getName() + " place your ships.";
     lblCurrentShipName.Text        = currentShip.getShipType() + ", it has a length of " + currentShip.getShipSize().ToString();
     shipNumber = 0;
 }
Exemple #2
0
 // Method that creates each player's 2 board for game play and assigns them to each player
 private void CreateBoards()
 {
     //Create and assign shipBoards
     Button[,] p1shipBoard = BoardHandler.GenerateBoard(pnlShipBoard_P1, Button_MouseClick);
     Button[,] p2shipBoard = BoardHandler.GenerateBoard(pnlShipBoard_P2, Button_MouseClick);
     //Create and assign guessBoards
     Button[,] p1guessBoard = BoardHandler.GenerateBoard(pnlGuessBoard_P1, Button_MouseClick);
     Button[,] p2guessBoard = BoardHandler.GenerateBoard(pnlGuessBoard_P2, Button_MouseClick);
     // Marks ship locations on each players ship board
     PlaceShips(p1shipBoard, playerOne.getShips());
     PlaceShips(p2shipBoard, playerTwo.getShips());
     //Give boards to player objects
     playerOne.setGuessBoard(p1guessBoard);
     playerOne.setShipBoard(p1shipBoard);
     playerTwo.setGuessBoard(p2guessBoard);
     playerTwo.setShipBoard(p2shipBoard);
 }