示例#1
0
 public bool HasAllTheseItems(List <ItemQuantity> items)
 {
     foreach (ItemQuantity item in items)
     {
         if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity)
         {
             return(false);
         }
     }
     return(true);
 }
示例#2
0
        //methods

        public bool HasAllTheseItems(List <ItemQuantity> itemQuantities)
        {
            foreach (ItemQuantity itemQuantity in itemQuantities)
            {
                if (Inventory.Count(i => i.Name == ItemFactory.CreateGameItem(itemQuantity.ItemId).Name) < itemQuantity.Quantity)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#3
0
        public bool HasAllTheseItems(List <ItemQuantity> items) // this function check if the player has all the items required to complete the quest
        {                                                       // function accepts a list of ItemQuantity objects and looks through the playr's inventory
            foreach (ItemQuantity item in items)
            {
                if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity) //if the count of items is less than the number required in the parameter, the function returns false; if the player has a large enough quantity for all the items passed into the function it will return true
                {
                    return(false);
                }
            }

            return(true);
        }
示例#4
0
文件: Player.cs 项目: ChuyueL/wpf-rpg
        public bool HasAllTheseItems(List <ItemQuantity> items)
        {
            foreach (ItemQuantity item in items)
            {
                //Count how many items player has in their inventory where the ItemID matches.
                //If the count is less than the count of the passed in parameter, return false
                //as player does not have enough items.
                if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity)
                {
                    return(false);
                }
            }

            //If we get through all the items in the list and we haven't returned false for any,
            //player has enough items so return true.
            return(true);
        }