Exemple #1
0
    public static void EndScreenHighScores(BigInteger score)
    {
        try
        {
            StreamReader read = new StreamReader("HighScores.txt");
            Console.Clear();
            Console.SetCursorPosition(5, 20);
            Console.Write("You entered top 9 player. Enter your name: ");
            bool canAdd = true;
            Dictionary <string, BigInteger> players = new Dictionary <string, BigInteger>();
            string readLine;
            using (read)
            {
                readLine = read.ReadLine();
                readLine = read.ReadLine();
                while (readLine != null)
                {
                    string[] player = readLine.Split(new char[] { ' ', ',', '|' }, StringSplitOptions.RemoveEmptyEntries);

                    players.Add(player[1], BigInteger.Parse(player[2]));
                    if (score > BigInteger.Parse(player[2]))
                    {
                        canAdd = true;
                    }
                    readLine = read.ReadLine();
                }
            }
            if (players.Count < 9 || canAdd)
            {
                StringBuilder playerName = new StringBuilder();
                int           length     = 0;
                while (true)
                {
                    if (Console.KeyAvailable)
                    {
                        EnterName(ref score, ref players, playerName, ref length);
                    }
                }
            }
        }
        catch (FileNotFoundException)
        {
            Console.Clear();
            Console.SetCursorPosition(5, 20);
            Console.Write("You entered top 9 player. Enter your name: ");

            Dictionary <string, BigInteger> players = new Dictionary <string, BigInteger>();
            StringBuilder playerName = new StringBuilder();
            int           length     = 0;
            EnterName(ref score, ref players, playerName, ref length);

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write(' ');
                Console.SetCursorPosition(0, Console.CursorTop);
            }
            StartScreen.Main();
        }
    }
Exemple #2
0
    public static void HighScoresTop9()
    {
        try
        {
            StreamReader read = new StreamReader("HighScores.txt");
            Console.Clear();
            using (read)
            {
                Console.SetCursorPosition(35, 18);
                Console.WriteLine("HIGH SCORES");
                int    i        = 21;
                string readLine = read.ReadLine();
                while (readLine != null)
                {
                    i++;
                    Console.SetCursorPosition(35, i);
                    Console.WriteLine(readLine);
                    readLine = read.ReadLine();
                }
            }

            Console.SetCursorPosition(35, 36);
            Console.WriteLine("To go back press Esc.");
            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write(' ');
                Console.SetCursorPosition(0, Console.CursorTop);
            }
            StartScreen.Main();
        }
        catch (FileNotFoundException)
        {
            Console.Clear();
            Console.SetCursorPosition(35, 22);
            Console.WriteLine("Nobody played this game yet! To go back press Esc.");
            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write(' ');
                Console.SetCursorPosition(0, Console.CursorTop);
            }
            StartScreen.Main();
        }
        catch (Exception e)
        {
            Console.WriteLine("I missed this exception:");
            Console.WriteLine(e.Message);
        }
    }
Exemple #3
0
    public static void FinishGame(BigInteger score)
    {
        Console.Clear();
        bool canAdd = false;
        int  i      = 0;

        try
        {
            StreamReader read = new StreamReader("HighScores.txt");
            using (read)
            {
                string readLine = read.ReadLine();
                readLine = read.ReadLine();
                while (readLine != null)
                {
                    string[] player = readLine.Split(new char[] { ' ', ',', '|' }, StringSplitOptions.RemoveEmptyEntries);

                    if (score > BigInteger.Parse(player[2]))
                    {
                        canAdd = true;
                        break;
                    }
                    i++;
                    readLine = read.ReadLine();
                }
            }
            if (i < 9 || canAdd)
            {
                HighScores.EndScreenHighScores(score);
            }
            else
            {
                Console.SetCursorPosition(5, 20);
                Console.WriteLine("Game ended.Your score wasn't high enough to enter the top 9 players. Press Esc to go back!");
            }

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write(' ');
                Console.SetCursorPosition(0, Console.CursorTop);
            }
            StartScreen.Main();
        }
        catch (FileNotFoundException)
        {
            HighScores.EndScreenHighScores(score);
        }
    }
Exemple #4
0
    //How to Play
    public static void HowToPlay()
    {
        Console.Clear();
        Console.SetCursorPosition(1, 1);
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("  ^");
        Console.WriteLine("   |");
        Console.Write(" <--->");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("  You move with the arrows.");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("   |");
        Console.WriteLine("  \\/");

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("\n\nYou get points by killing those:\n");

        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine(
            "  P     o     *        ***             \n" +
            " P P   oOo   ***   @   ***    *****     *\n" +
            "                       ***   *******   ***\n"
            );

        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("\n\nYou fire missiles(\'");

        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.Write("-");

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("') with Space bar.");

        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("\n\nYou ask for NUKLEAR BOMB with Z.");


        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("\n\n\n To go back press Escape.");

        while (Console.ReadKey().Key != ConsoleKey.Escape)
        {
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write(' ');
            Console.SetCursorPosition(0, Console.CursorTop);
        }
        StartScreen.Main();
    }
Exemple #5
0
    public static void _HowToPlay()
    {
        Console.Clear();
        Console.SetCursorPosition(1, 1);
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("  ^");
        Console.WriteLine("   |");
        Console.Write(" <--->");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("  You move with the arrows.");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("   |");
        Console.WriteLine("  \\/");

        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("\n     /\\");
        Console.WriteLine("    ///\\");
        Console.Write("   /////\\");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("  Be carefull with the mountains!");
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("  ///////\\");

        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("\n\nYou fire missiles(\'");

        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.Write("-");

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("') with Space bar.");

        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("\n\nYou fire bombs(\'");

        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.Write("*");

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("') with Z.");

        Console.ForegroundColor = ConsoleColor.Magenta;
        Console.WriteLine("\n\n  #");
        Console.Write(" ###");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("  Kill those fuckers with missiles or bombs.");
        Console.ForegroundColor = ConsoleColor.Magenta;
        Console.WriteLine("  #");

        Console.ForegroundColor = ConsoleColor.DarkRed;
        Console.WriteLine("\n\n  ^^^");
        Console.Write("  %%%");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("  You can kill bases with bombs.");
        Console.ForegroundColor = ConsoleColor.DarkRed;
        Console.WriteLine("  %%%");

        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("\n\n\n To go back press Escape.");

        while (Console.ReadKey().Key != ConsoleKey.Escape)
        {
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write(' ');
            Console.SetCursorPosition(0, Console.CursorTop);
        }
        StartScreen.Main();
    }