Example #1
0
        public FormGameSubSelector(string caption, Games[] games)
        {
            InitializeComponent();

            this.Text = "Which " + caption + " Game?";

            List <KeyValuePair <Games, string> > options = new List <KeyValuePair <Games, string> >();

            // Creates a drop-down option for each game, with the enum value and then the user-friendly name
            foreach (Games game in games)
            {
                options.Add(new KeyValuePair <Games, string>(game, GamesImplementation.GetGameName(game)));
            }

            this.cmbGame.DataSource   = options;
            this.cmbGame.SelectedItem = null;
        }
Example #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            Games game;

            if (this.radGameTypeCard.Checked)   // Show card games
            {
                FormGameSubSelector selector = new FormGameSubSelector("Card", new[] {
                    Games.TwentyOne,
                    Games.CrazyEights
                });

                if (selector.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                game = selector.ReturnValue;
            }
            else if (this.radGameTypeDice.Checked)     // Show dice games
            {
                FormGameSubSelector selector = new FormGameSubSelector("Dice", new[] {
                    Games.SnakeEyes,
                    Games.CaptainShipCrew
                });

                if (selector.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                game = selector.ReturnValue;
            }
            else     // this.radGameTypeCoin.Checked --- Play the only coin game
            {
                game = Games.TwoUp;
            }

            GamesImplementation.PlayGame(game);
        }