コード例 #1
0
    /// <summary>
    /// Used to split item.
    /// New instance should have the same parent. Sum of quantities shouldnt change.
    /// </summary>
    /// <returns>One piece of this item as the new instance.</returns>
    protected override StackableItem splitItem()
    {
        GameObject        newItem = Instantiate(gameObject, transform.parent);
        SimpleCollectible col     = newItem.GetComponent <SimpleCollectible>();

        col.quantity = 1;
        this.quantity--;
        return(col);
    }
コード例 #2
0
 /// <summary>
 /// Used to check if two types of items are stackable.
 /// It takes type into account
 /// </summary>
 /// <param name="item">Item we want to stack with ourselves.</param>
 /// <returns>true if possible, false otherwise.</returns>
 public override bool areItemsStackable(ItemObject item)
 {
     if (base.areItemsStackable(item))
     {
         SimpleCollectible collItem = (SimpleCollectible)item;
         return(collItem.type == this.type);
     }
     else
     {
         return(false);
     }
 }