Ejemplo n.º 1
0
        public static string LookAt(GameObject gameObject)
        {
            string messageBoxText = "";

            messageBoxText =
                $"{gameObject.Name}\n" +
                " \n" +
                gameObject.Description + " \n" +
                " \n";
            if (gameObject is AdventurerObject)
            {
                AdventurerObject adventurerObject = gameObject as AdventurerObject;

                messageBoxText += $"The {adventurerObject.Name} has a value of {adventurerObject.Value} and ";

                if (adventurerObject.CanInventory)
                {
                    messageBoxText += "may be added to your inventory.";
                }
                else
                {
                    messageBoxText += "may not be added to your inventory.";
                }
            }
            else
            {
                messageBoxText += $"The {gameObject.Name} may not be added to your inventory.";
            }

            return(messageBoxText);
        }
        private void PickUpAction()
        {
            //
            // display a list of adventurer object in dungeon location and get a player choice
            //
            int adventurerObjectToPickUpId = _gameConsoleView.DisplayGetAdventurerObjectToPickUp();

            //
            // add the adventurer object to adventurer's inventory
            //
            if (adventurerObjectToPickUpId != 0)
            {
                //
                // get the game object from the dungeon
                //
                AdventurerObject adventurerObject = _gameDungeon.GetGameObjectById(adventurerObjectToPickUpId) as AdventurerObject;

                //
                // note: adventurer object is added to list and the dungeon location of the object is set to 0
                //
                _gameAdventurer.Inventory.Add(adventurerObject);
                adventurerObject.DungeonLocationId = 0;

                //
                // display confirmation message
                //
                _gameConsoleView.DisplayConfirmAdventurerObjectAddedToInventory(adventurerObject);
            }
        }
Ejemplo n.º 3
0
        public int DisplayGetAdventurerObjectToPickUp()
        {
            int  gameObjectId      = 0;
            bool validGameObjectId = false;

            //
            // get a list of adventurer objects in the current dungeon location
            //
            List <AdventurerObject> adventurerObjectsInDungeonLocation = _gameDungeon.GetAdventurerObjectsByDungeonLocationId(_gameAdventurer.DungeonLocationID);

            if (adventurerObjectsInDungeonLocation.Count > 0)
            {
                DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(adventurerObjectsInDungeonLocation), ActionMenu.ObjectMenu, "");

                while (!validGameObjectId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the ID number of the object you wish to add to your inventory: ", 0, 0, out gameObjectId);

                    //
                    // validate integer as a valid game object id and in current location
                    //
                    if (_gameDungeon.IsValidAdventurerObjectByLocationId(gameObjectId, _gameAdventurer.DungeonLocationID))
                    {
                        AdventurerObject adventurerObject = _gameDungeon.GetGameObjectById(gameObjectId) as AdventurerObject;
                        if (adventurerObject.CanInventory)
                        {
                            validGameObjectId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("It appears you may not add that item to your inventory. Please try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears your entered an invalid game object ID. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no game objects here.", ActionMenu.ObjectMenu, "");
            }

            return(gameObjectId);
        }
Ejemplo n.º 4
0
        public int DisplayGetInventoryObjectToPutDown()
        {
            int  adventurerObjectId     = 0;
            bool validInventoryObjectId = false;

            if (_gameAdventurer.Inventory.Count > 0)
            {
                DisplayGamePlayScreen("Put Down Game Object", Text.GameObjectsChooseList(_gameAdventurer.Inventory), ActionMenu.ObjectMenu, "");

                while (!validInventoryObjectId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the ID number of the object you wish to remove from your inventory: ", 0, 0, out adventurerObjectId);

                    //
                    // find object in inventory
                    // note: LINQ used, but a foreach loop may also be used
                    //
                    AdventurerObject objectToPutDown = _gameAdventurer.Inventory.FirstOrDefault(o => o.Id == adventurerObjectId);

                    //
                    // validate object in inventory
                    //
                    if (objectToPutDown != null)
                    {
                        validInventoryObjectId = true;
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you entered the ID of an object not in the inventory. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Pick Up Game Object", "It appears there are no objects currently in inventory.", ActionMenu.ObjectMenu, "");
            }

            return(adventurerObjectId);
        }
        private void PutDownAction()
        {
            //
            // display a list of adventurer object in dungeon location and get a player choice
            //
            int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown();

            //
            // get the game object from the dungeon
            //
            AdventurerObject adventurerObject = _gameDungeon.GetGameObjectById(inventoryObjectToPutDownId) as AdventurerObject;

            //
            // remove the object from inventory and set the dungeon location to the current value
            //
            _gameAdventurer.Inventory.Remove(adventurerObject);
            adventurerObject.DungeonLocationId = _gameAdventurer.DungeonLocationID;

            //
            // display confirmation message
            //
            _gameConsoleView.DisplayConfirmAdventurerObjectRemovedFromInventory(adventurerObject);
        }
Ejemplo n.º 6
0
 public void DisplayConfirmAdventurerObjectRemovedFromInventory(AdventurerObject objectRemovedFromInventory)
 {
     DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, "");
 }
Ejemplo n.º 7
0
 public void DisplayConfirmAdventurerObjectAddedToInventory(AdventurerObject objectAddedToInventory)
 {
     DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, "");
 }