public void OnDrop(PointerEventData eventData) { if (eventData.pointerDrag != null) { if (!eventData.pointerDrag.GetComponent <Image>().sprite.Equals(defaultSprite)) { if (eventData.pointerDrag.GetComponentInParent <AbilityBar>() != null) //source is another ability bar { if (AbilityManager.instance.Swap(boxID, eventData.pointerDrag.GetComponentInParent <AbilityBar>().GetID())) { Sprite temp = iconSpot.sprite; UpdateIcon(eventData.pointerDrag.GetComponent <Image>().sprite); eventData.pointerDrag.GetComponent <Image>().sprite = temp; } } else { InventoryBoxManager otherBox = eventData.pointerDrag.GetComponentInParent <InventoryBoxManager>(); if (otherBox != null) { if (ProjectUtil.IsWeaponSlot(otherBox.GetID())) { Debug.LogWarning("Dragging between a weapon and the ability bar is unimplemented"); } else if (ProjectUtil.IsTrinketSlot(otherBox.GetID())) { if (AbilityManager.instance.SetAbility(boxID, otherBox.GetID())) { UpdateIcon(eventData.pointerDrag.GetComponent <Image>().sprite); } } } } //if it is from a trinket or equipment slot, then get the necessary info from the equipped item } } }
public void OnDrop(PointerEventData eventData) { if (eventData.pointerDrag != null) { if (!eventData.pointerDrag.GetComponent <Image>().sprite.Equals(defaultSprite)) { InventoryBoxManager otherBox = eventData.pointerDrag.GetComponentInParent <InventoryBoxManager>(); if (owner == InventoryOwner.Player && otherBox.owner == InventoryOwner.Player) { if (InventoryToolbox.instance.GetGlobalComponent(owner).Swap(slotID, otherBox.GetID())) { Sprite temp = iconSpot.sprite; UpdateIcon(eventData.pointerDrag.GetComponent <Image>().sprite); eventData.pointerDrag.GetComponentInParent <InventoryBoxManager>().UpdateIcon(temp); //eventData.pointerDrag.GetComponent<Image>().sprite = temp; } } if ((owner == InventoryOwner.Blacksmith && otherBox.owner == InventoryOwner.Player) || (owner == InventoryOwner.Player && otherBox.owner == InventoryOwner.Blacksmith)) { if (ProjectUtil.Sell(InventoryToolbox.instance.GetGlobalComponent(otherBox.owner), otherBox.GetID(), InventoryToolbox.instance.GetGlobalComponent(owner), slotID)) { Sprite temp = iconSpot.sprite; UpdateIcon(eventData.pointerDrag.GetComponent <Image>().sprite); eventData.pointerDrag.GetComponentInParent <InventoryBoxManager>().UpdateIcon(temp); } } } } }