public static string LookAt(GameObject gameObject) { string messageTextBox = ""; messageTextBox = $"{gameObject.Name}\n" + " \n" + gameObject.Description + " \n" + " \n"; if (gameObject is TravelerObject) { TravelerObject travelerObject = gameObject as TravelerObject; messageTextBox += $"The {travelerObject.Name} has a value of {travelerObject.Value} and "; if (travelerObject.CanInventory) { messageTextBox += "may not be added to your inventory."; } else { messageTextBox += "may not be added to your inventory."; } } else { messageTextBox += $"The {gameObject.Name} may not be added to your inventory."; } return(messageTextBox); }
/// <summary> /// process the Pick Up action /// </summary> private void PickUpAction() { // // display a list of traveler objects in space-time location and get a player choice // int travelerObjectToPickUpId = _gameConsoleView.DisplayGetTravelerObjectToPickUp(); // // add the traveler object to traveler's inventory // if (travelerObjectToPickUpId != 0) { // // get the game object from the universe // TravelerObject travelerObject = _gameUniverse.GetGameObjectById(travelerObjectToPickUpId) as TravelerObject; // // note: traveler object is added to list and the space-time location is set to 0 // _gameTraveler.Inventory.Add(travelerObject); travelerObject.SpaceTimeLocationId = 0; // // display confirmation message // _gameConsoleView.DisplayConfirmTravelerObjectAddedToInventory(travelerObject); } }
public void DisplayGameObjectInfo(GameObject gameObject, int[] playerPosition, string[,] map) { DisplayGamePlayScreen("Item", Text.LookAt(gameObject), ActionMenu.MainMenu, ""); // // future change here -> add item menu and check if player wants to add to inventory or not // if (gameObject is TravelerObject) { TravelerObject travelerObject = gameObject as TravelerObject; if (travelerObject.CanInventory == true) { _gameTraveler.Inventory.Add(travelerObject); map[playerPosition[0], playerPosition[1]] = "-"; travelerObject.CanInventory = false; } else { } } DisplayMessage("Press any key to continue..."); }
private void HandleObjectAddedToInventory(object gameObject, EventArgs e) { if (gameObject.GetType() == typeof(TravelerObject)) { TravelerObject travelerObject = gameObject as TravelerObject; switch (travelerObject.Type) { case TravelerObjectType.Poison: _gameTraveler.Lives -= 1; break; case TravelerObjectType.Medicine: _gameTraveler.Health += travelerObject.Value; // // add life if health greater than 100 // if (_gameTraveler.Health >= 100) { _gameTraveler.Health = 100; _gameTraveler.Lives += 1; } // // remove object from game // if (travelerObject.IsConsumable) { travelerObject.SpaceTimeLocationId = -1; } break; case TravelerObjectType.Key: foreach (SpaceTimeLocation location in _gameUniverse.SpaceTimeLocations) { if (!location.Accessible) { location.Accessible = true; } } break; case TravelerObjectType.BadMedicine: _gameTraveler.Health -= travelerObject.Value; if (_gameTraveler.Health <= 0) { _gameTraveler.Lives -= 1; _gameTraveler.Health = 100; } break; case TravelerObjectType.Information: break; default: break; } } }
private void PickUpAction() { // // display a list of traveler objects in space-time location and get a player choice // int travelerObjectToPickUpId = _gameConsoleView.DisplayGetTravelerObjectsToPickUp(); // // add the traveler object to traveler's inventory // if (travelerObjectToPickUpId != 0) { // // get the game object from the universe // TravelerObject travelerObject = _gameUniverse.GetGameObjectById(travelerObjectToPickUpId) as TravelerObject; // // note: traveler object is added to list and space-time location is set to 0 _gameTraveler.Inventory.Add(travelerObject); travelerObject.SpaceTimeLocationId = 0; _gameTraveler.ExperiencePoints += travelerObject.ExperiencePoints; if (travelerObject.Id == 11 && _gameTraveler.Inventory.Contains(_gameUniverse.GetGameObjectById(12)) || travelerObject.Id == 12 && _gameTraveler.Inventory.Contains(_gameUniverse.GetGameObjectById(11))) { _gameTraveler.Lives += 1; _gameConsoleView.DisplayGamePlayScreen("Pick Up Game Object", Text.HeartStonesFound(travelerObject), ActionMenu.MainMenu, ""); } else if (travelerObject.Id == 13) { _gameTraveler.Health -= 30; _gameConsoleView.DisplayGamePlayScreen("Pick Up Game Object", Text.RadiarionFound(travelerObject), ActionMenu.MainMenu, ""); } else if (travelerObject.Id == 14) { _gameTraveler.Lives -= 1; _gameTraveler.Inventory.Remove(travelerObject); _gameTraveler.SpaceTimeLocationID = -1; _gameConsoleView.DisplayGamePlayScreen("Pick Up Game Object", Text.BombFound(travelerObject), ActionMenu.MainMenu, ""); } else if (travelerObject.Id == 15) { int newId; int currentId = _currentLocation.SpaceTimeLocationID; do { newId = _gameConsoleView.GetRandomNumber(); _gameTraveler.SpaceTimeLocationID = newId; _currentLocation = _gameUniverse.GetSpaceTimeLocationById(_gameTraveler.SpaceTimeLocationID); } while (newId == currentId); _gameConsoleView.DisplayGamePlayScreen("Pick Up Game Object", Text.Transporter(travelerObject, _currentLocation), ActionMenu.MainMenu, ""); } else { _gameConsoleView.DisplayConfirmTravelerObjectAddedToInventory(travelerObject); } } }
/// <summary> /// confirm object added to inventory /// </summary> /// <param name="objectAddedToInventory">game object</param> public void DisplayConfirmTravelerObjectAddedToInventory(TravelerObject objectAddedToInventory) { if (objectAddedToInventory.PickUpMessage != null) { DisplayGamePlayScreen("Pick Up Game Object", objectAddedToInventory.PickUpMessage, ActionMenu.MainMenu, ""); } else { DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.MainMenu, ""); } }
///<summary> /// this method tests and casts all appropriate game objects to traveler objects /// </summary> private void HandleObjectAddedToInventory(object gameObject, EventArgs e) { if (gameObject.GetType() == typeof(TravelerObject)) { TravelerObject travelerObject = gameObject as TravelerObject; switch (travelerObject.Type) { case TravelerObjectType.Food: break; case TravelerObjectType.Medicine: _gameTraveler.Health += travelerObject.Value; // // add life if health greater than 100 // if (_gameTraveler.Health >= 100) { _gameTraveler.Health = 100; _gameTraveler.Lives += 1; } // // remove object from game // if (travelerObject.IsConsumable) { travelerObject.SpaceTimeLocationId = -1; } // // remove life if poisoned // if (travelerObject.IsDeadly) { _gameTraveler.Lives -= 1; } break; case TravelerObjectType.Weapon: break; case TravelerObjectType.Treasure: break; case TravelerObjectType.Information: break; default: break; } } }
public int DisplayGetTravelerObjectToPickUp() { int gameObjectId = 0; bool validGameObjectId = false; // // get a list of traveler objects in the current space-time location // List <TravelerObject> travelerObjectsInSpaceTimeLocation = _gameUniverse.GetTravelerObjectsBySpaceTimeLocationId(_gameTraveler.SpaceTimeLocationID); if (travelerObjectsInSpaceTimeLocation.Count > 0) { DisplayGamePlayScreen("Pick Up Game Object", Text.GameObjectsChooseList(travelerObjectsInSpaceTimeLocation), ActionMenu.MainMenu, ""); 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 (_gameUniverse.IsValidTravelerObjectByLocationId(gameObjectId, _gameTraveler.SpaceTimeLocationID)) { TravelerObject travelerObject = _gameUniverse.GetGameObjectById(gameObjectId) as TravelerObject; if (travelerObject.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.MainMenu, ""); } return(gameObjectId); }
public int DisplayGetInventoryObjectToPutDown() { int travelerObjectId = 0; bool validInventoryObjectId = false; if (_gameTraveler.Inventory.Count > 0) { DisplayGamePlayScreen("Put Down Game Object", Text.GameObjectsChooseList(_gameTraveler.Inventory), ActionMenu.MainMenu, ""); 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 travelerObjectId); // // find object in inventory // note: LINQ used, but a foreach loop may also be used // TravelerObject objectToPutDown = _gameTraveler.Inventory.FirstOrDefault(o => o.Id == travelerObjectId); // // 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.MainMenu, ""); } return(travelerObjectId); }
private void PickUpAction() { // // display a list of traveler objects in space-time location and get a player choice // int travelerObjectToPickUpId = _gameConsoleView.DisplayGetTravelerObjectToPickUp(); // // add the traveler object to traveler's inventory // if (travelerObjectToPickUpId != 0) { // // get the game object from the universe // TravelerObject travelerObject = _gameUniverse.GetGameObjectById(travelerObjectToPickUpId) as TravelerObject; // // note: traveler object is added to list and the space-time location is set to 0 // _gameTraveler.Inventory.Add(travelerObject); travelerObject.SpaceTimeLocationId = 0; // // display confirmation message // _gameConsoleView.DisplayComfirmTravelerObjectAddedToInventory(travelerObject); // // update experience points for adding objects // _gameTraveler.ExperiencePoints += _gameTraveler.ExperiencePoints; // // add life if health greater than 100 // if (_gameTraveler.Health >= 100) { _gameTraveler.Health = 100; _gameTraveler.Lives += 1; } } }
/// <summary> /// process the Put Down action /// </summary> private void PutDownAction() { // // display a list of traveler objects in inventory and get a player choice // int inventoryObjectToPutDownId = _gameConsoleView.DisplayGetInventoryObjectToPutDown(); // // get the game object from the universe // TravelerObject travelerObject = _gameUniverse.GetGameObjectById(inventoryObjectToPutDownId) as TravelerObject; // // remove the object from inventory and set the space-time location to the current value // travelerObject.SpaceTimeLocationId = _gameTraveler.SpaceTimeLocationID; // // display confirmation message // _gameConsoleView.DisplayConfirmTravelerObjectRemovedFromInventory(travelerObject); }
public void DisplayConfirmTravelerObjectRemovedFromInventory(TravelerObject objectRemovedFromInventory) { DisplayGamePlayScreen("Put Down Game Object", $"The {objectRemovedFromInventory.Name} has been removed from your inventory.", ActionMenu.MainMenu, ""); }
/// <summary> /// confirm object added to inventory /// </summary> /// <param name="objectAddedToInventory">game object</param> public void DisplayConfirmTravelerObjectAddedToInventory(TravelerObject objectAddedToInventory) { DisplayGamePlayScreen("Pick Up Game Object", $"The {objectAddedToInventory.Name} has been added to your inventory.", ActionMenu.ObjectMenu, ""); }