Exemplo n.º 1
0
        public HighScoreMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            this.HighScores = HighScores.GetInstance();
            HighScores.HighScoreList.Add(new Result() { PlayerName = "asd", Score = 10 });
            Rectangle labelRec = new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                Game.GraphicsDevice.Viewport.Height / 2 - 300, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT);

            label = new MenuItem(this, labelRec, LABEL_BEST_SCORES, null);

            scoresList = new ListMenuItem(this, new Vector2(label.Boundaries.Left, label.Boundaries.Bottom + 50), this.HighScores);
            scoresList = new ListMenuItem(this, new Rectangle(labelRec.X, labelRec.Y + labelRec.Height + 50, labelRec.Width, labelRec.Height * 2), this.HighScores);
        }
Exemplo n.º 2
0
        public DifficultyMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 - 300, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EASY, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Easy;
                        MenuManager.GetInstance().CurrentMenu = newScene;

                    }));
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 - 150, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), MEDIUM, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Medium;
                        MenuManager.GetInstance().CurrentMenu = newScene;
                    }));
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), HARD, (menu) =>
                    {
                        // Following line protects new menu from instantly reading previous key as pressed.
                        GameScene newScene = new GameScene(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        menu.Game.GameState.Difficulty = DifficultyLevel.Hard;
                        MenuManager.GetInstance().CurrentMenu = newScene;
                    }));
            MenuItems[currentlySelected].Selected = true;
        }
Exemplo n.º 3
0
        public SettingsMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            int start = 50;
            int pos = start;
            label = new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), LABEL_CONTROLS, null);
            pos += MENU_ITEM_HEIGHT + GAP * 2;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_UP, this.Game.Settings.Controls.Up.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_DOWN, this.Game.Settings.Controls.Down.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_LEFT, this.Game.Settings.Controls.Left.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_RIGHT, this.Game.Settings.Controls.Right.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(LEFT_MARGIN, pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT),
                String.Format("{0}: {1}", KEY_ACTION, this.Game.Settings.Controls.Action.ToString()), (menu) =>
                    {
                        ChangeKey();
                    }));

            MenuItems[currentlySelected].Selected = true;
        }
Exemplo n.º 4
0
 public ListMenuItem(MenuScene menu, Rectangle boundaries, HighScores hs)
     : base(menu, boundaries, hs.ToString(), null)
 {
     textNaturalPosition = new Vector2(inner.Left + HORIZONTAL_PADDING, inner.Top + VERTICAL_PADDING);
 }
Exemplo n.º 5
0
            public ListMenuItem(MenuScene menu, Vector2 pos, HighScores hs)
                : base(menu)
            {
                this.Text = hs.ToString();
                textDim = font.MeasureString(this.Text);

                outer = new Rectangle((int)pos.X, (int)pos.Y, (int)(textDim.X + 2 * HORIZONTAL_PADDING), (int)(textDim.Y + 2 * VERTICAL_PADDING));
                inner = new Rectangle(outer.Left + BORDER, outer.Top + BORDER, outer.Width - 2 * BORDER, outer.Height - 2 * BORDER);

                textNaturalPosition = new Vector2(inner.Left + HORIZONTAL_PADDING, inner.Top + VERTICAL_PADDING);
            }
Exemplo n.º 6
0
        public PauseMenu(MinerGame game, MenuScene previous)
            : base(game, previous)
        {
            int start = -400;
            int pos = start;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), RESUME, (menu) =>
                    {
                        this.GoBack();
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), SAVE_GAME, (menu) =>
                    {
                        using (FileStream fs = new FileStream("save1.xml", FileMode.Create))
                        {
                            XmlSerializer xml = new XmlSerializer(typeof(GameState));
                            xml.Serialize(fs, this.Game.GameState);
                        }
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), LOAD_GAME, (menu) =>
                    {
                        System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();

                        if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            try
                            {
                                this.Game.Content.Unload();

                                using (Stream stream = openFile.OpenFile())
                                {
                                    XmlSerializer xml = new XmlSerializer(typeof(GameState));
                                    this.Game.GameState = (GameState)xml.Deserialize(stream);
                                    this.Game.GameState.Miner.Suit = new Nanosuit();
                                    stream.Close();
                                }

                                this.Game.GameState.Miner.game = this.Game;

                                foreach (var item in this.Game.GameState.Enemies)
                                {
                                    item.game = this.Game;
                                }

                                foreach (var item in this.Game.GameState.Bullets)
                                {
                                    item.game = this.Game;
                                }

                                this.Game.Content.Load<SpriteFont>("general");
                                this.Game.Content.Load<Texture2D>(Kosmojopek.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Ufolowca.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(WladcaLaserowejDzidy.ASSET_NAME);
                                //this.Content.Load<Texture2D>(PoteznySultan.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Miner.ASSET_NAME);
                                //this.Content.Load<Texture2D>(CosmicMatter.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(DoubleJump.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Field.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Fuel.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Indestructibility.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Key.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(KeyLocalizer.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Laser.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(MoreEnemies.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(SolidRock.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(SpaceGate.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(TitanRock.ASSET_NAME);
                                this.Game.Content.Load<Texture2D>(Bullet.ASSET_NAME);

                                this.Game.GameState.Miner.LoadContent();

                                foreach (var item in this.Game.GameState.Enemies)
                                {
                                    item.LoadContent();
                                }

                                foreach (var item in this.Game.GameState.Bullets)
                                {
                                    item.LoadContent();
                                }

                                foreach (var item in this.Game.GameState.Map.Fields)
                                {
                                    foreach (var field in item)
                                    {
                                        field.game = this.Game;
                                        field.LoadContent();
                                    }
                                }

                                GameScene newScene = new GameScene(this.Game)
                                {
                                    OldKeyState = this.CurrentKeyState
                                };
                                MenuManager.GetInstance().CurrentMenu = newScene;
                            }
                            catch (Exception exc)
                            {
                                System.Windows.Forms.MessageBox.Show(ERROR_READING_FILE + exc.Message);
                            }
                        }
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), INSTRUCTIONS, (menu) =>
                    {

                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), SETTINGS, (menu) =>
                    {
                        SettingsMenu newMenu = new SettingsMenu(this.Game, this)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        MenuManager.GetInstance().CurrentMenu = newMenu;
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EXIT_MAIN_MENU, (menu) =>
                    {
                        MainMenu newMenu = new MainMenu(this.Game)
                        {
                            OldKeyState = this.CurrentKeyState
                        };
                        MenuManager.GetInstance().CurrentMenu = newMenu;
                    }));
            pos += MENU_ITEM_HEIGHT + GAP;
            MenuItems.Add(new MenuItem(this, new Rectangle(Game.GraphicsDevice.Viewport.Width / 2 - MENU_ITEM_WIDTH / 2,
                    Game.GraphicsDevice.Viewport.Height / 2 + pos, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT), EXIT_GAME, (menu) =>
                    {
                        menu.Game.ExitGame();
                    }));
            MenuItems[currentlySelected].Selected = true;
        }
Exemplo n.º 7
0
 public MenuScene(MinerGame game, MenuScene previous)
     : this(game)
 {
     previousMenu = previous;
 }