﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class UIInventory : MonoBehaviour
{
    public UIInventorySlot FirstAvailableSlot =>
        GetComponentsInChildren<UIInventorySlot>().FirstOrDefault(x => x.item == null);


    public GameObject[] debugItems;
    public void AddRandomItem()
    {
        //get an open slot
        UIInventorySlot slot = FirstAvailableSlot;

        //if there is an open slot...
        if (slot != null)
        {
            //add the item!
            slot.item = Instantiate(debugItems[Random.Range(0, debugItems.Length)], slot.transform);
        }
    }
}
