public KillerNonPlayableCharacter(NonPlayableCharacter nonPlayableCharacter) : base(nonPlayableCharacter) { Responses = nonPlayableCharacter.Responses; Responses.Remove(ConversationType.INVENTORY); Item knife = new Item("Knife"); Inventory.Add(knife); Responses.Add(ConversationType.INVENTORY, new RandomList <string> { "I am currently carrying the following: " + Inventory, "In my bag I have: " + Inventory, Inventory + " is all I have.", "I have :" + Inventory + ". And money ain't a problem." }); // Removes an item to make sure all characters have the same number of items //Inventory.RemoveAt(0); }
public KillerNonPlayableCharacter(Character character, Inventory inventory, Dictionary <ConversationType, RandomList <String> > responses, String title, int id) : base(character, inventory, responses, title, id) { // Removes an item to make sure all characters have the same number of items //Inventory.RemoveAt(0); // Add Killing Weapon Inventory.Add(new Item("Knife")); // Add Inventory Responses Responses.Remove(ConversationType.INVENTORY); String list = Inventory.ToString(); Responses.Add(ConversationType.INVENTORY, new RandomList <string> { "I am currently carrying the following " + list, "All I have is the following " + list, list + " are all the items I posses right now.", "I have " + list + ", and money ain't a problem." }); }
/// <summary> /// Method that uses the chosen item by the player. /// </summary> /// <param name="count">Maximum number possible to input.</param> public void UseItems(int count) { // Varible to hold player input string choice = ""; // Variable index int i = 0; // Do cyce while input is invalid do { // Ask and save player input Console.Write("\n> "); choice = Console.ReadLine(); // If input is a number convert string input to int if (choice != "") { i = Convert.ToInt32(choice); } } while (i < 0 || i > count - 1 || choice == ""); // If input is 0 if (i == 0) { // Go back to grid screen without losing a turn Health++; return; } // If input is not 0 else { // Define game object in inventory // Initially, i = player input IGameObject go = Inventory[i - 1]; // If game object is Food if (go is Food) { // Remove food from inventory Inventory.RemoveAt(i - 1); // Remove food item from player weight Weight -= (go as Item).Weight; // If player health is more than 100 if ((Health + (go as Food).HPIncrease) > 100) { // Health stays 100 Health = 100; } // If player health is less than 100 else { // Increase health by the respective HPIncrease of food Health += (go as Food).HPIncrease; } } // If game object is a weapon else if (go is Weapon) { // Remove weapon from inventory Inventory.RemoveAt(i - 1); // If there is no equipped weapon if (Equipped == null) { // Equipp chosen weapon Equipped = (go as Weapon); } // If there is a equipped weapon else { // Add previous weapon to inventory Inventory.Add(Equipped as Weapon); // Equipp chosen weapon Equipped = (go as Weapon); } } } }
/// <summary> /// Method that picks up the chosen item by the player. /// </summary> /// <param name="grid">Game Grid.</param> /// <param name="count">Maximum number possible to input.</param> public void PickUpItems(GridManager grid, int count) { // Variable to hold if player picked something up or not bool picked = false; // Varible to hold player input string choice = ""; // Variable index int i = 0; // Do cyce while input is invalid do { // Ask and save player input Console.Write("\n> "); choice = Console.ReadLine(); // If input is a number convert string input to int if (choice != "") { i = Convert.ToInt32(choice); } } while (i < 0 || i > count - 1 || choice == ""); // If input is 0 if (i == 0) { // Go back to grid screen without losing a turn Health++; return; } // If input is not 0 else { // Do cycle while player does not pick up an item do { // Define game object in player position // Initially, i = player input IGameObject go = grid.GameGrid[PlayerPos.X, PlayerPos.Y][i]; // If game object is an Item if (go is Item) { // If item does not fit in bag if ((Weight + (go as Item).Weight) > MaxWeight) { // Send error message. Console.WriteLine("You can't carry anymore."); Console.ReadLine(); return; } // If item fits in bag else { // Add item to Inventory Inventory.Add(go as Item); // Add item weight to player weight Weight += (go as Item).Weight; // Remove item from grid grid.GameGrid[PlayerPos.X, PlayerPos.Y].RemoveAt(i); grid.GameGrid[PlayerPos.X, PlayerPos.Y].Add(null); // Player picked something picked = true; } } // If game object is Map else if (go is Map) { // Remove map from grid grid.GameGrid[PlayerPos.X, PlayerPos.Y].Remove(grid.Map); grid.GameGrid[PlayerPos.X, PlayerPos.Y].Add(null); // Make the whole level explored foreach (GameTile gt in grid.GameGrid) { gt.Explored = true; } // Player picked something picked = true; } // If game object is not an Item or Map else { // Increment index i++; } } while (!picked); } }
public void EquipItem(Item item) { Inventory.Add(item); }