public override void Dispose()
 {
     this.entity = null;
     this.checkPoint = null;
     this.dtoGameTime = null;
     this.timeToCompleteMaze = null;
     this.mapExamMenu = null;
     this.pauseMenu = null;
     this.gameOverMenu = null;
     this.gameOverData = null;
     this.TotalGameTime = null;
     this.UserProfie = null;
     this.Walls = null;
     this.Weapons = null;
     base.Dispose();
 }
Beispiel #2
0
        private Menu CreateMainMenu()
        {
            TextButton play = new TextButton("Menus/Buttons/button", new Rectangle(100, 100, 125, 25));
            play.ClickedAction = () => { ActivateMenu("Game Selection"); };
            play.Color = Color.GhostWhite;
            play.Text.Font = Load.LoadFont("Fonts/font");
            play.Text.Color = Color.Red;
            play.Text.Position = new Vector2(play.Rectangle.X, play.Rectangle.Y);
            play.Text.Visible = true;
            play.Text.Text.Append("P L A Y");
            play.AddText();

            TextButton exit = new TextButton("Menus/Buttons/button", new Rectangle(100, 130, 125, 25));
            exit.ClickedAction = ExitGame;
            exit.Color = Color.GhostWhite;
            exit.Text.Font = Load.LoadFont("Fonts/font");
            exit.Text.Color = Color.Red;
            exit.Text.Position = new Vector2(exit.Rectangle.X, exit.Rectangle.Y);
            exit.Text.Visible = true;
            exit.Text.Text.Append("Q U I T");
            exit.AddText();

            BasicMenu menu = new BasicMenu("Menus/Backgrounds/background",
                                            new Rectangle(0, 0, displayWidth, displayHeight), "Main Menu");
            menu.Color = Color.Plum;
            menu.TextButtons.Add(play);
            menu.TextButtons.Add(exit);

            return menu;
        }
        private void Reset()
        {
            TotalGameTime.SetTime(TimeSpan.Zero);
            timeToCompleteMaze.SetTime(TimeSpan.Zero);
            camController.ScrollToBegening();
            camController.ScrollToTop();
            entity.UpdatePosition(110, 0);
            map.RemoveItem(checkPointCoordinates);
            PositionCheckPoint();
            score = 0;

            gameOverData.ClearData();
            gameOverData = null;
            gameOverMenu = null;
            this.Gamestate = GameState.Playing;
        }
        private void CheckForPause(IKeyboardMouse input)
        {
            KeyboardState keys = input.GameKeys;
            KeyboardState oldKeys = input.OldKeys;

            if (keys.IsKeyDown(Keys.P) &&
                oldKeys.IsKeyUp(Keys.P))
                this.Gamestate = GameState.Paused;

            pauseMenu = (BasicMenu)CreatePauseMenu();
        }
        protected override void EndGame()
        {
            if (Gamestate == GameState.Paused)
            {
                gameOverMenu = (BasicMenu)CreateGameOverMenu();

                gameOverMenu.TextButtons.Remove(
                    gameOverMenu.TextButtons
                    .Where(b => b.Name == "Play Again")
                    .First());

                SetFinalGameData();

                gameOverData.TimeScore.Text.
                    Clear().Append("No Score");

                gameOverData.TotalScore.Text.
                    Clear().Append("No Score");
            }
            else
            {
                gameOverMenu = (BasicMenu)CreateGameOverMenu();
                SetFinalGameData();
            }

            this.Gamestate = GameState.GameOver;
        }
        protected override Menu CreatePauseMenu()
        {
            Menu menu;

            TextButton resume =
                new TextButton("Menus/Buttons/Button", new Rectangle(100, 100, 125, 25));
            resume.ClickedAction = () => {
                Gamestate = GameState.Playing;
                    pauseMenu = null;
            };
            resume.Text.Text.Append("R E S U M E");
            resume.Text.Position = new Vector2(resume.X_Coordinate, resume.Y_Coordinate);
            resume.Text.Font = Load.LoadFont("Fonts/font");
            resume.Text.Color = Color.SeaGreen;
            resume.Text.Visible = true;
            resume.AddText();

            TextButton examine =
                new TextButton("Menus/Buttons/Button", new Rectangle(100, 130, 125, 25));
            examine.ClickedAction = () =>
            {
                mapExamMenu = (BasicMenu)CreateMapExamMenu();
                examineMap = true;
                camCol = camera.StartCol;
                camRow = camera.StartRow;
            };
            examine.Text.Text.Append("E X A M I N E M A P");
            examine.Text.Position = new Vector2(examine.X_Coordinate, examine.Y_Coordinate);
            examine.Text.Font = Load.LoadFont("Fonts/font");
            examine.Text.Color = Color.SeaGreen;
            examine.Text.Visible = true;
            examine.AddText();

            TextButton quitgame =
                new TextButton("Menus/Buttons/Button", new Rectangle(100, 160, 125, 25));
            quitgame.ClickedAction = EndGame;
            quitgame.Text.Text.Append("Q U I T");
            quitgame.Text.Position = new Vector2(quitgame.X_Coordinate, quitgame.Y_Coordinate);
            quitgame.Text.Font = Load.LoadFont("Fonts/font");
            quitgame.Text.Color = Color.SeaGreen;
            quitgame.Text.Visible = true;
            quitgame.AddText();

            List<TextButton> menuButtons =
                new List<TextButton>() { resume, examine, quitgame };
            menu = new BasicMenu("Graphics/background", new Rectangle(0, 0, Width, Height),
                                 "Pause", textButtons: menuButtons);
            menu.Color = Color.Magenta;
            return menu;
        }
        protected override Menu CreateGameOverMenu()
        {
            Menu gameOverMenu;
            TextButton
            playAgain = new TextButton("Menus/Buttons/button", new Rectangle(540, 400, 100, 25));
            playAgain.Name = "Play Again";
            playAgain.ClickedAction = Reset;
            playAgain.Text.Position = new Vector2(playAgain.Rectangle.X, playAgain.Rectangle.Y);
            playAgain.Text.Font = Load.LoadFont("Fonts/Font");
            playAgain.Text.Color = Color.Black;
            playAgain.Text.Text.Append("Play Again");
            playAgain.Text.Visible = true;
            playAgain.AddText();

            TextButton
            mainMenu = new TextButton("Menus/Buttons/button", new Rectangle(650, 400, 100, 25));
            mainMenu.Name = "Main Menu";
            mainMenu.ClickedAction = () => { gameHost.MazeGameEnded(); };
            mainMenu.Text.Position = new Vector2(mainMenu.Rectangle.X, mainMenu.Rectangle.Y);
            mainMenu.Text.Font = Load.LoadFont("Fonts/Font");
            mainMenu.Text.Color = Color.Black;
            mainMenu.Text.Text.Append("Main Menu");
            mainMenu.Text.Visible = true;
            mainMenu.AddText();

               List<TextButton> gameOverNavButtons = new List<TextButton>()
            {
                playAgain, mainMenu
            };

            gameOverMenu = new BasicMenu("Menus/Backgrounds/background",
                new Rectangle(0, 0, Width, Height),"Game Over", textButtons: gameOverNavButtons);
            gameOverMenu.Color = Color.PaleVioletRed;

            return gameOverMenu;
        }