/// <summary> /// process the Pick Up action /// </summary> private void PickUpAction() { // // display a list of hero objects in room location and get a player choice // int heroObjectToPickUpId = _gameConsoleView.DisplayGetHeroObjectToPickUp(); // // add the hero object to hero's inventory // if (heroObjectToPickUpId != 0) { // // get the game object from the universe // HeroObject heroObject = _gameHotel.GetGameObjectById(heroObjectToPickUpId) as HeroObject; // // note: hero object is added to list and the room location is set to 0 // _gameHero.Inventory.Add(heroObject); heroObject.RoomLocationID = 0; // // display confirmation message // _gameConsoleView.DisplayConfirmHeroObjectAddedToInventory(heroObject); } }
public static string LookAt(GameObject gameObject) { string messageBoxText = ""; messageBoxText = $"{gameObject.Name}\n" + " \n" + gameObject.Description + " \n" + " \n"; if (gameObject is HeroObject) { HeroObject heroObject = gameObject as HeroObject; messageBoxText += $"The {heroObject.Name} has a value of {heroObject.Value} and "; if (heroObject.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); }
public int DisplayGetHeroObjectToPickUp() { int gameObjectId = 0; bool validGameObjectId = false; // // get a list of hero objects in the current room location // List <HeroObject> heroObjectsInRoomLocation = _gameHotel.GetHeroObjectsByRoomLocationId(_gameHero.RoomLocationID); if (heroObjectsInRoomLocation.Count > 0) { DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(heroObjectsInRoomLocation), 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 (_gameHotel.IsValidHeroObjectByLocationId(gameObjectId, _gameHero.RoomLocationID)) { HeroObject heroObject = _gameHotel.GetGameObjectById(gameObjectId) as HeroObject; if (heroObject.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); }
public int DisplayGetInventoryObjectToPutDown() { int heroObjectId = 0; bool validInventoryObjectId = false; if (_gameHero.Inventory.Count > 0) { DisplayGamePlayScreen("Put Down Game Object", Text.GameObjectsChooseList(_gameHero.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 heroObjectId); // // find object in inventory // note: LINQ used, but a foreach loop may also be used // HeroObject objectToPutDown = _gameHero.Inventory.FirstOrDefault(o => o.Id == heroObjectId); // // 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(heroObjectId); }
/// <summary> /// process the Put Down action /// </summary> private void PutDownAction() { // // display a list of hero objects in inventory and get a player choice // int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown(); // // get the game object from the universe // HeroObject heroObject = _gameHotel.GetGameObjectById(inventoryObjectToPutDownId) as HeroObject; // // remove the object from inventory and set the room location to the current value // _gameHero.Inventory.Remove(heroObject); heroObject.RoomLocationID = _gameHero.RoomLocationID; // // display confirmation message // _gameConsoleView.DisplayConfirmHeroObjectRemovedFromInventory(heroObject); }
public void DisplayConfirmHeroObjectRemovedFromInventory(HeroObject objectRemovedFromInventory) { DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.ObjectMenu, ""); }
public void DisplayConfirmHeroObjectAddedToInventory(HeroObject objectAddedToInventory) { DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, ""); }