Esempio n. 1
0
        public HelpMenu(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont spriteFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.HelpMenu)
        {
            //Create menu item list
            string[] menuItems = { "Back to main menu"};
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                spriteFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            //Add a headline
            string headlineText = "How to play";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                headlineText,
                headlineFont.MeasureString(headlineText).X);
            _headline.Position = new Vector2(_headline.Position.X, _menuComponent.Position.Y - _headline.Height - 20);
            Components.Add(_headline);

            string text = "Mission:\n" +
                "Jump as high as you can. As you progress towards the sky, the difficulty will increase. Tip: you can bounce of the wall for that extra boost if your surroundings allow it. Good luck! \n\n" +
                "Controls:\n" +
                "Player one: W to jump, A to go left and D to go right.\n" +
                "Player two: Up key to jump, left key to go left and right key to go right.";
            _textBoxComponent = new TextBoxComponent(game,
                spriteBatch,
                spriteFont,
                text,
                game.Window.ClientBounds.Width - 200,
                10);
            Components.Add(_textBoxComponent);

            const int componentOffest = 20;

            //position the components on the screen
            _menuComponent.Position = new Vector2(_menuComponent.Position.X, _textBoxComponent.Position.Y + _textBoxComponent.Height + _menuComponent.Height + componentOffest);
            _headline.Position = new Vector2(_headline.Position.X, _textBoxComponent.Position.Y - _headline.Height - componentOffest);

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            _imageRectangle = new Rectangle(
                0,
                0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);
        }
Esempio n. 2
0
        //Constructor...
        public GameOver(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont spriteFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.GameOver)
        {
            //Add the scoreBoard
            string scoreBoardText = "Player 1: 1000";
            _scoreBoard = new TextBoxComponent(game,
                spriteBatch,
                spriteFont,
                scoreBoardText,
                spriteFont.MeasureString(scoreBoardText).X);
            Components.Add(_scoreBoard);

            //Add a headline
            string headlineText = "Game over!";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                headlineText,
                headlineFont.MeasureString(headlineText).X);
            Components.Add(_headline);

            //Create menu item list
            string[] menuItems = { "Back to main menu" };
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                spriteFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            //Fix Positions of the components
            PositionizeGameOverComponents();

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            _imageRectangle = new Rectangle(
                0,
                0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);
        }
Esempio n. 3
0
        //Constructor
        public NewHighscore(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont spriteFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.NewHighscore)
        {
            _game = game;
            _spriteFont = spriteFont;

            //Create menu item list
            string[] menuItems = { "Confirm" };
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                spriteFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            //Add a headline
            string text = "New Highscore!";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                text,
                headlineFont.MeasureString(text).X);
            Components.Add(_headline);

            string subHeadlinetext = "Write your name. When finished, press TAB to switch to next player, or ENTER to exit";
            _subHeadline = new TextBoxComponent(game,
                spriteBatch,
                _spriteFont,
                subHeadlinetext,
                DescriptionTextWidth);
            Components.Add(_subHeadline);

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            _imageRectangle = new Rectangle(
                0,
                0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);
        }
Esempio n. 4
0
        //Constructor
        public HighscoreMenu(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont spriteFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.Highscore)
        {
            //Create menu item list
            string[] menuItems = { "Back to main menu" };
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                spriteFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            //Add a headline
            const string text = "Highscore";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                text,
                headlineFont.MeasureString(text).X);
            Components.Add(_headline);

            //Add a headline
            //Dummy placeholder text to measure width of textbox component
            string highscoreContentText = "1) Magnus Sandgren : 10000";
            _highscoreContent = new TextBoxComponent(game,
                spriteBatch,
                spriteFont,
                highscoreContentText,
                spriteFont.MeasureString(highscoreContentText).X);
            Components.Add(_highscoreContent);

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            _imageRectangle = new Rectangle(
                0,
                0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);
        }
Esempio n. 5
0
        //Constructor...
        public InGameMenu(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont spriteFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.InGameMenu)
        {
            //Create menu item list
            string[] menuItems = {"Resume game", "Exit to main menu"};
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                spriteFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            string text = "Pause";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                text,
                headlineFont.MeasureString(text).X,
                0);
            _headline.Position = new Vector2(_headline.Position.X, _menuComponent.Position.Y - _headline.Height - 20);
            Components.Add(_headline);

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            const int imageWidth = 600;
            const int imageHeight = 400;
            _imageRectangle = new Rectangle(
                (Game.Window.ClientBounds.Width - imageWidth) / 2,
                (Game.Window.ClientBounds.Height - imageHeight) / 2,
                imageWidth,
                imageHeight);
        }
Esempio n. 6
0
        //Constructor...
        public MainMenu(Game game,
            SpriteBatch spriteBatch,
            string managerId,
            SpriteFont menuItemFont,
            SpriteFont headlineFont,
            Texture2D image)
            : base(game, spriteBatch, managerId, GameStates.MainMenu)
        {
            //Create menu item list
            string[] menuItems = { "Start Game", "Highscore", "Options", "Help", "End Game" };
            //Instantiate the MenuComponent
            _menuComponent = new MenuComponent(game,
                spriteBatch,
                menuItemFont,
                menuItems);
            //Add the menu to the components of the main menu screen
            Components.Add(_menuComponent);

            //Add a headline
            string text = "Main Menu";
            _headline = new TextBoxComponent(game,
                spriteBatch,
                headlineFont,
                text,
                headlineFont.MeasureString(text).X,
                50);
            _headline.Position = new Vector2(_headline.Position.X, _menuComponent.Position.Y - _headline.Height - 20);
            Components.Add(_headline);

            //Remember the image pointer for the draw method
            _image = image;
            //Create a rectangle that fills the whole window. This is for
            //drawing the background image
            _imageRectangle = new Rectangle(
                0,
                0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);
        }
Esempio n. 7
0
        public void PrepareNewHighscoreScreen(List<Score> scoreList)
        {
            _scoreList = scoreList;
            _inputBoxList = new List<InputField>();
            foreach (var score in scoreList)
            {
                var playerNameText = score.Name;
                var playerName = new TextBoxComponent(_game,
                    _spriteBatch,
                    _spriteFont,
                    playerNameText,
                    _spriteFont.MeasureString(playerNameText).X);
                Components.Add(playerName);

                var playerNameInput = new TextInputComponent(_game,
                    _spriteBatch,
                    _spriteFont,
                    Inputwidth);
                Components.Add(playerNameInput);

                _inputBoxList.Add(new InputField { InputPlayer = playerName, InputBox = playerNameInput });
            }

            _inputBoxList[0].InputBox.Selected = true;

            //Positionize the components of this screen
            PositionizeNewHighscoreComponents();
        }