Beispiel #1
0
        /// <summary>
        /// Init level without zombies
        /// </summary>
        public static void LoadNewLevel(Map level)
        {
            CurrentLevel  = level;
            ReloadedLevel = level.Clone() as Map;

            if (player == null) // if player is not created; deep in levels
            {
                player = new Hero(0, 0, InitialLives);
            }
            Redraw();
            PositionHero(player);
            // add enemies as well

            Run();
            if (player.Lives > 0)
            {
                return;
            }

            Program.PlaySound("../../sounds/game-over.wav"); //Game over sound

            Console.SetCursorPosition(52, 18);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("GAME OVER");

            GameMenu.EndingGame();
        }
        private static void GameSuccessfullyCompletedEnding()
        {
            Console.Clear();

            Program.PlaySound("../../sounds/game-completed.wav");

            try
            {
                StreamReader gameEnding = new StreamReader("../../LogoGame/GameEnding.txt", Encoding.GetEncoding("UTF-8"));

                using (gameEnding)
                {
                    string endingText = gameEnding.ReadToEnd();

                    Console.SetCursorPosition(0, 0);
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine(endingText);

                    GameMenu.EndingGame();
                }
            }
            catch (FileNotFoundException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The file specified in path was not found.");
            }
            catch (DirectoryNotFoundException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The specified path is invalid (for example, it is on an unmapped drive).");
            }
            catch (ArgumentNullException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The given path is NULL\n and some method received a null argument!");
            }
            catch (ArgumentException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Path is a zero-length string, contains only white space, or contains one or more invalid characters.");
            }
            catch (PathTooLongException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(" The specified path, file name, or both exceed\n the system-defined maximum length." +
                                  "Path must be\n less than 248 characters, and file names\n must be less than 260 characters.");
            }
            catch (NotSupportedException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The given path is in an invalid format.");
            }
            catch (UnauthorizedAccessException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("UnauthorizedAccesException detected! The reasons may be the following:\n" +
                                  " - Path specified a file that is read-only.\n - This operation is not supported on the current platform.\n" +
                                  " - The caller does not have the required permission.");
            }
            catch (SecurityException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Sorry, but you does not have the required permission.");
            }
            catch (IOException)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("An I/O (Input/Output) error occurred while opening the file.");
            }
        }