Exemplo n.º 1
0
    public bool Store(Item item)
    {
        if (_storageItems == null || _storageItems.Count == 0)
        {
            Debug.Log("There is no where to store the item");
            return(false);
        }

        foreach (StorageItem si in _storageItems)
        {
            Vector2Int    storageSize = si.StorageWindow.Size;
            StorageWindow sw          = si.StorageWindow;
            StorageSlot[,] slots = sw.storageSlotMatrix;

            for (int x = 0; x < storageSize.x; x++)
            {
                for (int y = 0; y < storageSize.y; y++)
                {
                    if (sw.Slot(slots[x, y], item.UIItem, false))
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Exemplo n.º 2
0
    public override void OnPointerUp(PointerEventData data)
    {
        base.OnPointerUp(data);

        if (data.button == PointerEventData.InputButton.Left)
        {
            if (_canUseLinkednItem)
            {
                UseLinkedItem();
                return;
            }

            ItemSlot slotHit = uIItemManager.CastToItemSlot(RectTransform.position);

            if (slotHit != null)
            {
                if (slotHit.GetType() == typeof(EquipmentSlot))
                {
                    EquipmentSlot es = (EquipmentSlot)slotHit;
                    es.Slot(this);
                    _slot = es;
                }

                else if (slotHit.GetType() == typeof(StorageSlot))
                {
                    StorageSlot   ss = (StorageSlot)slotHit;
                    StorageWindow sw = ss.StorageWindow;
                    if (sw != null)
                    {
                        sw.Slot(ss, this, true);
                        _storageWindow = sw;
                        _slot          = ss;
                    }
                }
            }
            else
            {
                Debug.Log("No Slot");
                LinkedItem.Drop(new object[] { gameManager.Actor.Character.transform.position });
            }
        }
    }