Exemple #1
0
        private void OnDragEnded(InventorySlot inventorySlot, Vector2 pointerPosition)
        {
            var           pointerPos   = new Vector3(pointerPosition.x, pointerPosition.y);
            InventorySlot equippedItem = null;

            foreach (var item in _equippedItemSlots)
            {
                var rectTransform = item.Key.GetComponent <RectTransform>();
                var localPos      = pointerPos - rectTransform.position;
                if (rectTransform.rect.Contains(localPos))
                {
                    equippedItem = item.Key;
                    break;
                }
            }

            if (equippedItem != null && InventoryService.CompareItemTypes(
                    InventoryService.Get(
                        Inventory.GetIndexOfInventorySlot(inventorySlot))
                    , _equippedItemSlots[equippedItem]))
            {
                EquipItem(inventorySlot);
            }
        }