Beispiel #1
0
    public void Remove(Item itemToRemove, int count = 1) //metoda do usuwania itemków z ekwipunku - ver Magdy
    {
        if (itemToRemove.stackable)                      //jeśli da się stackować
        {
            ItemSlot itemSlot = slots.Find(x => x.item == itemToRemove);
            if (itemSlot == null)
            {
                return;
            }

            itemSlot.count -= count;
            if (itemSlot.count <= 0)
            {
                itemSlot.Clear();                      //jeśli usunął ostatnią sztukę
            }
        }
        else
        {
            while (count > 0)
            {
                count -= 1;
                ItemSlot itemSlot = slots.Find(x => x.item == itemToRemove);
                if (itemSlot == null)
                {
                    return;
                }

                itemSlot.Clear();
            }
        }
        GameManager.instance.toolbarPanel.SetActive(false);
        GameManager.instance.toolbarPanel.SetActive(true);
    }
Beispiel #2
0
 public void Remove(Item itemToRemove, int count = 1)
 {
     if (itemToRemove.stackable)
     {
         ItemSlot itemSlot = slots.Find(x => x.item == itemToRemove);
         if (itemSlot == null)
         {
             return;
         }
         itemSlot.count -= count;
         if (itemSlot.count <= 0)
         {
             itemSlot.Clear();
         }
     }
     else
     {
         while (count > 0)
         {
             count -= 1;
             ItemSlot itemSlot = slots.Find(x => x.item == itemToRemove);
             if (itemSlot == null)
             {
                 return;
             }
             itemSlot.Clear();
         }
     }
 }
Beispiel #3
0
 public void Drop(ItemSlot itemSl, Vector3 worldPosition) //upuszcza przedmiot
 {
     ItemSpawnManager.instance.SpawnItem(                 //upuszcza w tym miejscu przedmiot
         worldPosition,
         itemSl.item,
         itemSl.count,
         false);
     itemSl.Clear();//czyści pole po wyrzuceniu
 }
Beispiel #4
0
 public void Remove(ItemSlot itemSlot)    //metoda do usuwania itemków z ekwipunku
 {
     if (itemSlot.item.stackable == true) //jeśli da się stackować
     {
         itemSlot.count--;                //usuwa jedną sztukę
         if (itemSlot.count == 0)
         {
             itemSlot.Clear();                      //jeśli usunął ostatnią sztukę
         }
     }
     else //jeśli nie da się stackować
     {
         itemSlot.Clear();
     }
     //"odświeżenie" toolbara
     GameManager.instance.toolbarPanel.SetActive(false);
     GameManager.instance.toolbarPanel.SetActive(true);
 }
Beispiel #5
0
    public void Drop(ItemSlot destination)
    {
        Debug.Log("Dropping: " + destination);

        if (source == null)
        {
            return;
        }

        if (!IsValid(source.GetItem(), destination))
        {
            return;
        }

        // Move or swap items
        if (destination.IsEmpty()) // Destination is empty, simply move item
        {
            if (destination is EquipSlot)
            {
                EquipHandler.instance.Add((Equipment)source.GetItem());
            }

            if (source is EquipSlot)
            {
                EquipHandler.instance.Remove((Equipment)source.GetItem());
            }

            destination.AddItem(source.GetItem());
            source.Clear();
        }
        else
        {
            // Check if swap is valid
            if (!IsValid(destination.GetItem(), source))
            {
                return;
            }

            if (destination is EquipSlot)
            {
                EquipHandler.instance.Remove((Equipment)destination.GetItem());
                EquipHandler.instance.Add((Equipment)source.GetItem());
            }

            Item temp = destination.GetItem();
            destination.AddItem(source.GetItem());
            source.AddItem(temp);
        }

        destination.GetItem().ShowTooltip(); // Show tooltip for moved item
    }
Beispiel #6
0
    void MinusSlot()
    {
        //Keep active slots so we cant minus them.
        if (_myslot.StartActive)
        {
            return;
        }

        _myslot.Clear();

        GameObjectTracker.instance._PlayerData.GemCart -= _myslot.Cost;

        UpdateDisplay();
    }
Beispiel #7
0
 internal void OnClick(ItemSlot itemSlot)
 {
     if (this.itemSlot.item == null)
     {
         this.itemSlot.Copy(itemSlot);
         itemSlot.Clear();
     }
     else
     {
         Item item  = itemSlot.item;
         int  count = itemSlot.count;
         itemSlot.Copy(this.itemSlot);
         this.itemSlot.Set(item, count);
     }
     UpdateIcon();
 }
Beispiel #8
0
    internal void OnClick(ItemSlot itemSlot, ItemContainer inventoryContainer) //przyjmuje "kliknięty" item
    {
        if (!shopPanel.activeInHierarchy)                                      //jeśli nie jesteśmy w sklepie
        {
            if (this.itemSlot.item == null)                                    //jeśli nic nie ma w aktualnie przechowywanym polu
            {
                this.itemSlot.Copy(itemSlot);                                  //to kopiuje do niego item
                itemSlot.Clear();                                              //czyści pole, z którego było przeniesione
            }
            else//jeśli w "schowku" jest item
            {
                Item item  = this.itemSlot.item;      //przechowuje slot ze "schowka"
                int  count = this.itemSlot.count;     // j.w. c.d.

                this.itemSlot.Copy(itemSlot);         //kopiuje do "schowka" kliknięty item
                itemSlot.Set(item, count, container); //w miejsce klikniętego wstawia ten, który był wcześniej w schowku
            }
            UpdateIcon();
        }
    }
    private void Update()
    {
        if (itemIcon.activeInHierarchy == true)
        {
            iconTransform.position = Input.mousePosition;

            if (Input.GetMouseButtonDown(0))
            {
                if (EventSystem.current.IsPointerOverGameObject() == false)
                {
                    Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    worldPosition.z = 0;

                    ItemSpawnManager.instance.SpawnItem(worldPosition, itemSlot.item, itemSlot.count);

                    itemSlot.Clear();
                    itemIcon.SetActive(false);
                }
            }
        }
    }
    internal void OnClick(ItemSlot itemSlot)
    {
        // Puts the item from inventory to the drag and drop slot
        if (this.itemSlot.item == null)
        {
            this.itemSlot.Copy(itemSlot);
            itemSlot.Clear();
        }
        else
        {
            // If the item slot is not empty we exchange items inside the item slots

            Item item  = itemSlot.item;
            int  count = itemSlot.count;

            // Assigns the currently dragged item into the inventory item slot
            itemSlot.Copy(this.itemSlot);

            this.itemSlot.Set(item, count);
        }
        UpdateIcon();
    }
Beispiel #11
0
    public void RemoveItem(Item removedItem, int count)
    {
        // Removing stackable items
        if (removedItem.stackable)
        {
            // Finding the item which is going to be removed

            ItemSlot itemSlot = slots.Find(slot => slot.item == removedItem);

            if (itemSlot == null)
            {
                return;
            }

            itemSlot.count -= count;

            if (itemSlot.count <= 0)   // Clearing the slot if it's empty
            {
                itemSlot.Clear();
            }
        }
        // Removing single items
        else
        {
            while (count > 0)
            {
                count--;
                ItemSlot itemSlot = slots.Find(slot => slot.item == removedItem);
                if (itemSlot == null)
                {
                    break;
                }
                itemSlot.Clear();
            }
        }
    }