Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Name f = new Name();
            f.ShowDialog();
            if (f.DialogResult == DialogResult.Cancel)
                return;
            if (f.DialogResult == DialogResult.OK)
                this.Visible = false;

            Human player1 = new Human();
            Human player2 = new Human();

            this.Visible = false;
            PrepareToGame prepare1 = new PrepareToGame();
            prepare1.ShowDialog();

            if (prepare1.DialogResult == DialogResult.OK)
            {
                player1 = prepare1.ReturnPlayer();
                player1.name = f.ReturnName();
                f = new Name();
                f.ShowDialog();
                if (f.DialogResult == DialogResult.Cancel)
                {
                    this.Visible = true;
                    return;
                }
                if (f.DialogResult == DialogResult.OK)
                    this.Visible = false;
                PrepareToGame prepare2 = new PrepareToGame();
                foreach (Button obj in prepare2.Controls)
                {
                    if (obj.Name == "ButtonBack")
                    {
                        obj.Visible = false;
                        break;
                    }
                }
                prepare2.ShowDialog();

                if (prepare2.DialogResult == DialogResult.OK)
                {
                    player2 = prepare2.ReturnPlayer();
                    player2.name = f.ReturnName();
                }
                else
                    Application.Exit();
                Game game = new Game(player1, player2);
                game.ShowDialog();
                if (game.DialogResult == DialogResult.OK)
                {
                    UpdateRecords(game.ReturnWinner(), player1, player2);
                    this.Visible = true;
                }
                if (game.DialogResult == DialogResult.Cancel)
                    Application.Exit();
            }
            else
                this.Visible = true;
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Human player = new Human();
            Bot bot = new Bot();
            Name f = new Name();
            f.ShowDialog();
            if (f.DialogResult == DialogResult.Cancel)
                return;
            if (f.DialogResult == DialogResult.OK)
                this.Visible = false;
            bot.FillField();
            this.Visible = false;

            PrepareToGame prepare = new PrepareToGame();
            prepare.ShowDialog();

            if (prepare.DialogResult == DialogResult.OK)
            {
                player = prepare.ReturnPlayer();
                player.name = f.ReturnName();
                Game game = new Game(player, bot);
                game.ShowDialog();
                if (game.DialogResult == DialogResult.Cancel)
                    Application.Exit();
                if (game.DialogResult == DialogResult.OK)
                {
                    UpdateRecords(game.ReturnWinner(), player, bot);
                }
            }
            this.Visible = true;
        }