public void OnSlotChange(InventoryUISlot newSlot, InventoryUIObject inventoryUIObject)
        {
            bool isSpecial = inventoryUIObject.GetInventoryObject() == inventory.GetSpecialInventoryObject();

            // normal object to special
            if (isSpecial == false && newSlot == slotSpecial)
            {
                inventory.MoveNormalInventoryObjectToSpecial(inventoryUIObject.GetInventoryObject());
            }

            // special object to normal
            if (isSpecial && newSlot != slotSpecial)
            {
                inventory.MoveSpecialInventoryObjectToNormal(inventoryUIObject.GetInventoryObject());
            }

            // set wish pos
            if (newSlot != slotSpecial)
            {
                inventoryUIObject.GetInventoryObject().SetCurrentPos(slots.IndexOf(newSlot));
            }
            else
            {
                inventoryUIObject.GetInventoryObject().SetCurrentPos(0);
            }
        }
Example #2
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     currentObject = this;
     currentObject.GetTransform().SetParent(emptyParent);
     currentObject.GetTransform().SetAsFirstSibling();
     startSlot = currentObject.GetCurrentSlot();
 }
Example #3
0
 public void SetCurrentSlot(InventoryUISlot slot)
 {
     currentSlot = slot;
     currentSlot.SetInventoryUIObject(this);
     GetTransform().SetParent(slot.GetTransform());
     GetTransform().localPosition = Vector3.zero;
 }
        public void InstantiateNewSlots(int amount)
        {
            for (int i = 0; i < amount; i++)
            {
                GameObject templateClone = Instantiate(inventoryUISlotTemplate.gameObject, Vector3.zero, Quaternion.identity);
                templateClone.name = "Slot" + i;
                InventoryUISlot slot = templateClone.GetComponent <InventoryUISlot>();
                slot.SetInventoryUIObject(null);
                slot.GetTransform().SetParent(inventoryUISlotTemplate.GetTransform().parent);
                slot.GetTransform().localScale = inventoryUISlotTemplate.GetTransform().localScale;
                slot.gameObject.SetActive(true);
                slot.Init(this);

                slots.Add(slot);
            }
        }