Beispiel #1
0
        /// <summary>
        /// display the welcome screen
        /// </summary>
        public void DisplayWelcomeScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Back To The Future Game");
            ConsoleUtil.DisplayMessage("");
            Console.WriteLine();

            sb.Clear();
            ConsoleUtil.DisplayMessage("");
            sb.AppendFormat("- You have just realized that the Flux Capacitor really does work!  -");
            ConsoleUtil.DisplayMessage("");
            sb.AppendFormat("- You now can drive or fly the DeLorean throughout time.  -");
            ConsoleUtil.DisplayMessage("");
            sb.AppendFormat("- Visit a destination year and see where the Future takes you -");
            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();

            DisplayContinuePrompt();
        }
Beispiel #2
0
        /// <summary>
        /// Display a Yes or No prompt with a message
        /// </summary>
        /// <param name="promptMessage">prompt message</param>
        /// <returns>bool where true = yes</returns>
        public static bool?DisplayGetYesNoPrompt(string promptMessage)
        {
            bool?  yesNoChoice   = null;
            bool   validResponse = false;
            string userResponse;

            while (!validResponse)
            {
                ConsoleUtil.DisplayReset();

                ConsoleUtil.DisplayPromptMessage(promptMessage + "(Yes/No)");
                userResponse = Console.ReadLine();

                if (userResponse.ToUpper() == "YES")
                {
                    validResponse = true;
                    yesNoChoice   = true;
                }
                else if (userResponse.ToUpper() == "NO")
                {
                    validResponse = true;
                    yesNoChoice   = false;

                    break;
                }
                else
                {
                    ConsoleUtil.DisplayMessage(
                        "It appears that you have entered an incorrect response." +
                        " Please enter either \"Yes\" or \"No\"."
                        );
                    DisplayContinuePrompt();
                }
            }

            return(yesNoChoice);
        }
Beispiel #3
0
        ///<summary>
        ///display talk to method
        /// </summary>
        public void DisplayTalkTo()
        {
            string travelerTalk;

            ConsoleUtil.HeaderText = "Talk To";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayPromptMessage("Type what you would like to say:  ");
            travelerTalk = Console.ReadLine();

            ConsoleUtil.DisplayReset();
            ConsoleUtil.DisplayMessage($"You stated: {travelerTalk} ");
            ConsoleUtil.DisplayMessage("");

            foreach (BadGuy badguy in _gameYear.GetBadGuysByYearTimeLocationID(_gameTraveler.TimeLocationID))
            {
                ConsoleUtil.DisplayMessage($"{badguy.Name} states: {badguy.Message}");
                ConsoleUtil.DisplayMessage("");

                if (badguy.NiceMessage != true)
                {
                    ConsoleUtil.DisplayMessage("You are forced to leave.");
                    var myplayer = new System.Media.SoundPlayer();
                    myplayer.SoundLocation = @"C:\Users\Jennifer\Documents\Visual Studio 2015\Projects\Back To The Future Game [sprint 3]\Project_TARDIS.S2_Starter\sound\lookinat.wav";
                    myplayer.Play();
                }
                else
                {
                    ConsoleUtil.DisplayMessage("You feel welcome and are invited for Pepsi.");
                    var myplayer = new System.Media.SoundPlayer();
                    myplayer.SoundLocation = @"C:\Users\Jennifer\Documents\Visual Studio 2015\Projects\Back To The Future Game [sprint 3]\Project_TARDIS.S2_Starter\sound\pepsiperfect.wav";
                    myplayer.Play();
                }
            }

            DisplayContinuePrompt();
        }
