public GameOverScreen(int size, int playersCount, int realPlayersCount, List <string> playersNames, string winnerName, bool draw)
        {
            SoundPlayer buttonClick    = new SoundPlayer(Properties.Resources.button_click);
            var         exitMenuButton = new Button();
            var         newGameButton  = new Button();
            var         label          = new Label();

            this.AutoScaleMode   = AutoScaleMode.None;
            this.BackColor       = Color.FromArgb(237, 238, 240);
            this.ClientSize      = new Size(1200, 600);
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.MinimumSize     = new Size(400, 200);
            this.MaximumSize     = new Size(400, 200);
            this.FormBorderStyle = FormBorderStyle.None;

            label.Location = new Point(0, 0);
            label.Size     = new Size(400, 100);
            label.Text     = "Game Over\n" + winnerName + " - win!";
            if (draw == true)
            {
                label.Text = "Game Over\nDraw";
            }
            label.BackColor = Color.FromArgb(237, 238, 240);
            label.Font      = new Font("MV Boli", 20.00F);
            label.TextAlign = ContentAlignment.BottomCenter;

            newGameButton.Anchor          = AnchorStyles.Left;
            newGameButton.AutoSizeMode    = AutoSizeMode.GrowAndShrink;
            newGameButton.Cursor          = Cursors.Hand;
            newGameButton.FlatStyle       = FlatStyle.Popup;
            newGameButton.Font            = new Font("MV Boli", 20.25F);
            newGameButton.ImageAlign      = ContentAlignment.BottomCenter;
            newGameButton.Location        = new Point(230, 100);
            newGameButton.Text            = "New";
            newGameButton.Size            = new Size(100, 50);
            newGameButton.BackgroundImage = Properties.Resources.exit_button;
            newGameButton.Click          += (sender, args) =>
            {
                buttonClick.Play();
                Thread.Sleep(150);
                this.Hide();
                GameScreen gameScreen = new GameScreen(size, playersCount, realPlayersCount, playersNames);
                gameScreen.Show();
            };

            exitMenuButton.Anchor       = AnchorStyles.Left;
            exitMenuButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            exitMenuButton.Cursor       = Cursors.Hand;
            exitMenuButton.FlatStyle    = FlatStyle.Popup;
            exitMenuButton.Font         = new Font("MV Boli", 20.25F);
            exitMenuButton.BackColor    = Color.FromArgb(74, 118, 168);
            exitMenuButton.ForeColor    = Color.FromArgb(0, 0, 0);
            exitMenuButton.ImageAlign   = ContentAlignment.BottomCenter;
            exitMenuButton.Location     = new Point(70, 100);
            exitMenuButton.Text         = "Menu";
            exitMenuButton.Size         = new Size(100, 50);
            exitMenuButton.Click       += (sender, args) =>
            {
                buttonClick.Play();
                Thread.Sleep(150);
                this.Hide();
                var mainMenu = new MainScreen(size, playersCount, realPlayersCount);
                mainMenu.Show();
            };

            Controls.Add(newGameButton);
            Controls.Add(label);
            Controls.Add(exitMenuButton);
        }
