コード例 #1
0
        /// <summary>
        /// display information about the current space-time location
        /// </summary>
        public void DisplayLookAround()
        {
            ConsoleUtil.HeaderText = "Current Space-Time Location Info";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage(_gameYLocation.GetYearTimeLocationByID(_gameTraveler.YearTimeLocationID).Description);

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage("Items in current location.");
            foreach (Item item in _gameYLocation.GetItemtsByYearTimeLocationID(_gameTraveler.YearTimeLocationID))
            {
                ConsoleUtil.DisplayMessage(item.Name + " - " + item.Description);
            }

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage("Treasures in current location.");
            foreach (Treasure treasure in _gameYLocation.GetTreasuressByYearTimeLocationID(_gameTraveler.YearTimeLocationID))
            {
                ConsoleUtil.DisplayMessage(treasure.Name + " - " + treasure.Description);
            }

            DisplayContinuePrompt();
        }
コード例 #2
0
        public void DisplayLookAt()
        {
            int             locationID      = _gameOgre.SwampLocationID;
            List <Item>     itemsInSwamp    = new List <Item>();
            List <Treasure> treasureInSwamp = new List <Treasure>();
            Item            itemToSee       = new Item();
            Treasure        treasureToSee   = new Treasure();

            itemsInSwamp    = _gameKingdom.GetItemsBySwampLocationID(locationID);
            treasureInSwamp = _gameKingdom.GetTreasuresBySwampLocationID(locationID);

            ConsoleUtil.HeaderText = "Items in Current Location";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage(_gameKingdom.GetSwampLocationByID(locationID).Name);
            ConsoleUtil.DisplayMessage("");

            if (itemsInSwamp != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Items in Current location.");
                foreach (Item item in _gameKingdom.Items)
                {
                    if (item.SwampLocationID == locationID)
                    {
                        Console.WriteLine(item.GameObjectID + " - " + item.Name);
                        Console.WriteLine();
                    }
                }
                ConsoleUtil.DisplayPromptMessage("Enter item number or press Enter to move on to Treasures.");
                Console.WriteLine();
                int itemIDChoice;

                if (int.TryParse(Console.ReadLine(), out itemIDChoice))
                {
                    itemToSee = _gameKingdom.GetItemtByID(itemIDChoice);
                    ConsoleUtil.DisplayMessage(itemToSee.Description);

                    DisplayContinuePrompt();
                }
            }

            if (treasureInSwamp != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Treasures in Current location.");
                foreach (Treasure treasure in _gameKingdom.Treasures)
                {
                    if (treasure.SwampLocationID == locationID)
                    {
                        Console.WriteLine(treasure.GameObjectID + " - " + treasure.Name);
                        Console.WriteLine();
                    }
                }
                ConsoleUtil.DisplayPromptMessage("Enter treasure number or press Enter to move on.");
                Console.WriteLine();
                int treasureIDChoice;

                if (int.TryParse(Console.ReadLine(), out treasureIDChoice))
                {
                    treasureToSee = _gameKingdom.GetTreasuretByID(treasureIDChoice);
                    ConsoleUtil.DisplayMessage(treasureToSee.Description);

                    DisplayContinuePrompt();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// get the action choice from the user
        /// </summary>
        public OgreAction DisplayGetOgreActionChoice()
        {
            OgreAction ogreActionChoice = OgreAction.None;
            bool       usingMenu        = true;

            while (usingMenu)
            {
                //
                // set up display area
                //
                ConsoleUtil.HeaderText = "Ogre Action Choice";
                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" + "Ogre Actions" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "A. Look Around" + Environment.NewLine +
                    "\t" + "B. Talk To" + Environment.NewLine +
                    "\t" + "C. Look At" + Environment.NewLine +
                    "\t" + "D. Pick Up Item" + Environment.NewLine +
                    "\t" + "E. Pick Up Treasure" + Environment.NewLine +
                    "\t" + "F. Put Down Item" + Environment.NewLine +
                    "\t" + "G. Put Down Treasure" + Environment.NewLine +
                    "\t" + "H. Travel" + Environment.NewLine +
                    "\t" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Traveler Information" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "I. Display General Ogre Info" + Environment.NewLine +
                    "\t" + "J. Display Ogre Inventory" + Environment.NewLine +
                    "\t" + "K. Display Ogre Treasures" + Environment.NewLine +
                    "\t" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "Game Information" + Environment.NewLine +
                    "\t" + "**************************" + Environment.NewLine +
                    "\t" + "L. Display All Swamp Destinations" + Environment.NewLine +
                    "\t" + "M. Display All Game Items" + Environment.NewLine +
                    "\t" + "N. 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':
                    ogreActionChoice = OgreAction.LookAround;
                    usingMenu        = false;
                    break;

                case 'B':
                case 'b':
                    ogreActionChoice = OgreAction.TalkTo;
                    usingMenu        = false;
                    break;

                case 'C':
                case 'c':
                    ogreActionChoice = OgreAction.LookAt;
                    usingMenu        = false;
                    break;

                case 'D':
                case 'd':
                    ogreActionChoice = OgreAction.PickUpItem;
                    usingMenu        = false;
                    break;

                case 'E':
                case 'e':
                    ogreActionChoice = OgreAction.PickUpTreasure;
                    usingMenu        = false;
                    break;

                case 'F':
                case 'f':
                    ogreActionChoice = OgreAction.PutDownItem;
                    usingMenu        = false;
                    break;

                case 'G':
                case 'g':
                    ogreActionChoice = OgreAction.PutDownTreasure;
                    usingMenu        = false;
                    break;

                case 'H':
                case 'h':
                    ogreActionChoice = OgreAction.Travel;
                    usingMenu        = false;
                    break;

                case 'I':
                case 'i':
                    ogreActionChoice = OgreAction.OgreInfo;
                    usingMenu        = false;
                    break;

                case 'J':
                case 'j':
                    ogreActionChoice = OgreAction.OgreInventory;
                    usingMenu        = false;
                    break;

                case 'K':
                case 'k':
                    ogreActionChoice = OgreAction.OgreTreasure;
                    usingMenu        = false;
                    break;

                case 'L':
                case 'l':
                    ogreActionChoice = OgreAction.ListSwampDestinations;
                    usingMenu        = false;
                    break;

                case 'M':
                case 'm':
                    ogreActionChoice = OgreAction.ListItems;
                    usingMenu        = false;
                    break;

                case 'N':
                case 'n':
                    ogreActionChoice = OgreAction.ListTreasures;
                    usingMenu        = false;
                    break;

                case 'Q':
                case 'q':
                    ogreActionChoice = OgreAction.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(ogreActionChoice);
        }
コード例 #4
0
        /// <summary>
        /// get and validate the player's TARDIS destination
        /// </summary>
        /// <returns>space-time location</returns>
        public SwampLocation DisplayGetOgresNewDestination()
        {
            bool          validResponse = false;
            int           swampID;
            SwampLocation nextSwampLocation = new SwampLocation();

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

                //
                // display a table of space-time locations
                //
                DisplaySwampDestinationsTable();

                //
                // get and validate user's response for a space-time location
                //
                ConsoleUtil.DisplayPromptMessage("Choose your swamp location by using its ID: ");

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



                    try
                    {
                        nextSwampLocation = _gameKingdom.GetSwampLocationByID(swampID);

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

                        if (nextSwampLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("Your journey continues.");
                        }
                        else
                        {
                            ConsoleUtil.DisplayMessage("It appears this destination is not available to you at this time.");
                            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 location 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 location ID.");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextSwampLocation);
        }
コード例 #5
0
        /// <summary>
        /// get the action choice from the user
        /// </summary>
        public TimeTravelerAction DisplayGetTravelerActionChoice()
        {
            TimeTravelerAction travelerActionChoice = TimeTravelerAction.None;
            bool usingMenu = true;

            while (usingMenu)
            {
                //
                // set up display area
                //
                ConsoleUtil.HeaderText = "TimeTraveler Action Choice";
                ConsoleUtil.DisplayReset();
                Console.CursorVisible = false;

                //
                // display the menu
                //
                ConsoleUtil.DisplayMessage("What would you like to do (Type Number).");
                Console.WriteLine();
                Console.WriteLine(
                    "\t" + "1. Look Around" + Environment.NewLine +
                    "\t" + "2. Travel" + Environment.NewLine +
                    "\t" + "3. Display TimeTraveler Info" + Environment.NewLine +
                    "\t" + "4. Display TimeTraveler Inventory" + Environment.NewLine +
                    "\t" + "5. Display TimeTraveler Treasure" + Environment.NewLine +
                    "\t" + "6. Display All TARDIS Destinations" + Environment.NewLine +
                    "\t" + "7. Display All Game Items" + Environment.NewLine +
                    "\t" + "8. Display All Game Treasures" + Environment.NewLine +
                    "\t" + "E. Exit" + 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 '1':
                    travelerActionChoice = TimeTravelerAction.LookAround;
                    usingMenu            = false;
                    break;

                case '2':
                    travelerActionChoice = TimeTravelerAction.Travel;
                    usingMenu            = false;
                    break;

                case '3':
                    travelerActionChoice = TimeTravelerAction.TravelerInfo;
                    usingMenu            = false;
                    break;

                case '4':
                    travelerActionChoice = TimeTravelerAction.TravelerInventory;
                    usingMenu            = false;
                    break;

                case '5':
                    travelerActionChoice = TimeTravelerAction.TravelerTreasure;
                    usingMenu            = false;
                    break;

                case '6':
                    travelerActionChoice = TimeTravelerAction.ListYearDestinations;
                    usingMenu            = false;
                    break;

                case '7':
                    travelerActionChoice = TimeTravelerAction.ListItems;
                    usingMenu            = false;
                    break;

                case '8':
                    travelerActionChoice = TimeTravelerAction.ListTreasures;
                    usingMenu            = false;
                    break;

                case 'E':
                case 'e':
                    travelerActionChoice = TimeTravelerAction.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);
        }
コード例 #6
0
        /// <summary>
        /// get and validate the player's TARDIS 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 = "TARDIS Destination";
                ConsoleUtil.DisplayReset();

                //
                // display a table of year-time locations
                //
                DisplayTARDISDestinationsTable();

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

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

                    try
                    {
                        nextYearTimeLocation = _gameYLocation.GetYearTimeLocationByID(locationID);

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

                        if (nextYearTimeLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("You will be transported immediately.");
                        }
                        else
                        {
                            ConsoleUtil.DisplayMessage("It appears this destination is not available to you at this time.");
                            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 location 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 location ID.");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextYearTimeLocation);
        }