Exemple #1
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            string selectedOption   = DifficultySelector.GetItemText(DifficultySelector.SelectedItem);
            bool   noOptionSelected = false;

            switch (selectedOption)
            {
            case "Easy 8*8 (10 mines)":
                GameInfo.BoardX         = 8;
                GameInfo.BoardY         = 8;
                GameInfo.TotalMineCount = 10;
                break;

            case "Normal 16*16 (40 mines)":
                GameInfo.BoardX         = 16;
                GameInfo.BoardY         = 16;
                GameInfo.TotalMineCount = 40;
                break;

            case "Hard 30*16 (99 mines)":
                GameInfo.BoardX         = 30;
                GameInfo.BoardY         = 16;
                GameInfo.TotalMineCount = 99;
                break;

            case "Custom":
                GameInfo.BoardX         = (int)XCustomizer.Value;
                GameInfo.BoardY         = (int)YCustomizer.Value;
                GameInfo.TotalMineCount = (int)MinesCustomizer.Value;
                break;

            default:    //no item is selected
                noOptionSelected = true;
                break;
            }
            if (noOptionSelected == false)
            {
                Hide();//hide startup menu
                MinesweeperInstance = new Minesweeper();
                MinesweeperInstance.Show();
                GameInfo.GameStarted = true;
            }
        }
Exemple #2
0
        private void play_Click(object sender, EventArgs e)
        {
            if (sizeButtons.SelectedValue == null)
            {
                return;
            }
            int bombs = Int32.Parse(Math.Round(numberBombs.Value).ToString());
            int rows  = Int32.Parse(Math.Round(numberRows.Value).ToString());
            int cols  = Int32.Parse(Math.Round(numberCols.Value).ToString());

            Enum.TryParse <ButtonSize>(sizeButtons.SelectedValue.ToString(), out ButtonSize buttonSize);
            int size = (int)buttonSize;

            Hide();

            Minesweeper form1 = new Minesweeper(rows, cols, bombs, size);

            form1.Closed += (s, args) => Close();
            form1.Show();
            form1.NewGame();
        }