Beispiel #4
0
        /// <summary>
        /// get the action choice from the user
        /// </summary>
        public TravelerAction DisplayGetTravelerActionChoice()
        {
            TravelerAction travelerActionChoice = TravelerAction.None;
            bool           usingMenu            = true;

            while (usingMenu)
            {
                //
                // set up display area
                //
                ConsoleUtil.HeaderText = "Time Traveler Actions";
                ConsoleUtil.DisplayReset();
                Console.CursorVisible = false;

                //
                // display the menu
                //
                ConsoleUtil.DisplayMessage("What would you like to do (Type Letter)?");
                Console.WriteLine();
                Console.WriteLine(
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Time Traveler Actions" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "A. Look Around" + Environment.NewLine +
                    "\t" + "B. Look At" + Environment.NewLine +
                    "\t" + "C. Pick Up Item" + Environment.NewLine +
                    "\t" + "D. Pick Up Treasure" + Environment.NewLine +
                    "\t" + "E. Put Down Item" + Environment.NewLine +
                    "\t" + "F. Put Down Treasure" + Environment.NewLine +
                    "\t" + "G. Travel" + Environment.NewLine +
                    "\t" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Time Traveler Information" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "H. Display General Time Traveler Information" + Environment.NewLine +
                    "\t" + "I. Display Time Traveler Inventory" + Environment.NewLine +
                    "\t" + "J. Display Time Traveler Treasure" + Environment.NewLine +
                    "\t" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Game Information" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "K. Display All Year Destinations" + Environment.NewLine +
                    "\t" + "L. Display All Game Items" + Environment.NewLine +
                    "\t" + "M. Display All Game Treasures" + Environment.NewLine +
                    "\t" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Q. Quit" + Environment.NewLine);

                //
                // get and process the user's response
                // note: ReadKey argument set to "true" disables the echoing of the key press
                //
                ConsoleKeyInfo userResponse = Console.ReadKey(true);
                switch (userResponse.KeyChar)
                {
                case 'A':
                case 'a':
                    travelerActionChoice = TravelerAction.LookAround;
                    usingMenu            = false;
                    break;

                case 'B':
                case 'b':
                    travelerActionChoice = TravelerAction.LookAt;
                    usingMenu            = false;
                    break;

                case 'C':
                case 'c':
                    travelerActionChoice = TravelerAction.PickUpItem;
                    usingMenu            = false;
                    break;

                case 'D':
                case 'd':
                    travelerActionChoice = TravelerAction.PickUpTreasure;
                    usingMenu            = false;
                    break;

                case 'E':
                case 'e':
                    travelerActionChoice = TravelerAction.PutDownItem;
                    usingMenu            = false;
                    break;

                case 'F':
                case 'f':
                    travelerActionChoice = TravelerAction.PutDownTreasure;
                    usingMenu            = false;
                    break;

                case 'G':
                case 'g':
                    travelerActionChoice = TravelerAction.Travel;
                    usingMenu            = false;
                    break;

                case 'H':
                case 'h':
                    travelerActionChoice = TravelerAction.TravelerInfo;
                    usingMenu            = false;
                    break;

                case 'I':
                case 'i':
                    travelerActionChoice = TravelerAction.TravelerInventory;
                    usingMenu            = false;
                    break;

                case 'J':
                case 'j':
                    travelerActionChoice = TravelerAction.TravelerTreasure;
                    usingMenu            = false;
                    break;

                case 'K':
                case 'k':
                    travelerActionChoice = TravelerAction.ListYearDestinations;
                    usingMenu            = false;
                    break;

                case 'L':
                case 'l':
                    travelerActionChoice = TravelerAction.ListItems;
                    usingMenu            = false;
                    break;

                case 'M':
                case 'm':
                    travelerActionChoice = TravelerAction.ListTreasures;
                    usingMenu            = false;
                    break;

                case 'Q':
                case 'q':
                    travelerActionChoice = TravelerAction.Exit;
                    usingMenu            = false;
                    break;

                default:
                    Console.WriteLine(
                        "It appears you have selected an incorrect choice." + Environment.NewLine +
                        "Press any key to continue or the ESC key to quit the application.");

                    userResponse = Console.ReadKey(true);
                    if (userResponse.Key == ConsoleKey.Escape)
                    {
                        usingMenu = false;
                    }
                    break;
                }
            }
            Console.CursorVisible = true;

            return(travelerActionChoice);
        }
Beispiel #5
0
        /// <summary>
        /// get and validate the player's year destination
        /// </summary>
        /// <returns>space-time location</returns>
        public YearLocation DisplayGetTravelersNewDestination()
        {
            bool         validResponse = false;
            int          locationID;
            YearLocation nextYearTimeLocation = new YearLocation();

            while (!validResponse)
            {
                //
                // display header
                //
                ConsoleUtil.HeaderText = "Year Destination";
                ConsoleUtil.DisplayReset();

                //
                // display a table of locations
                DisplayYearDestinationTable();

                //
                // get and validate user's response for a location
                //
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayPromptMessage("Choose the year destination by entering the ID: ");

                //
                // user's response is an integer
                //
                if (int.TryParse(Console.ReadLine(), out locationID))
                {
                    ConsoleUtil.DisplayMessage("");

                    try
                    {
                        nextYearTimeLocation = _gameYear.GetYearTimeLocationByID(locationID);

                        ConsoleUtil.DisplayReset();
                        ConsoleUtil.DisplayMessage($"You have indicated {nextYearTimeLocation.Name} as your destination.");
                        ConsoleUtil.DisplayMessage("");

                        if (nextYearTimeLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("You have reached 88 miles per hour in the DeLorean. Were off to the Future!");
                        }
                        else
                        {
                            ConsoleUtil.DisplayMessage("The Flux Capacitor is broke and you can't travel to this year at this time. This could have something to do with your inventory value");
                            ConsoleUtil.DisplayMessage("");
                            ConsoleUtil.DisplayMessage("Please make another choice.");
                        }
                    }
                    //
                    // user's response was not in the correct range
                    //
                    catch (ArgumentOutOfRangeException ex)
                    {
                        ConsoleUtil.DisplayMessage("It appears you entered an invalid year ID.");
                        ConsoleUtil.DisplayMessage(ex.Message);
                        ConsoleUtil.DisplayMessage("Please try again.");
                    }
                }
                //
                // user's response was not an integer
                //
                else
                {
                    ConsoleUtil.DisplayMessage("It appears you did not enter a number for the year ID.");
                    ConsoleUtil.DisplayMessage("");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextYearTimeLocation);
        }
Beispiel #6
0
        /// <summary>
        /// get and validate the player's year destination
        /// </summary>
        /// <returns>-time location</returns>
        public YearLocation DisplayGetTravelersNewDestination()
        {
            bool         validResponse = false;
            int          locationID;
            YearLocation nextYearTimeLocation = new YearLocation();

            while (!validResponse)
            {
                //
                // display header
                //
                ConsoleUtil.HeaderText = "Year Destination";
                ConsoleUtil.DisplayReset();

                //
                // display a table of locations
                DisplayYearDestinationTable();

                //
                // get and validate user's response for a location
                //
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayPromptMessage("Choose the year destination by entering the ID: ");

                //
                // user's response is an integer
                //
                if (int.TryParse(Console.ReadLine(), out locationID))
                {
                    ConsoleUtil.DisplayMessage("");

                    try
                    {
                        nextYearTimeLocation = _gameYear.GetYearTimeLocationByID(locationID);

                        ConsoleUtil.DisplayReset();
                        ConsoleUtil.DisplayMessage($"You have indicated {nextYearTimeLocation.Name} as your destination.");
                        ConsoleUtil.DisplayMessage("");

                        if (nextYearTimeLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("You have reached 88 miles per hour in the DeLorean. Were off to the Future!");
                            var myplayer = new System.Media.SoundPlayer();
                            myplayer.SoundLocation = @"C:\Users\Jennifer\Documents\Visual Studio 2015\Projects\Back To The Future Game [sprint 3]\Project_TARDIS.S2_Starter\sound\workedgreat.wav";
                            myplayer.Play();
                        }
                        else if (nextYearTimeLocation.Accessable == false)
                        {
                            ConsoleUtil.DisplayMessage("The Flux Capacitor is broke and you can't travel to this year at this time. This could have something to do with your inventory items");
                            ConsoleUtil.DisplayMessage("");
                            ConsoleUtil.DisplayMessage("Please make another choice.");
                            var myplayer = new System.Media.SoundPlayer();
                            myplayer.SoundLocation = @"C:\Users\Jennifer\Documents\Visual Studio 2015\Projects\Back To The Future Game [sprint 3]\Project_TARDIS.S2_Starter\sound\wrongyear.wav";
                            myplayer.Play();
                        }
                        else
                        {
                        }
                    }
                    //
                    // user's response was not in the correct range
                    //
                    catch (ArgumentOutOfRangeException ex)
                    {
                        ConsoleUtil.DisplayMessage("It appears you entered an invalid year ID.");
                        ConsoleUtil.DisplayMessage(ex.Message);
                        ConsoleUtil.DisplayMessage("Please try again.");
                    }
                }
                //
                // user's response was not an integer
                //
                else
                {
                    ConsoleUtil.DisplayMessage("It appears you did not enter a number for the year ID.");
                    ConsoleUtil.DisplayMessage("");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextYearTimeLocation);
        }
Beispiel #7
0
 /// <summary
 /// console write
 public void DisplayWrongItem()
 {
     ConsoleUtil.DisplayMessage("You do not have the correct item to execute the traveler action. ");
 }