Beispiel #1
0
        /// <summary>
        /// get a SpaceTimeLocation object using an Id
        /// </summary>
        /// <param name="Id">space-time location ID</param>
        /// <returns>requested space-time location</returns>
        public RegionLocation GetRegionLocationById(int Id)
        {
            RegionLocation regionLocation = null;

            //
            //run through the space-time location list and grab the correct one
            //
            foreach (RegionLocation location in _regionLocations)
            {
                if (location.RegionLocationID == Id)
                {
                    regionLocation = location;
                }
            }

            //
            // the specified ID was not found in the universe
            // throw and exception
            //

            if (regionLocation == null)
            {
                string feedbackMessage = $"The Region Location ID {Id} does not exist in the" +
                                         $"current Universe.";
                throw new ArgumentException(Id.ToString(), feedbackMessage);
            }

            return(regionLocation);
        }
Beispiel #2
0
        public static string CurrentLocationInfo(RegionLocation regionLocation)
        {
            string messageBoxText =
                $"Current Location: {regionLocation.CommonName}\n" +
                "\n" +
                regionLocation.Description;

            return(messageBoxText);
        }
Beispiel #3
0
        public static string LookAround(RegionLocation regionLocation)
        {
            string messageBoxText =
                $"Current Location: {regionLocation.CommonName}\n" +
                $" \n" +
                regionLocation.GeneralContents;

            return(messageBoxText);
        }
Beispiel #4
0
        /// <summary>
        /// determine if a location is accessible to the player
        /// </summary>
        /// <param name="regionLocationID"></param>
        /// <returns>accessible</returns>
        public bool IsAccessibleLocation(int regionLocationID)
        {
            RegionLocation regionLocation = GetRegionLocationById(regionLocationID);

            if (regionLocation.Accessible == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// method to manage the application setup and game loop
        /// </summary>
        private void ManageGameLoop()
        {
            ProspectorAction travelerActionChoice = ProspectorAction.None;

            //
            // display splash screen
            //
            _playingGame = _gameConsoleView.DisplaySpashScreen();

            //
            // player chooses to quit
            //
            if (!_playingGame)
            {
                Environment.Exit(1);
            }

            //
            // display introductory message
            //
            _gameConsoleView.DisplayGamePlayScreen("Game Intro", Text.GameIntro(), ActionMenu.GameIntro, "");
            _gameConsoleView.GetContinueKey();

            //
            // initialize the mission prospector
            //
            InitializeAdventure();

            //
            // prepare game play screen
            //

            _currentLocation = _gameUniverse.GetRegionLocationById(_gamePlayer.CurrentRegionLocationID);
            _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrrentLocationInfo(), ActionMenu.MainMenu, "");

            //
            // game loop
            //
            while (_playingGame)
            {
                //
                // process all flags, events, and stats
                //

                UpdateGameStatus();
                //
                // get next game action from player
                //

                //
                // get next game action from player
                //
                travelerActionChoice = GetNextProspectorAction();

                //
                // choose an action based on the user's menu choice
                //
                switch (travelerActionChoice)
                {
                case ProspectorAction.None:
                    break;

                case ProspectorAction.ProspectorInfo:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.ProspectorInfo;
                    _gameConsoleView.DisplayTravelerInfo();
                    //_gameConsoleView.DisplayTravelerInfo();
                    break;

                case ProspectorAction.EditAccount:
                    editAccount();
                    break;

                case ProspectorAction.LookAround:
                    _gameConsoleView.DisplayLookAround();
                    break;

                case ProspectorAction.Travel:
                    //
                    // get new location choice and update the current location property
                    //
                    _gamePlayer.CurrentRegionLocationID = _gameConsoleView.DisplayGetNextRegionLocation();
                    _currentLocation = _gameUniverse.GetRegionLocationById((_gamePlayer).CurrentRegionLocationID);

                    //
                    // set the game play screen to the current location info format
                    //
                    _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, "");
                    break;

                case ProspectorAction.ProspectorInventory:
                    _gameConsoleView.DisplayInventory();
                    break;

                case ProspectorAction.ProspectorLocationsVisited:
                    _gameConsoleView.DisplayLocationsVisited();
                    break;

                case ProspectorAction.ListDestinations:
                    _gameConsoleView.DisplayListOfRegionLocations();
                    break;

                case ProspectorAction.ListItems:
                    _gameConsoleView.DisplayListOfAllGameObjects();
                    break;

                case ProspectorAction.AdminMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu;
                    _gameConsoleView.DisplayGamePlayScreen("Admin Menu", "Select an operation from the menu.", ActionMenu.AdminMenu, "");
                    break;

                case ProspectorAction.ReturnToMainMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu;
                    _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, "");
                    break;

                case ProspectorAction.Exit:
                    _playingGame = false;
                    break;

                case ProspectorAction.LookAt:
                    LookAtAction();
                    break;

                case ProspectorAction.PickUpItem:
                    PickUpAction();
                    break;

                case ProspectorAction.PutDownItem:
                    PutDownAction();
                    break;

                case ProspectorAction.Shop:
                    if (_gameUniverse.GetRegionLocationById(_gamePlayer.CurrentRegionLocationID).CommonName == "Wilderness")
                    {
                        _gameConsoleView.DisplayCanNotVisitShop();
                    }
                    else
                    {
                        Shop();
                    }

                    break;

                case ProspectorAction.ManageInventory:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.ManageInventory;
                    _gameConsoleView.DisplayGamePlayScreen("Manage Inventory", $"Please select an menu action you would like to do with the below items: \n{Text.CurrentInventory(_gamePlayer.Inventory)}", ActionMenu.useItem, "");
                    break;

                case ProspectorAction.ListNonPlayableCharacters:
                    _gameConsoleView.DisplayListOfAllNpcObjects();
                    break;

                case ProspectorAction.TalkTo:
                    TalkToAction();
                    break;

                case ProspectorAction.SellTo:
                    SellItem();
                    break;

                case ProspectorAction.Interact:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.NpcMenu;
                    _gameConsoleView.DisplayGamePlayScreen("Interact With NPC", "Please select an action!", ActionMenu.NpcMenu, "");
                    break;

                case ProspectorAction.ConsumeItem:
                    ConsumeItem();
                    break;

                case ProspectorAction.WieldItem:
                    WieldItem();
                    break;

                case ProspectorAction.PlayerInfoMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.ProspectorInfo;
                    _gameConsoleView.DisplayGamePlayScreen("Player Information", "Please select a menu option to your left to view Player Information", ActionMenu.ProspectorInfo, "");
                    break;

                default:
                    break;
                }
            }

            //
            // close the application
            //
            Environment.Exit(1);
        }