예제 #1
0
파일: formGame.cs 프로젝트: vbergaaa/Mines
        private void formGame_Load(object sender, EventArgs e)
        {
            // Set Dummy game Control
            MineField = new MinefieldControl(1, 1, 1);

            ShowMainMenu();
        }
예제 #2
0
파일: formGame.cs 프로젝트: vbergaaa/Mines
        private void NewGame(MinefieldControl mf)
        {
            DialogResult result = DialogResult.Yes;

            if (this.MineField.GameInProgress)
            {
                result = MessageBox.Show("Are you sure you want to start a new game?\n\nYour current game will not be saved", "Start new game?", MessageBoxButtons.YesNo);
            }

            if (result == DialogResult.Yes)
            {
                // remove other menus
                pnlHighScores.Visible = false;
                pnlMainMenu.Visible   = false;

                // setup new Minefield Class
                pnlGame.Controls.Remove(MineField);
                MineField = mf;
                pnlGame.Controls.Add(MineField);

                // resize window
                pnlGame.Width      = 3 + 21 * mf.HorizontalTiles;
                pnlGame.Height     = 110 + 21 * mf.VerticalTiles;
                MineField.Location = new Point(1, 108);
                this.Width         = 41 + 21 * mf.HorizontalTiles;
                this.Height        = 171 + 21 * mf.VerticalTiles;

                // setup menus
                lblMinesLeft.Location = new Point(11 * mf.HorizontalTiles - 83, 48);
                btnRestart.Location   = new Point(11 * mf.HorizontalTiles - 83, 72);
                lblTimer.Location     = new Point(11 * mf.HorizontalTiles - 83, 30);
                lblMinesLeft.Text     = mf.TotalMines + " mines left";
                lblTimer.Text         = "";
                RefreshInGameButtons();     // check if cluebot is toggled and sets layout of screen ingame menu

                // center the game panel
                pnlGame.Location = new Point(
                    this.ClientSize.Width / 2 - pnlGame.Size.Width / 2,
                    this.ClientSize.Height / 2 - pnlGame.Size.Height / 2);
                pnlGame.Anchor = AnchorStyles.None;

                // misc control
                EndTimer();
                startTime = DateTime.MinValue;
                menuStrip1.BringToFront();
                pnlGame.Visible = true;

                ////debugs
                //System.Diagnostics.Debug.WriteLine("Minefield Size: " + MineField.HorizontalTiles + "x" + MineField.VerticalTiles);
                //System.Diagnostics.Debug.WriteLine("Panel Size: " + pnlGame.Size.Width + "x" + pnlGame.Size.Height);
                //System.Diagnostics.Debug.WriteLine("Panel Location: " + pnlGame.Location.X +  ", " + pnlGame.Location.Y);
                //System.Diagnostics.Debug.WriteLine("Form Size: " + this.ClientSize.Width + "x" + this.ClientSize.Height + "\n\n");
            }
        }
예제 #3
0
 // constructors
 public ClueBot(MinefieldControl mf)
 {
     Minefield = mf;
 }