Exemple #1
0
        /// <summary>
        /// display select information about the current location
        /// </summary>
        public void DisplayLookAround()
        {
            //
            // get current world area location
            //
            WorldAreaLocation currentWorldAreaLocation = _gameWorld.GetWorldAreaLocationById(_gameAdventurer.WorldAreaLocationID);

            //
            // get list of game objects in current world-area location
            //
            List <GameObject> gameObjectsInCurrentWorldAreaLocation = _gameWorld.GetGameObjectsByWorldAreaLocationId(_gameAdventurer.WorldAreaLocationID);

            //
            // get list of NPCs in current world area location
            //

            List <Npc> npcsInCurrentWorldAreaLocation = _gameWorld.GetNpcsByWorldAreaLocationId(_gameAdventurer.WorldAreaLocationID);

            string messageBoxText = Text.LookAround(currentWorldAreaLocation) + Environment.NewLine + Environment.NewLine;

            messageBoxText += Text.GameObjectsChooseList(gameObjectsInCurrentWorldAreaLocation) + Environment.NewLine;
            messageBoxText += Text.NpcsChooseList(npcsInCurrentWorldAreaLocation);

            DisplayGamePlayScreen("Current Location", messageBoxText, ActionMenu.MainMenu, "");
        }
        /// <summary>
        /// get a worldAreaLocation object using an Id
        /// </summary>
        /// <param name="Id">worldArea location Id</param>
        /// <returns>requested worldArea location</returns>
        public WorldAreaLocation GetWorldAreaLocationById(int Id)
        {
            WorldAreaLocation worldAreaLocation = null;

            //
            // run through the worldArea location list and grab the correct one
            //
            foreach (WorldAreaLocation location in _worldAreaLocations)
            {
                if (location.WorldAreaLocationID == Id)
                {
                    worldAreaLocation = location;
                }
            }

            //
            // the specified ID was not found in the World
            // throw and exception
            //
            if (worldAreaLocation == null)
            {
                string feedbackMessage = $"The World Area Location ID {Id} does not exist in the current World.";
                throw new ArgumentException(Id.ToString(), feedbackMessage);
            }

            return(worldAreaLocation);
        }
Exemple #3
0
        public static string LookAround(WorldAreaLocation worldAreaLocation)
        {
            string messageBoxText =
                $"Current Location: {worldAreaLocation.CommonName}\n" +
                " \n" +
                worldAreaLocation.Description;

            return(messageBoxText);
        }
