Exemplo n.º 1
0
    public void OnDrop(PointerEventData eventData)
    {
        eventData.pointerDrag.GetComponent <DragnDrop>().Changing = true;
        newParent      = eventData.pointerDrag.GetComponent <DragnDrop>().Oldparent;
        oldSlot        = newParent.GetComponent <Drop>().Slot;
        othersateCheck = newParent.GetComponent <SateCheck>();
        storeItem      = sateCheck.Slot.Item;
        storeOtherItem = eventData.pointerDrag;
        storeThisItem  = sateCheck.ActiveItem;

        if (eventData.pointerDrag != null)
        {
            GameObject dragged = eventData.pointerDrag;
            if (sateCheck.Slot.Filled == false)
            {
                eventData.pointerDrag.transform.position = transform.position;
                eventData.pointerDrag.transform.SetParent(transform);
                sateCheck.Slot.Filled      = true;
                sateCheck.ActiveItem       = eventData.pointerDrag;
                othersateCheck.ActiveItem  = null;
                othersateCheck.Slot.Filled = false;
                inventory.ItemChange(oldSlot, Slot, othersateCheck.Slot.Item);
                sateCheck.recieve(othersateCheck.Slot.Item);
                othersateCheck.give();
            }
            else if (sateCheck.Slot.Filled == true)
            {
                storeOtherItem.transform.position = transform.position;
                storeOtherItem.transform.SetParent(transform);
                sateCheck.ActiveItem             = storeOtherItem;
                storeThisItem.transform.position = newParent.position;
                storeThisItem.transform.SetParent(newParent);
                othersateCheck.ActiveItem = storeThisItem;
                inventory.ItemSwitch(oldSlot, Slot, othersateCheck.Slot.Item, sateCheck.Slot.Item);
                sateCheck.recieve(othersateCheck.Slot.Item);
                othersateCheck.recieve(storeItem);
            }
        }
    }
Exemplo n.º 2
0
 void Start()
 {
     sateCheck = gameObject.GetComponent <SateCheck>();
     inventory = GetComponentInParent <Inventory>();
 }
Exemplo n.º 3
0
 void Start()
 {
     sateCheck = GetComponentInParent <SateCheck>();
 }