示例#1
0
        /// <summary>
        /// Bind this UI to a specific collection.
        /// </summary>
        /// <param name="collection"></param>
        public virtual void Initialize(ItemCollection collection)
        {
            Collection = collection;
            Slots      = new ItemSlotInterface[collection.Count];

            if (m_AutoGenerateSlots)
            {
                for (int i = 0; i < collection.Count; i++)
                {
                    GameObject instance = Instantiate(m_ItemSlotPrefab);

                    instance.name += " [Slot: " + i + "]";
                    instance.transform.SetParent(m_SlotContainer);
                    instance.transform.localScale = Vector3.one;

                    Slots[i] = instance.GetComponent <ItemSlotInterface>();
                    Slots[i].Initialize(i, this);
                }
            }
            else
            {
                for (int i = 0; i < collection.Count; i++)
                {
                    Transform         child         = m_SlotContainer.GetChild(i);
                    ItemSlotInterface slotInterface = child.GetComponent <ItemSlotInterface>();

                    child.name += " [Slot: " + i + "]";
                    Slots[i]    = slotInterface;
                    Slots[i].Initialize(i, this);
                }
            }

            Repaint();
        }
示例#2
0
 /// <summary>
 /// Repaints the interface based on our collection.
 /// </summary>
 public virtual void Repaint()
 {
     for (int i = 0; i < Slots.Length; i++)
     {
         ItemSlotInterface slot = Slots[i];
         slot.Repaint(Collection[i]);
     }
 }
示例#3
0
        public void OnDrop(ItemSlotInterface slot)
        {
            if (slot.Item == null)
            {
                return;
            }

            slot.Interface.Collection.Inventory.DropItem(slot.Item, slot.Index, slot.Interface.Collection);
        }
 /// <summary>
 /// Sets the hovered slot.
 /// </summary>
 /// <param name="slot">The slot.</param>
 public void SetHovered(ItemSlotInterface slot)
 {
     Hovered = slot;
 }
 public SlotDragHandlerData(ItemSlotInterface sourceSlot)
 {
     Source = sourceSlot;
 }