コード例 #1
0
        public static void NewPlayer()
        {
            //get the user input
            string usersInput;
            //always false until user adds input
            bool validAnswer = false;

            while (validAnswer == false)
            {
                Console.WriteLine("Are you new to Avalon?");
                Console.Write("> ");
                usersInput = Console.ReadLine();

                if (usersInput.ToLower() == "no") //Get save data info
                {
                    validAnswer = true;
                    Console.WriteLine("What is your name?");
                    usersInput = CapWords.FirstCharToUpper(Console.ReadLine());
                    LoadPlayer.LoadGame(usersInput.ToLower());
                }
                else if (usersInput.ToLower() == "yes") // Move on to create the player
                {
                    validAnswer = true;
                    CreatePlayer.CreateAPlayer();
                }
                else
                {
                    Console.WriteLine("Enter a valid answer.");
                }
            }
        }
コード例 #2
0
        public static void NewPlayer()
        {
            string userInput;                   // To hold the user's input.
            bool   validAnswer = false;         // This will stay false until the user's answers yes or no.

            /**
             * This loop will stay going until a valid answer is recieved from
             * the user.
             */
            while (validAnswer == false)
            {
                Console.WriteLine("Are you a new Player?");
                Console.Write("> ");
                userInput = Console.ReadLine();

                if (userInput.ToLower() == "no")
                {
                    validAnswer = true;
                    Console.WriteLine("What is your name?");
                    userInput = CapWord.FirstCharToUpper(Console.ReadLine());
                    Load.LoadGameData(userInput.ToLower());         // Go to the Load class and exacute the LoadGame method.
                }
                else if (userInput.ToLower() == "yes")
                {
                    validAnswer = true;
                    CreatePlayer.CreatePlayerInst();                // Go to CreatePlayer and exacute the CreatePlayerInst method.
                }
                else
                {
                    Console.WriteLine("Not a valid answer.");
                }
            }
        }
コード例 #3
0
        public static void PContinue(Player player)
        {
            string usersInput;
            bool   validAnswer = false;

            while (validAnswer == false)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("You are a weakling");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Would you like to Continue?");
                Console.WriteLine("Yes, No, or Create");
                Console.Write("> ");
                usersInput = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine();

                if (usersInput.ToLower() == "no")
                {
                    Environment.Exit(0);
                }
                else if (usersInput.ToLower() == "yes")
                {
                    LocationCurrent.CurrentLocation();
                    break;
                }
                else if (usersInput.ToLower() == "create")
                {
                    Console.Clear(); // clear Console to keep clean
                    CreatePlayer.CreateAPlayer();
                    LocationCurrent.CurrentLocation();
                    break;
                }
                else
                {
                    Console.WriteLine("Enter a valid answer.");
                }
            }
        }