Example #1
0
        public static void StartProgram()
        {
            Console.Title = "My Classmates";
            if (FileHandling.CheckFileFolderExistance() > 0)
            {
                Classmates.Populate(myClassmates);

                //Method for saving mockdata and user changes to a file.
                FileHandling.BinarySerializer(myClassmates);
            }

            // Else read the file
            else
            {
                myClassmates = FileHandling.BinaryDeSerializer(myClassmates);
            }
            Console.SetWindowSize(100, 40);
            FileHandling.CreateLogos();

            //Runs the login method
            Login.UserLogin();
            //If the program had to add any files, then populate that file with the standard classmates

            Menus.StartMenu(myClassmates);
        }
Example #2
0
        /******************************************************************
        *                           NEW GAME MENU
        ******************************************************************/
        private void NewGame()
        {
            Thread.Sleep(500);

            Print.ClearAllScreen();
            Print.DragonPrint();

            string name;
            bool   emptyName   = true;
            string errorMsg    = default;
            string pathwayFull = string.Concat(pathway, file);

            //If no filepath is found
            if (new FileInfo(pathwayFull).Length == 0)
            {
                do
                {
                    if (!string.IsNullOrEmpty(errorMsg))
                    {
                        Console.SetCursorPosition(left, top + 1);
                        Print.Red(errorMsg);
                        errorMsg = default;
                    }

                    //User input for name
                    Print.SetTopLeftCursorPosToStandard();
                    Console.Write("What is our heros name?> ");
                    Console.CursorVisible = true;
                    name = Console.ReadLine();
                    Console.CursorVisible = false;
                    var sounds = _menuObject.SoundList();
                    AudioPlaybackEngine sound = new AudioPlaybackEngine();
                    sound.PlaySound(sounds[1]);
                    Thread.Sleep(700);
                    sound.Dispose();
                    //Check if name is empty
                    if (!string.IsNullOrEmpty(name))
                    {
                        emptyName = false;
                    }
                    else
                    {
                        top = 13;
                        Console.SetCursorPosition(left, top + 1);
                        errorMsg = "Name can not be empty";
                    }
                } while (emptyName);

                //Creating a new player and saves it to a list
                player = new Player(name);
                playerList.Add(player);
                //Saving the player list to a file.
                FileHandling.BinarySerializer(playerList);
            }
            else
            {
                foreach (var item in playerList)
                {
                    player = item;
                }
            }
            player.PrintCurrentPlayerStatus();
            InGameMenu();
        }