Example #1
0
        private void LookAtAction()
        {
            //display list of traveler objects in location id and get player choice
            int gameObjectToLookAtId = _gameConsoleView.DisplayGetGameObjectToLookAt();

            //display game object info
            if (gameObjectToLookAtId != 0)
            {
                //gets game object from world
                GameObject gameObject = _worldContents.GetGameOjbectById(gameObjectToLookAtId);

                //displays that item info
                _gameConsoleView.DisplayGameObjectInfo(gameObject);
            }
        }
Example #2
0
        /// <summary>
        /// initialize the major game objects
        /// </summary>
        private void InitializeGame()
        {
            _gameSurvivor    = new Survivor();
            _worldContents   = new WorldContents();
            _gameConsoleView = new ConsoleView(_gameSurvivor, _worldContents);
            _gameConsoleView.DisplayStatusBox();
            SurvivorObject survivorObject;
            Friendly       friendly;

            _playingGame = true;

            //add event handler for adding/subtracting to/from inventory
            foreach (GameObject gameObject in _worldContents.GameObjects)
            {
                if (gameObject is SurvivorObject)
                {
                    survivorObject = gameObject as SurvivorObject;
                    survivorObject.ObjectAddedToInventory += HandleObjectAddedToInventory;
                }
            }

            //event handler for speaking with and unlocking room
            foreach (Npc npc in _worldContents.Npcs)
            {
                if (npc is Friendly)
                {
                    friendly = npc as Friendly;
                    friendly.FriendlyTalkedTo += HandleNpcTalkedTo;
                }
            }

            //add initial items to the survivor's inventory
            _gameSurvivor.Inventory.Add(_worldContents.GetGameOjbectById(5) as SurvivorObject);
            _gameSurvivor.Inventory.Add(_worldContents.GetGameOjbectById(6) as SurvivorObject);

            Console.CursorVisible = false;
        }
Example #3
0
        public int DisplayGetSurvivorObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //get list of survivor objects in current location
            List <SurvivorObject> survivorObjectsInCurrentLocation = _worldContents.GetSurvivorObjectsByLocationId(_gameSurvivor.LocationId);

            if (survivorObjectsInCurrentLocation.Count > 0)
            {
                DisplayGamePlayScreen("Pick up item", Text.GameObjectsChooseList(survivorObjectsInCurrentLocation), ActionMenu.ObjectMenu, "");

                while (!validGameObjectId)
                {
                    //get int from user
                    GetInteger($"Enter the Id number of the item you want to pick up:", 0, 0, out gameObjectId);

                    //validate integer as valid object id AND in current location
                    if (_worldContents.IsValidGameObjectByLocationId(gameObjectId, _gameSurvivor.LocationId))
                    {
                        SurvivorObject survivorObject = _worldContents.GetGameOjbectById(gameObjectId) as SurvivorObject;
                        if (survivorObject.CanInventory)
                        {
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("You cannot pick that item up. Try again.");
                        }
                    }
                    else
                    {
                        DisplayInputErrorMessage("You entered an invalid item Id, try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick up item", "There are no items here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }