using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

class ItemManager : MonoBehaviour
{
    public GameObject[] ItemPrefabs; 

    public int NumItems
    {
        get
        {
            return ItemPrefabs.Length-1; 
        }
    }

    public static ItemManager Instance;

    public void Awake()
    {
        Instance = this; 
    }

    public Item SpawnWeapon(int id)
    {
        GameObject obj = GameObject.Instantiate(ItemPrefabs[id]);
        return obj.GetComponent<Weapon>(); 
    }

    public Sprite GetSprite(int id)
    {
        SpriteRenderer spriteRenderer = ItemPrefabs[id].GetComponent<SpriteRenderer>(); 
        if(spriteRenderer != null)
        {
            return spriteRenderer.sprite; 
        }

        return null; 
    }

}