Exemple #4
0
        public static string AdventurerInfo(Adventurer gameAdventurer, WorldAreaLocation currentLocation)
        {
            string messageBoxText =
                $"\tAdventurer Name: {gameAdventurer.Name}\n" +
                $"\tAdventurer Age: {gameAdventurer.Age}\n" +
                $"\tAdventurer Race: {gameAdventurer.Race}\n" +
                " \n" +
                $"\tCurrent Location: {currentLocation.CommonName}\n" +
                " \n";

            return(messageBoxText);
        }
        /// <summary>
        /// determine if a location is accessible to the player
        /// </summary>
        /// <param name="WorldAreaeLocationId"></param>
        /// <returns>accessible</returns>
        public bool IsAccessibleLocation(int worldAreaLocationId, Adventurer adventurer)
        {
            WorldAreaLocation worldAreaLocation = GetWorldAreaLocationById(worldAreaLocationId);

            if (worldAreaLocation.PlayerCanAccess(adventurer) == true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        /// <summary>
        /// process the Adventurer action
        /// </summary>
        private void TravelAction()
        {
            //
            // get new location choice and update the current location property
            //
            _gameAdventurer.WorldAreaLocationID = _gameConsoleView.DisplayGetNextWorldAreaLocation();
            _currentLocation = _gameWorld.GetWorldAreaLocationById(_gameAdventurer.WorldAreaLocationID);

            //
            // display the new world area location info
            //
            _gameConsoleView.DisplayCurrentLocationInfo();
        }
Exemple #7
0
        /// <summary>
        /// display all relevant information about the current location
        /// </summary>
        public void DisplayCurrentLocationInfo()
        {
            WorldAreaLocation currentWorldAreaLocation = _gameWorld.GetWorldAreaLocationById(_gameAdventurer.WorldAreaLocationID);

            DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(currentWorldAreaLocation), ActionMenu.MainMenu, "");
        }
Exemple #8
0
        /// <summary>
        /// display all relevant information about the adventuere
        /// </summary>
        public void DisplayAdventurerInfo()
        {
            WorldAreaLocation currentWorldAreaLocation = _gameWorld.GetWorldAreaLocationById(_gameAdventurer.WorldAreaLocationID);

            DisplayGamePlayScreen("Adventurer Information", Text.AdventurerInfo(_gameAdventurer, currentWorldAreaLocation), ActionMenu.AdventurerMenu, "");
        }
Exemple #9
0
        /// <summary>
        /// method to manage the application setup and game loop
        /// </summary>
        private void ManageGameLoop()
        {
            AdventurerAction adventurerActionChoice = AdventurerAction.None;

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

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

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

            //
            // initialize the mission adventurer
            //
            InitializeMission();

            //
            // prepare game play screen
            //
            _currentLocation = _gameWorld.GetWorldAreaLocationById(_gameAdventurer.WorldAreaLocationID);
            _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, "");

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

                //
                // get next game action from player
                //
                adventurerActionChoice = GetNextAdventurerAction();

                //
                // choose an action based on the player's menu choice
                //
                switch (adventurerActionChoice)
                {
                case AdventurerAction.None:
                    break;

                case AdventurerAction.AdventurerInfo:
                    _gameConsoleView.DisplayAdventurerInfo();
                    break;

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

                case AdventurerAction.Travel:
                    TravelAction();
                    break;

                case AdventurerAction.AdventurerLocationsVisited:
                    _gameConsoleView.DisplayLocationsVisited();
                    break;

                case AdventurerAction.LookAt:
                    LookAtAction();
                    break;

                case AdventurerAction.PickUp:
                    PickUpAction();
                    break;

                case AdventurerAction.PutDown:
                    PutDownAction();
                    break;

                case AdventurerAction.Inventory:
                    _gameConsoleView.DisplayInventory();
                    break;

                case AdventurerAction.ListWorldAreaLocations:
                    _gameConsoleView.DisplayListOfWorldAreaLocations();
                    break;

                case AdventurerAction.ListGameObjects:
                    _gameConsoleView.DisplayListOfAllGameObjects();
                    break;

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

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

                case AdventurerAction.ListNonplayerCharacters:
                    _gameConsoleView.DisplayListOfAllNpcObjects();
                    break;

                case AdventurerAction.TravelMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdventurerMenu;
                    _gameConsoleView.DisplayGamePlayScreen("Adventurer Menu", "Select an operation from the menu.", ActionMenu.AdventurerMenu, "");
                    break;

                case AdventurerAction.ObjectMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.ObjectMenu;
                    _gameConsoleView.DisplayGamePlayScreen("Object Menu", "Select an operation from the menu.", ActionMenu.ObjectMenu, "");
                    break;

                case AdventurerAction.NonplayerCharacterMenu:
                    ActionMenu.currentMenu = ActionMenu.CurrentMenu.NpcMenu;
                    _gameConsoleView.DisplayGamePlayScreen("NPC Menu", "Select an operation from the menu.", ActionMenu.NpcMenu, "");
                    break;

                case AdventurerAction.TalkTo:
                    TalkToAction();
                    break;

                case AdventurerAction.Battle:
                    bool survived = BattleAction();
                    if (!survived)
                    {
                        _playingGame = false;
                    }
                    else
                    {
                        ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu;
                        _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, "");
                    }
                    break;

                case AdventurerAction.Exit:
                    _playingGame = false;
                    break;

                default:
                    break;
                }
            }

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