Beispiel #1
0
    void Start()
    {
        database       = GetComponent <ItemDatabase>();
        itemsInventory = GetComponent <InventoryDatabase>();

        slotAmount     = 20;
        inventoryPanel = GameObject.Find("Inventory Panel");
        slotPanel      = inventoryPanel.transform.FindChild("Slot Panel").gameObject;
        for (int i = 0; i < slotAmount; i++)
        {
            items.Add(new Item());
            slots.Add(Instantiate(inventorySlot));
            slots[i].GetComponent <InventorySlot>().id = i;
            slots[i].transform.SetParent(slotPanel.transform);
            slots[i].name = "Slot";
        }


        itemsInInvetory = itemsInventory.FetchAllItemsIDs();

        for (int i = 0; i < itemsInInvetory.Length; i++)
        {
            itemAmount = itemsInventory.FetchItemsAmount(i);
            for (int a = 0; a < itemAmount; a++)
            {
                AddItem(itemsInInvetory[i]);
            }
        }

        inventoryPanel.SetActive(false);
    }