/// <summary> /// process the Pick Up action /// </summary> private void PickUpAction() { // // display a list of Adventurer objects in world area location and get a player choice // int adventurerObjectToPickUpId = _gameConsoleView.DisplayGetAdventuereObjectToPickUp(); // // add the Adventurer object to Adventurer's inventory // if (adventurerObjectToPickUpId != 0) { // // get the game object from the World // AdventurerObject AdventurerObject = _gameWorld.GetGameObjectById(adventurerObjectToPickUpId) as AdventurerObject; // // note: Adventurer object is added to list and the world area location is set to 0 // _gameAdventurer.Inventory.Add(AdventurerObject); AdventurerObject.WorldAreaLocationId = 0; // // display confirmation message // _gameConsoleView.DisplayConfirmAdventurerObjectAddedToInventory(AdventurerObject); } }
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); }
/// <summary> /// display the information required for the player to choose an object to pick up /// </summary> /// <returns>game object Id</returns> public int DisplayGetAdventuereObjectToPickUp() { int gameObjectId = 0; bool validGameObjectId = false; // // get a list of adventuere objects in the current world area location // List <AdventurerObject> adventurerObjectsInWorldAreaLocation = _gameWorld.GetAdventurerObjectsByWorldAreaLocationId(_gameAdventurer.WorldAreaLocationID); if (adventurerObjectsInWorldAreaLocation.Count > 0) { DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(adventurerObjectsInWorldAreaLocation), 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 (_gameWorld.IsValidAdventurerObjectByLocationId(gameObjectId, _gameAdventurer.WorldAreaLocationID)) { AdventurerObject adventurerObject = _gameWorld.GetGameObjectById(gameObjectId) as AdventurerObject; if (adventurerObject.CanInventory) { validGameObjectId = true; } else { ClearInputBox(); DisplayInputErrorMessage("It appears you may not inventory that object. Please try again."); } } else { ClearInputBox(); DisplayInputErrorMessage("It appears you 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); }
/// <summary> /// display the information required for the player to choose an object to pick up /// </summary> /// <returns>game object Id</returns> 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); }
/// <summary> /// process the Put Down action /// </summary> private void PutDownAction() { // // display a list of Adventurer objects in inventory and get a player choice // int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown(); // // get the game object from the World // AdventurerObject adventurerObject = _gameWorld.GetGameObjectById(inventoryObjectToPutDownId) as AdventurerObject; // // remove the object from inventory and set the world area location to the current value // _gameAdventurer.Inventory.Remove(adventurerObject); adventurerObject.WorldAreaLocationId = _gameAdventurer.WorldAreaLocationID; // // display confirmation message // _gameConsoleView.DisplayConfirmAdventurerObjectRemovedFromInventory(adventurerObject); }
/// <summary> /// confirm object removed from inventory /// </summary> /// <param name="objectRemovedFromInventory">game object</param> public void DisplayConfirmAdventurerObjectRemovedFromInventory(AdventurerObject objectRemovedFromInventory) { DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, ""); }
/// <summary> /// confirm object added to inventory /// </summary> /// <param name="objectAddedToInventory">game object</param> public void DisplayConfirmAdventurerObjectAddedToInventory(AdventurerObject objectAddedToInventory) { DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, ""); }