Ejemplo n.º 1
0
 public void AddSlots(int slotCount)
 {
     for (int i = 0; i < slotCount; i++)
     {
         SlotScript slot = Instantiate(slotPrefab, transform).GetComponent <SlotScript>();
         slot.MyBag = this;
         slots.Add(slot);
     }
 }
Ejemplo n.º 2
0
        private bool MergeItems(SlotScript from)
        {
            if (IsEmpty)
            {
                return(false);
            }
            if (from.MyItem.GetType() == MyItem.GetType() && !IsFull)
            {
                // how many free slots
                int free = MyItem.MyStackSize - MyCount;

                for (int i = 0; i < free; i++)
                {
                    AddItem(from.MyItems.Pop());
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 private bool SwapItems(SlotScript from)
 {
     if (IsEmpty)
     {
         return(false);
     }
     if (from.MyItem.GetType() != MyItem.GetType() || from.MyCount + MyCount > MyItem.MyStackSize)
     {
         // copy all the items we need to swap from A
         ObservableStack <Item> tmpFrom = new ObservableStack <Item>(from.MyItems);
         // clear slot A
         from.MyItems.Clear();
         // all items from slot b and copy them into a
         from.AddItems(MyItems);
         // clear B
         MyItems.Clear();
         // move items from A to B
         AddItems(tmpFrom);
         return(true);
     }
     return(false);
 }