Exemple #1
0
    public static void CollectItem(GameObject itemPanel)
    {
        Furniture  furniture;
        GameObject furniturePanel = itemPanel.transform.parent.parent.gameObject;

        if (!furnitureReference.TryGetValue(furniturePanel, out furniture))
        {
            Debug.LogError("Nie znaleziono mebla!!!");
        }

        int  itemNumber = Int32.Parse(itemPanel.name);
        Item i          = furniture.RemoveItemAtIndex(itemNumber);

        currentParty.AddItemToInventory(i);

        itemPanel.transform.SetParent(null);
        GameObject.Destroy(itemPanel);


        Transform furnitureContents = furniturePanel.transform.GetChild(1);

        if (furnitureContents.childCount == 0)
        {
            furnitureContents.transform.SetParent(null);
            Destroy(furnitureContents.gameObject);
        }
        for (int index = itemNumber; index < furnitureContents.childCount; index++)
        {
            furnitureContents.GetChild(index).gameObject.name = index.ToString();
        }

        if (InventoryPanel.activeSelf)
        {
            UpdateInventoryPanel();
        }
    }