예제 #1
0
        public Multiplayer()
        {
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.multiplayer_FormClosing);
            if (Properties.Settings.Default.WindowMax)
            {
                WindowState = FormWindowState.Maximized;
            }
            if (Properties.Settings.Default.WindowLocation != null)
            {
                this.Location = Properties.Settings.Default.WindowLocation;
            }
            if (Properties.Settings.Default.WindowSize != null)
            {
                this.Size = Properties.Settings.Default.WindowSize;
            }
            this.BackgroundImage = new Bitmap(@"data\img\Texture.png");
            Bitmap color = new Bitmap(@"data\img\Colors.png");

            System.Drawing.Color color_blue = color.GetPixel(1, 1);

            mapListMenu = new MapList();

            buttonClickSnd     = new WindowsMediaPlayer();
            buttonClickSnd.URL = @"data/snd/misc/thunk.wav";

            this.Resize += new EventHandler(multiplayer_Resize);

            this.title      = new Label();
            title.Location  = new Point(this.Width / 3 - buttonX / 48, this.Height / 16);
            title.Text      = "Multi Player Game Options";
            title.AutoSize  = true;
            title.Font      = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            title.BackColor = Color.Transparent;
            title.ForeColor = Color.White;
            this.Controls.Add(title);

            this.host      = new Button();
            host.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 4);
            host.Height    = buttonY;
            host.Width     = buttonX;
            host.BackColor = color_blue;
            host.ForeColor = Color.Gold;
            host.Text      = "Host Multi Player Game";
            host.Click    += new EventHandler(mapSelect_Click);
            this.Controls.Add(host);


            this.join      = new Button();
            join.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 8 * 3);
            join.Height    = buttonY;
            join.Width     = buttonX;
            join.BackColor = color_blue;
            join.ForeColor = Color.Gold;
            join.Text      = "Join Multiplayer Game";
            join.Click    += new EventHandler(join_Click);
            this.Controls.Add(join);

            this.joinDirect      = new Button();
            joinDirect.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 4);
            joinDirect.Height    = buttonY;
            joinDirect.Width     = buttonX;
            joinDirect.BackColor = color_blue;
            joinDirect.ForeColor = Color.Gold;
            joinDirect.Text      = "Direct Connection";
            //joinDirect.Click += new EventHandler(back_Click);
            joinDirect.Hide(); // Hide the join buttons at initialization
            this.Controls.Add(joinDirect);

            this.joinServer      = new Button();
            joinServer.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 8 * 3);
            joinServer.Height    = buttonY;
            joinServer.Width     = buttonX;
            joinServer.BackColor = color_blue;
            joinServer.ForeColor = Color.Gold;
            joinServer.Text      = "Server Connection";
            joinServer.Click    += new EventHandler(joinServer_Click);
            joinServer.Hide(); // Hide the join buttons at initialization
            this.Controls.Add(joinServer);

            initServerTable();

            this.back      = new Button();
            back.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 8 * 5);
            back.Height    = buttonY;
            back.Width     = buttonX;
            back.BackColor = color_blue;
            back.ForeColor = Color.Gold;
            back.Text      = "Back";
            back.Click    += new EventHandler(back_Click);
            this.Controls.Add(back);
        }
예제 #2
0
        public MainMenu()
        {
            InitializeComponent();
            this.Size = new Size(clientx, clienty);
            ReallyCenterToScreen();
            Bitmap backGroundImage = new Bitmap(@"data\img\Texture.png");

            this.BackgroundImage = backGroundImage;
            Bitmap color = new Bitmap(@"data\img\Colors.png");
            // because the Colors size is 4 * 8, the bule is at 1, 1
            Color color_blue = color.GetPixel(1, 1);


            //Load menu music
            menuMusic     = new WMPLib.WindowsMediaPlayer();
            menuMusic.URL = @"data\snd\music\menu.mp3";
            menuMusic.settings.playCount = 999; //1 for testing, set to 999
            //menuMusic.controls.play();

            //Load button sound
            buttonClickSnd     = new WindowsMediaPlayer();
            buttonClickSnd.URL = @"data/snd/misc/thunk.wav";

            multiplayerMenu = new Login();

            mapListMenu = new MapList();

            optionsMenu = new Options();

            this.SuspendLayout();

            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainMenu_FormClosing);
            this.ResumeLayout(false);
            this.PerformLayout();



            //To handle window resize event
            this.Resize += new EventHandler(MainMenu_Resize);
            //Set background of form (But can't conenct/find path to texture for some reason)
            //this.BackgroundImage = Image.FromFile(@"data\img\Texture.png");

            /*Bitmap textureA = new Bitmap(@"data\img\Texture.png");
             * this.BackgroundImage = textureA;*/


            //Play game button
            this.playGame      = new Button();
            playGame.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 4);
            playGame.Height    = buttonY;
            playGame.Width     = buttonX;
            playGame.BackColor = color_blue;
            playGame.ForeColor = Color.Gold;
            playGame.Text      = "Single Player Game";
            //playGame.Click += new EventHandler(playGame_Click);
            playGame.Click += new EventHandler(mapSelect_Click);
            this.Controls.Add(playGame);

            //Multiplayer Menu button
            this.multiMenu      = new Button();
            multiMenu.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 8 * 3);
            multiMenu.Height    = buttonY;
            multiMenu.Width     = buttonX;
            multiMenu.BackColor = color_blue;
            multiMenu.ForeColor = Color.Gold;
            multiMenu.Text      = "Multiplayer";
            multiMenu.Click    += new EventHandler(multiMenu_Click);
            this.Controls.Add(multiMenu);

            //Map Select button

            /*
             * this.mapSelect = new Button();
             * mapSelect.Location = new Point(this.Width / 2 - buttonX / 2, this.Height /8 * 3);
             * mapSelect.Height = buttonY;
             * mapSelect.Width = buttonX;
             * mapSelect.BackColor = color_blue;
             * mapSelect.ForeColor = Color.Gold;
             * mapSelect.Text = "Select Map";
             * mapSelect.Click += new EventHandler(mapSelect_Click);
             * this.Controls.Add(mapSelect);
             */

            //Options
            this.options      = new Button();
            options.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 2);
            options.Height    = buttonY;
            options.Width     = buttonX;
            options.BackColor = color_blue;
            options.ForeColor = Color.Gold;
            options.Text      = "Options";
            options.Click    += new EventHandler(optionsSelect_Click);
            this.Controls.Add(options);

            //Exit button
            this.exitButton      = new Button();
            exitButton.Location  = new Point(this.Width / 2 - buttonX / 2, this.Height / 8 * 5);
            exitButton.Height    = buttonY;
            exitButton.Width     = buttonX;
            exitButton.BackColor = color_blue;
            exitButton.ForeColor = Color.Gold;
            exitButton.Text      = "Exit Game";
            exitButton.Click    += new EventHandler(exitButton_Click);
            this.Controls.Add(exitButton);

            Label menuName = new Label();

            menuName.Text            = "Main Menu";
            menuName.AutoSize        = true;
            menuName.Font            = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            menuName.BackgroundImage = backGroundImage;
            menuName.ForeColor       = Color.Gold;
            menuName.Anchor          = (AnchorStyles.Top);
            menuName.Location        = new Point(this.Width / 2 - 80, 10);
            this.Controls.Add(menuName);
        }