/// <summary> /// Finds and returns all instances of Items in the Inventory with any of the designated ItemTypes. /// </summary> /// <param name="itemTypes">The ItemTypes enum values to look for.</param> /// <returns>An array of all items with any of the designated ItemTypes. If none are found, an empty array.</returns> public Item[] FindItems(Item.ItemCategories itemCategory, Item.ItemTypes itemTypes) { List <Item> itemsToFind = new List <Item>(); //If searching for Key Items, add all Key Items to the list if (itemCategory == Item.ItemCategories.KeyItem) { itemsToFind.AddRange(KeyItems); } else { //Look in the Item list for all Items with these ItemTypes and add them itemsToFind.AddRange(Items.FindAll((item) => UtilityGlobals.ItemTypesHasFlag(item.ItemType, itemTypes) == true)); } return(itemsToFind.ToArray()); }
public override Item GetItemOfType(Item.ItemTypes itemTypes) { //If the enemy isn't holding anything, simply return null; if (HeldCollectible == null) { return(null); } //See if the enemy is holding an item Item item = HeldCollectible as Item; //If the enemy is holding an item and the item has the ItemTypes specified, return it if (item != null && UtilityGlobals.ItemTypesHasFlag(item.ItemType, itemTypes) == true) { return(item); } return(null); }
/// <summary> /// Finds and returns the first Item in the Inventory with any of the designated ItemTypes. /// </summary> /// <param name="itemTypes">The ItemTypes enum values to look for.</param> /// <returns>An item with any of the designated ItemTypes. If not found, null.</returns> public Item FindItem(Item.ItemCategories itemCategory, Item.ItemTypes itemTypes) { return(Items.Find((item) => UtilityGlobals.ItemTypesHasFlag(item.ItemType, itemTypes) == true)); }