コード例 #1
0
    /// <summary>
    /// Create a portable item from the given details.
    /// </summary>
    /// <param name="details">The item details to use.</param>
    /// <returns>An item based on the given details.</returns>
    public PortableItem CreateItem(PortableItemDetails details)
    {
        PortableItem item = ScriptableObject.CreateInstance <PortableItem>();

        item.details = details;
        return(item);
    }
コード例 #2
0
 /// <summary>
 /// See if the inventory contains an item with the given details.
 /// </summary>
 /// <param name="details">The details to look for.</param>
 /// <returns>
 /// A boolean denoting if an item with the details was present.
 /// </returns>
 public bool Contains(PortableItemDetails details)
 {
     foreach (PortableItem item in this.items)
     {
         if (item != null && item.details == details)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #3
0
 /// <summary>
 /// Check if the given item based on the details is present.
 /// </summary>
 /// <param name="details">The details to compare to.</param>
 /// <returns>Boolean representing if the item is present.</returns>
 /// <remarks>
 /// <para>
 /// If the list of items is <c>null</c> or empty then this is always false.
 /// </para>
 /// If the provided details are <c>null</c> then this is false.
 /// </para>
 /// </remarks>
 public bool Contains(PortableItemDetails details)
 {
     if (details == null)
     {
         return(false);
     }
     foreach (PortableItemDetails d in this.items)
     {
         if (d == details)
         {
             return(true);
         }
     }
     return(false);
 }