public GameRestartScreen(Game game, MenuItem[] items) : base(game)
 {
     restartMenu = new Menu[items.Length];
     for (int i = 0; i < items.Length; i++)
     {
         restartMenu[i] = new Menu(items[i], GameSettings.menuColor);
     }
     restartMenu[0].MenuColor = GameSettings.activeColor;
 }
 public MenuScreen(Game game, MenuItem[] items, Texture2D background, Rectangle backgroundRect) : base(game)
 {
     menuBackground = background;
     menuGameName = items[3];
     menuBackgroundR = backgroundRect;
     menu = new Menu[3];
     menu[0] = new Menu(items[0], GameSettings.activeColor);
     menu[1] = new Menu(items[1], GameSettings.menuColor);
     menu[2] = new Menu(items[2], GameSettings.menuColor);
 }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            var scorpionDictionary = DictionaryLoader.GetDictionary(GameSettings.firstName, Content);
            var subZeroDictionary = DictionaryLoader.GetDictionary(GameSettings.secondName, Content);
            var firstHealth = new HealthBar(GameSettings.HealthBar, Content.Load<Texture2D>("DamageBar"));
            var secondHealth = new HealthBar(new Vector2(width - GameSettings.HealthBar.X, GameSettings.HealthBar.Y), Content.Load<Texture2D>("DamageBar"));
            var firstMoves = new PlayerControls();
            firstMoves.GetFirstPlayerKeyboard();
            var secondMoves = new PlayerControls();
            secondMoves.GetSecondPlayerKeyboard();
            
            //first player
            var firstSprite = new SpriteAnimation(GameSettings.SpriteWidth, GameSettings.SpriteHeigth, false)
            {
                SpriteTexture = scorpionDictionary,
                Moves = firstMoves,
                Position = new Vector2(GameSettings.FirstPosition.X - 100, GameSettings.FirstPosition.Y)
            };

            //second player
            var secondSprite = new SpriteAnimation(GameSettings.SpriteWidth, GameSettings.SpriteHeigth, true)
            {
                SpriteTexture = subZeroDictionary,
                Moves = secondMoves,
                Position = new Vector2(GameSettings.FirstPosition.X + 100, GameSettings.FirstPosition.Y)
            };

            //game screen
            var arenaRect = new Rectangle(0, 0, graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width, graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height);
            var arenaTexture = Content.Load<Texture2D>("Arenas//TheDeadPoolArena");
            gameScreen = new GameScreen(this, Content.Load<SpriteFont>("Pristina"), Content.Load<SpriteFont>("Courier New"), width, arenaTexture, arenaRect)
            {
                FirstSprite = firstSprite,
                FirstHealthBar = firstHealth,

                SecondSprite = secondSprite,
                SecondHealthBar = secondHealth,
            };

            //menu screen
            var font = Content.Load<SpriteFont>("Narkisim");
            var gameNameItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width/2, 100),
                MenuItemName = "Mortal Kombat",
                MenuItemOrigin = font.MeasureString("Mortal Kombat")/2
            };
            font = Content.Load<SpriteFont>("Viner Hand ITC");
            var startItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 300),
                MenuItemName = "New game",
                MenuItemOrigin = font.MeasureString("New game") / 2
            };
            var helpItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 400),
                MenuItemName = "Help",
                MenuItemOrigin = font.MeasureString("Help") / 2
            };
            var exitItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 500),
                MenuItemName = "Exit",
                MenuItemOrigin = font.MeasureString("Exit") / 2
            };
            var menuItems = new MenuItem[]
            {
                startItem,
                helpItem,
                exitItem,
                gameNameItem
            };
            var texture = Content.Load<Texture2D>("BackgroundMenu");
            var rect = new Rectangle(0, 0, graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width,
                graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height);
            menuScreen = new MenuScreen(this, menuItems, texture, rect);

            //help screen
            helpScreen = new HelpScreen(this, texture, rect, Content.Load<SpriteFont>("Courier new"), Content.Load<SpriteFont>("Viner Hand ITC"), firstMoves, secondMoves);

            //game pause screen
            font = Content.Load<SpriteFont>("Viner Hand ITC");
            var resumeItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 300),
                MenuItemName = "Resume",
                MenuItemOrigin = font.MeasureString("Resume") / 2
            };
            exitItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 400),
                MenuItemName = "Exit",
                MenuItemOrigin = font.MeasureString("Exit") / 2
            };
            menuItems = new MenuItem[]
            {
                resumeItem,
                exitItem
            };
            gamePauseScreen = new GamePauseScreen(this, menuItems);

            //game restart screen
            font = Content.Load<SpriteFont>("Viner Hand ITC");
            var restartItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 300),
                MenuItemName = "New game",
                MenuItemOrigin = font.MeasureString("New game") / 2
            };
            exitItem = new MenuItem
            {
                MenuFont = font,
                MenuItemPosition = new Vector2(width / 2, 400),
                MenuItemName = "Exit",
                MenuItemOrigin = font.MeasureString("Exit") / 2
            };
            menuItems = new MenuItem[]
            {
                restartItem,
                exitItem
            };
            gameRestartScreen = new GameRestartScreen(this, menuItems);

            Components.Add(menuScreen);
            Components.Add(gameScreen);
            Components.Add(helpScreen);
            Components.Add(gamePauseScreen);
            Components.Add(gameRestartScreen);
            menuScreen.Show();
        }
Пример #4
0
 public Menu(MenuItem item, Color color)
 {
     Item = item;
     MenuColor = color;
 }