Exemplo n.º 1
0
 // Test method to create new dungeon
 private void NewDungeon()
 {
     //dungeon = null;
     gen.Generate(8);
     dungeon = gen.GetDungeon();
     dungeon.PaintAll();
     //dungeon.PlacePlayer();
 }
Exemplo n.º 2
0
        // Needs work
        /// <summary>
        /// Starts the game known as Rogue. If there is a loaded game we do not
        /// get the user name, if it is a loaded game we get the information from
        /// the loaded game and pass the health. The game ends when the player health
        /// reaches zero. The user can save and or just exit.
        /// </summary>
        /// <param name="loadedGame"></param>
        private void BeginGame(bool loadedGame = false)
        {
            NewDungeon(); // Creates the first dungeon
            if (!loadedGame)
            {
                playerName = GetUserName();
                dungeon.LoadPlayerHealth(playerHealth); // Starting Health
            }
            if (loadedGame)
            {
                dungeon.LoadPlayerHealth(playerHealth);
            }

            playerHealth = dungeon.CurrentPlayerHealth();

            dungeon.PaintAll(); // Paints first dungeon
            PrintGameInfo(playerName, score, dungeon.CurrentPlayerHealth(), level);
            stopwatch.Start();

            do
            {
                ConsoleKeyInfo userInput = Console.ReadKey(true);

                dungeon.MovePlayer(userInput.Key); // Passes the key to move the player
                PrintGameInfo(playerName, score, dungeon.CurrentPlayerHealth(), level);

                //Possible if statement that would go to new level
                //Update score method and NewDungeon method called here?
                //Test example shown below
                playerHealth = dungeon.CurrentPlayerHealth(); // Testing new level creation
                if (dungeon.atExit)
                {
                    // Needs to do all these to propely go to a new level
                    // Possible way to improve this?
                    Console.Clear();
                    NewDungeon();
                    //dungeon.PaintAll();
                    dungeon.LoadPlayerHealth(playerHealth);
                    PrintGameInfo(playerName, score, dungeon.CurrentPlayerHealth(), level);
                    Debug.Print("Got HERE!!!");
                }

                //Save and exit back to menu
                if ((userInput.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control &&
                    userInput.Key == ConsoleKey.S)
                {
                    Console.Clear();
                    // Passes information to be saved
                    fm.SaveGameToFile(playerName, score, level, dungeon.CurrentPlayerHealth());
                    GameMenu();
                    break;
                }
                //Just exit to menu
                if (userInput.Key == ConsoleKey.Escape)
                {
                    Console.Clear();
                    GameMenu();
                    break;
                }
            } while (dungeon.CurrentPlayerHealth() > 0); // While player is alive
            GameOverScreen();
        }