Пример #1
0
        public JoinNetworkGameScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D background)
            : base(game, spriteBatch)
        {
            this.background = background;
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            Vector2 formSize = new Vector2(350, 350);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);
            connectionMethodForm = new Form("Connect", "Connection Metod", new Rectangle((int)center.X, (int)center.Y,(int) formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);

            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");
            textboxTexture = game.Content.Load<Texture2D>("textboxTexture");

            //figure out the width and heigh of the text on the buttons
            Vector2 lanButtonSize, connectButtonSize;
            lanButtonSize = spriteFont.MeasureString("Scan Lan");
            connectButtonSize = spriteFont.MeasureString("Connect");
            lanButton = new Button("ScanLan", "Scan LAN", new Rectangle(32,30,(int)lanButtonSize.X + 10, (int)lanButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            sendButton = new Button("Connect", "Connect", new Rectangle(32,151,(int)connectButtonSize.X + 10, (int)connectButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(32, 192, 95, 23), buttonTexture, spriteFont, Color.White);
            textBoxIP = new TextBox("Address", "",100,new Rectangle(32,110,232,20), textboxTexture, spriteFont, Color.Black);
            textBoxPort = new TextBox("Port", "", 8, new Rectangle(288,110,60,20), textboxTexture, spriteFont, Color.Black);

            connectionMethodForm.AddControl(lanButton);
            connectionMethodForm.AddControl(sendButton);
            connectionMethodForm.AddControl(backButton);
            connectionMethodForm.AddControl(textBoxIP);
            connectionMethodForm.AddControl(textBoxPort);

            lanButton.onClick += new EHandler(ButtonClick);
            sendButton.onClick += new EHandler(ButtonClick);
            backButton.onClick += new EHandler(ButtonClick);

            imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
        }
Пример #2
0
        public NetworkGameSelectScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D backgorund)
            : base(game, spriteBatch)
        {
            Vector2 formSize = new Vector2(150, 200);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");

            networkGameTypeSelectForm = new Form("GameTypeMenu", "Network Game", new Rectangle((int)center.X, (int)center.Y, (int)formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(27, 132, 95, 23), buttonTexture, spriteFont, Color.White);
            joinGameButton = new Button("JoinGame", @"Join Game", new Rectangle(27, 90, 95, 23), buttonTexture, spriteFont, Color.White);
            hostGameButton = new Button("HostGame", @"Host Game", new Rectangle(27, 42, 95, 23), buttonTexture, spriteFont, Color.White);

            networkGameTypeSelectForm.AddControl(hostGameButton);
            networkGameTypeSelectForm.AddControl(joinGameButton);
            networkGameTypeSelectForm.AddControl(backButton);

            hostGameButton.onClick  += new EHandler(ButtonClick);
            joinGameButton.onClick  += new EHandler(ButtonClick);
            backButton.onClick      += new EHandler(ButtonClick);
        }
Пример #3
0
        public HostNetworkGameScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Texture2D background)
            : base(game, spriteBatch)
        {
            this.background = background;
            formBackground = game.Content.Load<Texture2D>("alienmetal");
            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");
            textboxTexture = game.Content.Load<Texture2D>("textboxTexture");

            //center the form ont he screen
            Rectangle center = this.CenterGUIForm(242, 224);
            hostGameForm = new Form("Host", "Host a Game", new Rectangle(center.X, center.Y, center.Width, center.Height), formBackground, spriteFont, Color.White);

            //figure out the width and heigh of the text on the buttons
            Vector2 startButtonSize, backButtonSize;
            startButtonSize = spriteFont.MeasureString("Start Game");
            backButtonSize = spriteFont.MeasureString("Back");

            startButton = new Button("Start", "Start Game", new Rectangle(6, 186, (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);
            backButton = new Button("BackButton", @"Back", new Rectangle(132, 186,  (int)startButtonSize.X + 10, (int)startButtonSize.Y + 10), buttonTexture, spriteFont, Color.White);

            textBoxMaxConnections = new TextBox("MaxConnections", "10", 100, new Rectangle(11, 42, 60, 20), textboxTexture, spriteFont, Color.Black);
            maxConnectionsLabel = new Label("maxConnectionsLabel", @"Max Connections", new Vector2(8, 26), spriteFont, Color.White, 0, 0);

            textBoxPort = new TextBox("Port", "14242", 8, new Rectangle(11, 116, 60, 20), textboxTexture, spriteFont, Color.Black);
            portLabel = new Label("portLabel", @"Port", new Vector2(8, 91), spriteFont, Color.White, 0, 0);

            hostGameForm.AddControl(startButton);
            hostGameForm.AddControl(backButton);
            hostGameForm.AddControl(textBoxMaxConnections);
            hostGameForm.AddControl(maxConnectionsLabel);
            hostGameForm.AddControl(textBoxPort);
            hostGameForm.AddControl(portLabel);

            startButton.onClick += new EHandler(ButtonClick);
            backButton.onClick += new EHandler(ButtonClick);

            imageRectangle = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height);
        }
Пример #4
0
        public StartScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont)
            : base(game, spriteBatch)
        {
            //screenSize = game.GraphicsDevice.Viewport.Bounds;
            //TAKE THE WIDTH AND HEIGHT MINUS THE MAIN FORM WIDTH AND HEIGHT DIVEDED BY 2 TO GET CENTER ON X AND Y
            Vector2 formSize = new Vector2(150, 200);
            Vector2 center = new Vector2((this.windowSize.Width - formSize.X) / 2, (this.windowSize.Height - formSize.Y) / 2);

            formBackground = game.Content.Load<Texture2D>("alienmetal");
            buttonTexture = game.Content.Load<Texture2D>("buttonTexture");

            mainMenuForm = new Form("MainMenu", "Main Menu", new Rectangle((int)center.X, (int)center.Y, (int)formSize.X, (int)formSize.Y), formBackground, spriteFont, Color.White);
            quitGameButton = new Button("QuitGame", @"Quit Game", new Rectangle(27, 132, 95, 23), buttonTexture, spriteFont, Color.White);
            networkGameButton = new Button("NetworkGame", @"Network Game",new Rectangle(27, 90, 95, 23), buttonTexture, spriteFont, Color.White);
            startGameButton = new Button("StartGame", @"Start Game", new Rectangle(27, 42, 95, 23), buttonTexture, spriteFont, Color.White);

            mainMenuForm.AddControl(startGameButton);
            mainMenuForm.AddControl(networkGameButton);
            mainMenuForm.AddControl(quitGameButton);

            startGameButton.onClick += new EHandler(ButtonClick);
            networkGameButton.onClick += new EHandler(ButtonClick);
            quitGameButton.onClick += new EHandler(ButtonClick);
        }
Пример #5
0
        protected override void LoadContent()
        {
            base.LoadContent();
            Texture2D txtButton = game.Content.Load<Texture2D>(@"GUI\texButton");
            Texture2D txtTextBox = game.Content.Load<Texture2D>(@"GUI\texTextBox");
            Texture2D txtForm = game.Content.Load<Texture2D>(@"GUI\texForm");
            lvlLoadForm = new Form("LoadForm", "levels: 0 - 20 ",
                new Rectangle((Game.Window.ClientBounds.Width / 2 - 75), (Game.Window.ClientBounds.Height / 2 - 45),
                    150, 90), txtForm, spriteFont, Color.Black);
            txtLevelSelect = new TextBox("level", " ", 2, "0123456789-.", new Rectangle(10, 10, 50, 30), txtTextBox, spriteFont, Color.Black);
            exitButton = new Button("Exit", "Exit", new Rectangle(75,60,60,20), txtButton, spriteFont, Color.Black);
            loadButton = new Button("Load", "Load", new Rectangle(10, 60, 60, 20), txtButton, spriteFont, Color.Black);

            lvlLoadForm.AddControl(txtLevelSelect);
            lvlLoadForm.AddControl(exitButton);
            lvlLoadForm.AddControl(loadButton);

            loadButton.onClick += new EHandler(LoadButtonClicked);
        }
Пример #6
0
 public void NewForm()
 {
     Frm = new Form("MyForm", "",
         new Rectangle((int)Position.X, (int)Position.Y, (int)Width, (int)Height),
         PanelTexture, Font, Color.Black);
 }
Пример #7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            ButtonTexture = Game.Content.Load<Texture2D>("texButton");
            TextBoxTexture = Game.Content.Load<Texture2D>("texTextBox");
            PanelTexture = Game.Content.Load<Texture2D>("texForm");
            Font = Game.Content.Load<SpriteFont>("Arial");
            Frm = new Form("MyForm", "",
                new Rectangle(Position.X, Position.Y, Width, Height),
                PanelTexture, Font, Color.Black);
        }