示例#1
0
        private void DifficultySelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedOption = DifficultySelector.GetItemText(DifficultySelector.SelectedItem);

            if (selectedOption == "Custom")
            {
                DifficultyCustomizer.Enabled = true;
            }
        }
示例#2
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;
            }
        }