Beispiel #2
0
        public GameScreen(int size, int playersCount, int realPlayersCount, List <string> playersNames)
        {
            this.Size = (int)Math.Sqrt(Math.Pow((double)(playersCount + 1), (double)playersCount));
            this.game = new Core.Game(playersNames, playersCount, realPlayersCount);
            this.game.StartLevel(this.Size, this.Size, playersCount + 1);
            SoundPlayer gameMedia   = new SoundPlayer(Properties.Resources.bensound_punky);
            SoundPlayer buttonClick = new SoundPlayer(Properties.Resources.button_click);

            gameMedia.PlayLooping();
            var exitButton = new Button();

            table           = new TableLayoutPanel();
            table.BackColor = Color.FromArgb(173, 216, 230);
            table.Location  = new Point(2, 2);
            table.Size      = new Size(76 * this.Size, 76 * this.Size);
            for (int i = 0; i < this.Size; i++)
            {
                table.RowStyles.Add(new RowStyle(SizeType.Percent, 100f / this.Size));
                table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f / this.Size));
            }
            for (int column = 0; column < this.Size; column++)
            {
                for (int row = 0; row < this.Size; row++)
                {
                    var button = new Button();
                    button.BackColor = Color.FromArgb(255, 255, 255);
                    button.Size      = new Size(66, 66);
                    button.FlatStyle = FlatStyle.Standard;
                    button.Click    += (senders, args) =>
                    {
                        var position = table.GetCellPosition((Control)senders);
                        this.game.CurrentLevel.MakeMove(position.Column, position.Row);
                        this.Map = this.game.CurrentLevel.Map;
                        ChangeMap();
                        if (!(this.game.CurrentLevel.Winner == null) || this.game.CurrentLevel.IsDraw == true)
                        {
                            string winnerName = "";
                            var    draw       = this.game.CurrentLevel.IsDraw;
                            if (!(this.game.CurrentLevel.Winner == null))
                            {
                                winnerName = game.CurrentLevel.Winner.Name;
                            }
                            this.Hide();
                            gameMedia.Stop();
                            GameOverScreen gameOver = new GameOverScreen(size, playersCount, realPlayersCount, playersNames, winnerName, draw);
                            gameOver.Show();
                        }
                    };
                    table.Controls.Add(button, column, row);
                }
            }


            // Game Screen Settins
            this.AutoScaleMode   = AutoScaleMode.None;
            this.BackColor       = Color.FromArgb(173, 216, 230);
            this.ClientSize      = new Size(76 * this.Size, 76 * this.Size + 60);
            this.MinimumSize     = new Size(76 * this.Size, 76 * this.Size + 60);
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.None;

            exitButton.Anchor       = AnchorStyles.Left;
            exitButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            exitButton.Cursor       = Cursors.Hand;
            exitButton.FlatStyle    = FlatStyle.Popup;
            exitButton.Font         = new Font("MV Boli", 20.25F);
            exitButton.BackColor    = Color.FromArgb(74, 118, 168);
            exitButton.ForeColor    = Color.FromArgb(0, 0, 0);
            exitButton.ImageAlign   = ContentAlignment.BottomCenter;
            exitButton.Location     = new Point(ClientSize.Width / 2 - 90, ClientSize.Height - 50);
            exitButton.Text         = "Main Menu";
            exitButton.Size         = new Size(180, 40);
            exitButton.Click       += (sender, args) =>
            {
                buttonClick.Play();
                Thread.Sleep(150);
                gameMedia.Stop();
                this.Hide();
                var mainScreen = new MainScreen(this.Size, playersCount, realPlayersCount);
                mainScreen.Show();
            };

            Controls.Add(table);
            Controls.Add(exitButton);
        }
Beispiel #3
0
        public ExitScreen()
        {
            SoundPlayer buttonClick  = new SoundPlayer(Properties.Resources.button_click);
            var         cancelButton = new Button();
            var         exitButton   = new Button();
            var         label        = new Label();

            this.AutoScaleMode   = AutoScaleMode.None;
            this.BackColor       = Color.FromArgb(237, 238, 240);
            this.ClientSize      = new Size(1200, 600);
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.MinimumSize     = new Size(400, 200);
            this.MaximumSize     = new Size(400, 200);
            this.FormBorderStyle = FormBorderStyle.None;

            label.Location  = new Point(0, 20);
            label.Size      = new Size(400, 100);
            label.Text      = "Are you sure, you want to exit?";
            label.BackColor = Color.FromArgb(237, 238, 240);
            label.Font      = new Font("MV Boli", 20.00F);
            label.TextAlign = ContentAlignment.BottomCenter;

            exitButton.Anchor       = AnchorStyles.Left;
            exitButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            exitButton.Cursor       = Cursors.Hand;
            exitButton.FlatStyle    = FlatStyle.Popup;
            exitButton.Font         = new Font("MV Boli", 20.25F);
            exitButton.BackColor    = Color.FromArgb(74, 118, 168);
            exitButton.ForeColor    = Color.FromArgb(0, 0, 0);
            exitButton.ImageAlign   = ContentAlignment.BottomCenter;
            exitButton.Location     = new Point(70, 100);
            exitButton.Text         = "Yes";
            exitButton.Size         = new Size(100, 50);
            exitButton.Click       += (sender, args) =>
            {
                buttonClick.Play();
                Thread.Sleep(150);
                Application.Exit();
            };

            cancelButton.Anchor       = AnchorStyles.Left;
            cancelButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            cancelButton.Cursor       = Cursors.Hand;
            cancelButton.FlatStyle    = FlatStyle.Popup;
            cancelButton.Font         = new Font("MV Boli", 20.25F);
            cancelButton.BackColor    = Color.FromArgb(74, 118, 168);
            cancelButton.ForeColor    = Color.FromArgb(0, 0, 0);
            cancelButton.ImageAlign   = ContentAlignment.BottomCenter;
            cancelButton.Location     = new Point(230, 100);
            cancelButton.Text         = "No";
            cancelButton.Size         = new Size(100, 50);
            cancelButton.Click       += (sender, args) =>
            {
                buttonClick.Play();
                Thread.Sleep(150);
                this.Hide();
                var mainMenu = new MainScreen(5, 3, 3);
                mainMenu.Show();
            };

            Controls.Add(label);
            Controls.Add(cancelButton);
            Controls.Add(exitButton);
        }