Пример #1
0
 //Constructor...
 public ChoosePlayerModeManager(Game game,
     SpriteBatch spriteBatch,
     string managerId,
     SpriteFont spriteFont,
     Texture2D image)
     : base(game, spriteBatch, managerId, GameStates.ChoosePlayerModeManager)
 {
     //Create menu item list
     string[] menuItems = { "Single player", "Multiplayer (two player)", "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);
     //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);
 }
Пример #2
0
 //Constructor...
 public OptionsMenu(Game game,
     SpriteBatch spriteBatch,
     string managerId,
     SpriteFont spriteFont,
     Texture2D image)
     : base(game, spriteBatch, managerId, GameStates.Options)
 {
     //Create menu item list
     string[] menuItems = { "Option menu 1: Not yet implemented", "Option menu 2: Not yet implemented", "Option menu 3: Not yet implemented", "Option menu 4: Not yet implemented" };
     //Instantiate the MenuComponent
     _menuComponent = new MenuComponent(game,
         spriteBatch,
         spriteFont,
         menuItems);
     //Add the menu to the components of the main menu screen
     Components.Add(_menuComponent);
     //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);
 }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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);
        }