using System.Collections; using System.Collections.Generic; using System.Net.NetworkInformation; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; using static UnityEditor.Progress; public class InventoryManager : MonoBehaviour { public static InventoryManager Instance; /// /// creating a list to hold items /// public List Items = new List(); //calling InventoryItemController into the constructor and caching the instance private InventoryItemController inventoryController; //item count //public int count; public Transform ItemContent; public GameObject InventoryItem; private const int maxInventorySize = 9; // maximum number of stacks in the inventory //toggle for enabling remove button public Toggle EnableRemove; //inventory item array public InventoryItemController[] InventoryItems; private void Awake() { Instance = this; //InventoryItemController obj = Instantiate(inventoryController); } public void Start() { inventoryController = new InventoryItemController(); //inventoryController = GetComponent(); } /// /// adding items to the list /// /// public void Add(Item item) { int Itemcoucount = inventoryController.IncrementCounter(); //inventoryController.count = inventoryController.count + i; //inventoryController.IncrementCounter(); foreach (Item InventoryItems in Items) { if (InventoryItems.itemType == item.itemType) { //Debug.Log("items are stacking"); //inventoryController.count = inventoryController.count + 1; inventoryController.IncrementCounter(); Debug.Log("number of stacked items: " + (Itemcoucount)); return; } } Items.Add(item); //Debug.Log("items are being added"); } //removes item from inventory public void Remove(Item item) { Items.Remove(item); } //locates and lists items in the inventory public void ListItems() { //cleans content before opening foreach (Transform item in ItemContent) { Destroy(item.gameObject); } foreach (Item item in Items) { //Debug.Log("item name and icon is not null"); GameObject obj = Instantiate(InventoryItem, ItemContent); var itemName = obj.transform.Find("ItemName").GetComponent(); var itemIcon = obj.transform.Find("ItemIcon").GetComponent(); var removeButton = obj.transform.Find("RemoveButton").GetComponent