Exemplo n.º 1
0
    //Update colors and determine selectedItem (triggering relevant onDeselect event)
    public void updateSlots(int deselected = -1)
    {
        Transform inventoryPanel = transform.Find("InventoryPanel");

        foreach (Transform slot in inventoryPanel)
        {
            if (slot.name == "Slot" + selected.ToString())
            {
                slot.GetComponent <Image>().color = selectedColor;
                if (selected < inventory.pItems.Count)
                {
                    selectedItem = inventory.pItems[selected];
                    selectedItem.OnSelected();
                }
            }
            else
            {
                slot.GetComponent <Image>().color = nonSelectedColor;
                if (slot.name == "Slot" + deselected.ToString())
                {
                    if (deselected < inventory.pItems.Count)
                    {
                        inventory.pItems[deselected].OnDeselected();
                    }
                }
            }
        }
    }