Exemple #1
0
    public static void AskUserToRestartLevelOne(IWavePlayer waveOutDevice, AudioFileReader audioFileReader)
    {
        waveOutDevice.Stop();
        Console.Clear();

        Console.SetCursorPosition(5, 15);
        Console.Write("Do you want to RESTART?");
        Console.SetCursorPosition(14, 16);
        Console.WriteLine("Y/N");

        ConsoleKeyInfo check = Console.ReadKey();

        Console.Clear();

        if (check.Key.ToString().ToLower() == "y")
        {
            Console.Clear();

            PackManHydra.monsterOneCounter   = 0;
            PackManHydra.monsterTwoCounter   = 0;
            PackManHydra.monsterThreeCounter = 0;
            PackManHydra.monsterFourCounter  = 0;

            PackManHydra.points       = 0;
            PackManHydra.lives        = 3;
            PackManHydra.currentLevel = 1;

            Console.ForegroundColor = ConsoleColor.White;

            Mariyan.DrawGameBoardLevelOne();
            Dimitar.StartCounter();

            PackManHydra.InitDotsArray(1);

            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();

            PackManHydra.endGame = true;

            Georgi.RefreshScreen(PackManHydra.badGuysCoordinates, Mariyan.wallsLevelOne);
        }
        else if (check.Key.ToString().ToLower() == "n")
        {
            Console.Clear();

            PackManHydra.monsterOneCounter   = 0;
            PackManHydra.monsterTwoCounter   = 0;
            PackManHydra.monsterThreeCounter = 0;
            PackManHydra.monsterFourCounter  = 0;

            PackManHydra.points       = 0;
            PackManHydra.lives        = 3;
            PackManHydra.currentLevel = 1;

            PackManHydra.returnFromLevelOne = false;
            PackManHydra.endGame            = true;

            PackManHydra.Main();
        }
    }
Exemple #2
0
    public static void Main()
    {
        Console.Title = "EatSharp";

        Dimitar.SetConsoleWidthAndHeight();

        Console.OutputEncoding = Encoding.UTF8;

        if (returnFromHighScores && returnFromInstructions && returnFromLevelOne && returnFromLevelTwo)
        {
            DrawLogo(20);

            DimitarPiskov.PrintGameName();
            Console.ReadKey();
            Console.Clear();

            DimitarPiskov.Introduction();
            Console.ReadKey();
            Console.Clear();
        }

        // Menu

        Ivaylo.PrintingMenuGame();

        waveOutDevice = new WaveOut();

        ConsoleKeyInfo choice = Console.ReadKey();

        StringBuilder userNickname = new StringBuilder();

        if (choice.Key == ConsoleKey.D1)
        {
            Console.Clear();

            int  currentColumn = 15;
            bool inputSuccess  = true;
            var  nickname      = new List <ConsoleKeyInfo>();

            Dimitar.AskUserForNickname(ref currentColumn, ref inputSuccess, nickname);

            Console.ForegroundColor = ConsoleColor.White;

            Mariyan.DrawGameBoardLevelOne();
            Dimitar.StartCounter();

            InitDotsArray(1);

            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();

            while (!endLevelOne)
            {
                Thread.Sleep(200);

                Ivaylo.MonsterNMovingLevelOne();
                Dimitar.MonsterIMovingLevelOne();
                Mariyan.MonsterDLevelOne();
                Antonina.monsterEMovingLevelOne();

                Georgi.RefreshScreen(badGuysCoordinates, Mariyan.wallsLevelOne);

                if (points >= 1280) //1280
                {
                    Thread.Sleep(1500);

                    endLevelOne = true;

                    currentLevel = 2;
                    break;
                }

                else if (endGame == false)
                {
                    Dimitar.AskUserToRestartLevelOne(waveOutDevice, audioFileReader);
                }
            }

            waveOutDevice.Stop();

            Dimitar.LevelTwoMessage();
            Console.ReadKey();

            Console.Clear();

            Console.ForegroundColor = ConsoleColor.White;

            Mariyan.DrawGameBoardLevelTwo();
            Dimitar.StartCounter();

            InitDotsArray(2);

            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();

            monsterOneCounter   = 0;
            monsterTwoCounter   = 0;
            monsterThreeCounter = 0;
            monsterFourCounter  = 0;

            while (!endLevelTwo)
            {
                Thread.Sleep(200);

                Ivaylo.MonsterNMovingLevelTwo();
                Mariyan.MonsterILevelTwo();
                Evgeni.MonsterDMovingLevelTwo();
                Ivaylo.MonsterEMovingLevelTwo();

                Georgi.RefreshScreen(badGuysCoordinates, Mariyan.wallsLevelTwo);

                if (points >= 2600) //2600
                {
                    Thread.Sleep(1500);
                    endLevelTwo = true;

                    try
                    {
                        StreamWriter userScores = new StreamWriter(@"..\..\HighScores.txt");


                        using (userScores)
                        {
                            user.Append(points);
                            userScores.WriteLine(user);
                        }
                    }
                    catch (FileNotFoundException exMessage)
                    {
                        Console.WriteLine("The file is not found!");
                        Console.WriteLine(exMessage.Message);
                    }

                    break;
                }

                else if (endGame == false)
                {
                    Dimitar.AskUserToRestartLevelTwo(waveOutDevice, audioFileReader);
                }
            }
        }

        else if (choice.Key == ConsoleKey.D2)
        {
            UserChooseInstructionsMenu();
        }

        else if (choice.Key == ConsoleKey.D3)
        {
            UserChooseHighScoresMenu();
        }

        else if (choice.Key == ConsoleKey.D4)
        {
            Console.Clear();
            Environment.Exit(-1);
        }

        Console.Clear();
        Mariyan.GameOutro();

        Console.CursorVisible = false;
    }