コード例 #1
0
ファイル: Form1.cs プロジェクト: Ontrox/Battleship-1
        public void formBoards()
        {
            int horizontalLoc = 49;
            int verticalLoc   = 126;

            for (int k = 0; k < 10; k++)
            {
                playerGridButtons[k] = new GridButton[10];
            }
            for (int l = 0; l < 10; l++)
            {
                enemyGridButtons[l] = new GridButton[10];
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    setGridButtonAttributes(i, j, horizontalLoc, verticalLoc, ref playerGridButtons);
                    setGridButtonAttributes(i, j, horizontalLoc + 584, verticalLoc, ref enemyGridButtons);
                    enemyGridButtons[i][j].XLoc         = j;
                    enemyGridButtons[i][j].YLoc         = i;
                    playerGridButtons[i][j].Text        = playerGridButtons[i][j].XLoc + ", " + playerGridButtons[i][j].YLoc;
                    enemyGridButtons[i][j].Text         = enemyGridButtons[i][j].XLoc + ", " + enemyGridButtons[i][j].YLoc;
                    playerGridButtons[i][j].MouseUp    += new MouseEventHandler(playerGridButton_Click);
                    playerGridButtons[i][j].MouseEnter += new EventHandler(playerGridButton_MouseEnter);
                    playerGridButtons[i][j].MouseLeave += new EventHandler(playerGridButton_MouseLeave);
                    enemyGridButtons[i][j].MouseUp     += new MouseEventHandler(enemyGridButton_Click);
                    //                enemyGridButtons[i][j].MouseEnter += new EventHandler(enemyGridButton_MouseEnter);
                    //                enemyGridButtons[i][j].MouseLeave += new EventHandler(enemyGridButton_MouseLeave);
                    this.Controls.Add(playerGridButtons[i][j]);
                    this.Controls.Add(enemyGridButtons[i][j]);
                    controller.setPlayerTurn(0);
                    horizontalLoc += 37;
                }
                horizontalLoc = 49;
                verticalLoc  += 35;
            }

            singlePlayerMode();
        }
コード例 #2
0
 void resetUI()
 {
     controller            = new GameController();
     startButton.Text      = "Start Game";
     turnLabel.Text        = "Arrange Your Ships";
     playerScore           = 0;
     playerScoreLabel.Text = "Your Score: " + playerScore + "/17";
     compScore             = 0;
     label42.Text          = "Enemy Score: " + compScore + "/17";
     canPlaceShips         = true;
     restarting            = false;
     controller.setPlayerTurn(0);
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             playerGridButtons[i][j].BringToFront();
             enemyGridButtons[i][j].BackColor = Color.Transparent;
             enemyGridButtons[i][j].BringToFront();
             playerGridButtons[i][j].BackColor = Color.Transparent;
         }
     }
     this.ship2PictureBox.Visible        = true;
     this.ship3aPictureBox.Visible       = true;
     this.ship3bPictureBox.Visible       = true;
     this.ship4PictureBox.Visible        = true;
     this.ship5PictureBox.Visible        = true;
     this.ship2PlacedPictureBox.Visible  = true;
     this.ship3aPlacedPictureBox.Visible = true;
     this.ship3bPlacedPictureBox.Visible = true;
     this.ship4PlacedPictureBox.Visible  = true;
     this.ship5PlacedPictureBox.Visible  = true;
     this.ship2PlacedPictureBox.BringToFront();
     this.ship3aPlacedPictureBox.BringToFront();
     this.ship3bPlacedPictureBox.BringToFront();
     this.ship4PlacedPictureBox.BringToFront();
     this.ship5PlacedPictureBox.BringToFront();
     computer = new AIPlayer();
     Board.resetBoard();
     singlePlayerMode();
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: ninoaguilar/Battleship
 void resetUI()
 {
     controller = new GameController();
             startButton.Text = "Start Game";
             turnLabel.Text = "Arrange Your Ships";
             playerScore = 0;
             playerScoreLabel.Text = "Your Score: " + playerScore + "/17";
             compScore = 0;
             label42.Text = "Enemy Score: " + compScore + "/17";
             canPlaceShips = true;
             restarting = false;
             controller.setPlayerTurn(0);
             for (int i = 0; i < 10; i++)
             {
                 for (int j = 0; j < 10; j++)
                 {
                     playerGridButtons[i][j].BringToFront();
                     enemyGridButtons[i][j].BackColor = Color.Transparent;
                     enemyGridButtons[i][j].BringToFront();
                     playerGridButtons[i][j].BackColor = Color.Transparent;
                 }
             }
             this.ship2PictureBox.Visible = true;
             this.ship3aPictureBox.Visible = true;
             this.ship3bPictureBox.Visible = true;
             this.ship4PictureBox.Visible = true;
             this.ship5PictureBox.Visible = true;
     this.ship2PlacedPictureBox.Visible = true;
     this.ship3aPlacedPictureBox.Visible = true;
     this.ship3bPlacedPictureBox.Visible = true;
     this.ship4PlacedPictureBox.Visible = true;
     this.ship5PlacedPictureBox.Visible = true;
     this.ship2PlacedPictureBox.BringToFront();
     this.ship3aPlacedPictureBox.BringToFront();
     this.ship3bPlacedPictureBox.BringToFront();
     this.ship4PlacedPictureBox.BringToFront();
     this.ship5PlacedPictureBox.BringToFront();
     computer = new AIPlayer();
             Board.resetBoard();
             singlePlayerMode();
 }