Ejemplo n.º 1
0
        // This displays after the user assigns their traits and begins the game
        public static void DisplayGameIntro()
        {
            Console.ReplaceAllColorsWithDefaults();

            var enterKeyPressed = false;
            var r = 255;
            var g = 255;
            var b = 255;

            foreach (var line in ConsoleStrings.GameIntro)
            {
                if (enterKeyPressed)
                {
                    Console.WriteLine(line, Color.FromArgb(r, g, b));
                }
                else
                {
                    enterKeyPressed = TypingAnimation.Animate(line, Color.FromArgb(r, g, b));
                }

                g -= 25;
                b -= 25;
            }

            Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4);
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void SetupApplicationInformation()
        {
            var versionAttribute = typeof(Startup).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>();

            Console.SetWindowSize(120, 25);
            Console.Title = $"{nameof(Rhapsody)} v{versionAttribute?.InformationalVersion}";

            const string TITLE =
                @"       _         _           _       _         _        _         _            _  
     _/\\___   _/\\___    __/\\__  _/\\___    /\\__  __/\\___  __/\\___   _   /\\ 
    (_   _  ))(_ __ __)) (_  ____)(_   _ _)) /    \\(_     _))(_  ____)) /\\ / // 
     /  |))//  /  |_| \\  /  _ \\  /  |))\\ _\  \_// /  _  \\  /   _ \\  \ \/ //  
    /:.    \\ /:.  _   \\/:./_\ \\/:. ___//// \:.\  /:.(_)) \\/:. |_\ \\ _\:.//   
    \___|  // \___| |  //\  _   //\_ \\    \\__  /  \  _____//\  _____//(_  _))   
         \//         \//  \// \//   \//       \\/    \//       \//        \//     
";

            Console.WriteWithGradient(TITLE, Color.DarkOrange, Color.SlateBlue);
            Console.ReplaceAllColorsWithDefaults();

            const string LOG_MESSAGE =
                "->  Version: {0}\n->  Framework: {1}\n->  OS Arch: {2}\n->  Process Arch: {3}\n->  OS: {4}";

            var formatters = new[] {
                new Formatter(versionAttribute?.InformationalVersion.Trim(), Color.Gold),
                new Formatter(RuntimeInformation.FrameworkDescription, Color.Aqua),
                new Formatter(RuntimeInformation.OSArchitecture, Color.Gold),
                new Formatter(RuntimeInformation.ProcessArchitecture, Color.LawnGreen),
                new Formatter(RuntimeInformation.OSDescription, Color.HotPink)
            };

            Console.WriteLineFormatted(LOG_MESSAGE, Color.White, formatters);
            Console.WriteLine(new string('-', 100), Color.Gray);
        }
Ejemplo n.º 3
0
        public static void DisplayGameTitle(GameTitle gameTitle)
        {
            var font   = FigletFont.Default;
            var figlet = new Figlet(font);

            Console.ReplaceAllColorsWithDefaults();
            Console.WriteLine(figlet.ToAscii(gameTitle.Title), gameTitle.TitleTextColor);
            Console.WriteLine();
            Console.WriteLine("\t\t-- Written by " + gameTitle.Author + "--", gameTitle.AuthorTextColor);
            Console.WriteLine("\n\n");
            Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4);
            Console.ReadLine();
            Console.ReplaceAllColorsWithDefaults();
            Console.Clear();
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            // Starting point of the program

            Console.SetWindowPosition(0, 0);
            Console.WindowHeight = Console.LargestWindowHeight;
            Console.WindowWidth  = Console.LargestWindowWidth;

            //Thread that play sound
            ThreadStart sounds = new ThreadStart(Sounds.playFireFlies);
            Thread      sound  = new Thread(sounds);

            sound.Start();


            // Thread that play animation
            ThreadStart Animation = new ThreadStart(Animations.zetaAnimation);
            Thread      animation = new Thread(Animation);

            animation.Start();


            ConsoleKey stop = Console.ReadKey().Key;

            if (!stop.Equals(ConsoleKey.Escape))
            {
                animation.Abort();
                Console.ReplaceAllColorsWithDefaults();
                Console.BackgroundColor = Color.Black;
                Console.ForegroundColor = Color.White;
                Console.Clear();
                Animations.SpaceShipLoading();
                Sounds.Stop();

                // Calling the User interface of the system
                UserInterface ui   = new UserInterface();
                ThreadStart   main = new ThreadStart(ui.Initialize);
                Thread        Main = new Thread(main);

                Main.Start();
            }
        }
        static void exam()
        {
            Console.Clear();

            Console.ReplaceAllColorsWithDefaults();
            Console.WriteWithGradient(FiggleFonts.Big.Render("Exam"), Color.HotPink, ColorTranslator.FromHtml("#ff6969"), 3);

            string marks_file = "marks.txt";

            if (File.Exists(marks_file))
            {
                //
                // reads file "marks_file" into a list where every line is a element
                //
                string[] lines = System.IO.File.ReadAllLines(marks_file);

                //
                // creates list names that contains the objects students which have
                // name and grade
                //

                List <Student> names = new List <Student>();


                foreach (string line in lines)
                {
                    //
                    // splits every line into "name" and "grade"
                    //

                    var words = line.Split(' ');
                    names.Add(new Student(words[1], Int16.Parse(words[0]), ""));
                }
                //
                // sorts the students by their grade
                //
                var result1 = names.OrderByDescending(a => a.Score).Reverse();
                if (File.Exists(marks_file))
                {
                    File.Delete("distinctionList.txt");
                }
                foreach (Student stu in result1)
                {
                    if ((stu.Score > 100) | (stu.Score < 0))
                    {
                        stu.Grade = "Error";
                    }
                    else if (stu.Score > 85)
                    {
                        stu.Grade = "Distinction";
                    }
                    else if (stu.Score >= 75)
                    {
                        stu.Grade = "Credit";
                    }
                    else if (stu.Score > 50)
                    {
                        stu.Grade = "Pass";
                    }
                    else
                    {
                        stu.Grade = "Fail";
                    }


                    string to_file = (stu.Grade + " " + stu.Score + "% " + stu.Name + "\n");
                    Console.WriteFormatted(to_file, Color.White);
                    if (stu.Grade == "Distinction")
                    {
                        File.AppendAllText("distinctionList.txt", to_file);
                    }
                }
                Console.WriteLineFormatted(String.Format(@"Please find distinctionList.txt in {0}distinctionList.txt", AppDomain.CurrentDomain.BaseDirectory), Color.Green);
                //Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            }
            else
            {
                Console.WriteFormatted("File 'marks.txt' does not exist\nPlease re-run the program once this file exists\n", Color.Red);
            }
        }