Exemplo n.º 1
0
        //private void button11_Click(object sender, EventArgs e)
        //{
        //    player1.placeship(0, 1, Board.patrol_boat1, Board.horizontalalign);
        //    player1.placeship(1, 1, Board.patrol_boat2, Board.verticalalign);

        //    setGrid(player1, Board1);
        //    button1.Enabled = false;
        //    // once players have set thier ships enable play for first player
        //    if (!button2.Enabled)
        //      button3.Enabled = true;
        //}
        // Player 2 place ships

        private void button2_Click(object sender, EventArgs e)
        {
            int rowindex    = Board2.SelectedCells[0].RowIndex;
            int columnindex = Board2.SelectedCells[0].ColumnIndex;

            bool success = player2.placeship(rowindex, columnindex, player2shiplist.SelectedItem.ToString(), player2shipalign.SelectedItem.ToString());

            if (success)
            {
                setGrid(player2, Board2);
            }
            else
            {
                player2message.Text = "Ship cannot be placed in that position";
            }
        }