コード例 #1
0
        private void creatingShipsLayout(GAME_MODE mode)
        {
            Global.GameMode = mode;

            this.Controls.Remove(hostButton);
            this.Controls.Remove(joinButton);
            this.Controls.Remove(exitButton);
            this.Controls.Remove(logoPictureBox);

            this.Controls.Add(randomButton);
            this.Controls.Add(backButton);
            this.Controls.Add(nextButton);

            mainBoard.setShips(GameBoard.generateMatrix());
            mainBoard.Visible = true;
        }
コード例 #2
0
        private void myInitialization()
        {
            this.ClientSize = new System.Drawing.Size(350, 550);
            int topMargin = MARGIN + 20;
            int width     = this.ClientSize.Width;
            int height    = this.ClientSize.Height;

            hostButton          = new ImageButton("Host Game");
            hostButton.Location = new Point(width / 2 - hostButton.Width / 2, height / 2 - 2 * hostButton.Height);
            hostButton.Click   += delegate(object sender, EventArgs e) { creatingShipsLayout(GAME_MODE.HOST); };
            this.Controls.Add(hostButton);

            joinButton          = new ImageButton("Join Game");
            joinButton.Location = new Point(width / 2 - joinButton.Width / 2, height / 2 - joinButton.Height + 5);
            joinButton.Click   += delegate(object sender, EventArgs e) { creatingShipsLayout(GAME_MODE.CLIENT); };
            this.Controls.Add(joinButton);

            exitButton          = new ImageButton("Exit");
            exitButton.Location = new Point(width / 2 - exitButton.Width / 2, height / 2 + joinButton.Height + 5);
            exitButton.Click   += delegate(object sender, EventArgs e) { Close(); };
            this.Controls.Add(exitButton);

            backButton          = new ImageButton("Back");
            backButton.Location = new Point(width / 4 - backButton.Width / 2, topMargin);
            backButton.Click   += delegate(object sender, EventArgs e) { mainMenuLayout(); };

            nextButton          = new ImageButton("Next");
            nextButton.Location = new Point(width / 2 + width / 4 - nextButton.Width / 2, topMargin);
            nextButton.Click   += StartGame;

            randomButton          = new ImageButton("Random");
            randomButton.Location = new Point(width / 2 - randomButton.Width / 2, topMargin + randomButton.Height + 10);
            randomButton.Click   += delegate(object sender, EventArgs e) { mainBoard.setShips(GameBoard.generateMatrix()); };

            mainBoard         = new GameBoard(GameBoard.BoardType.MAIN_BOARD, GameBoard.empty);
            mainBoard.Enabled = false;
            mainBoard.addToWindow(this);
            mainBoard.Visible = false;

            prevBoard         = new GameBoard(GameBoard.BoardType.PREVIEW_BOARD, GameBoard.empty);
            prevBoard.Enabled = false;
            prevBoard.addToWindow(this);
            prevBoard.Visible = false;
        }