46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
// InventoryManager.cs
|
|
public class InventoryManager : MonoBehaviour
|
|
{
|
|
public List<GameItem> inventoryItems = new();
|
|
|
|
private void Start()
|
|
{
|
|
Debug.Log("InventoryManager Start");
|
|
InitializeInventory();
|
|
}
|
|
|
|
|
|
public void AddItem(GameItem item)
|
|
{
|
|
inventoryItems.Add(item);
|
|
Debug.Log("Added item: " + item.itemName);
|
|
}
|
|
|
|
public void RemoveItem(GameItem item)
|
|
{
|
|
inventoryItems.Remove(item);
|
|
Debug.Log("Removed item: " + item.itemName);
|
|
}
|
|
|
|
|
|
public void InitializeInventory()
|
|
{
|
|
// Add predefined items to the inventory list
|
|
// Example items (replace with your actual items)
|
|
Debug.Log("Initializing Inventory");
|
|
var item1 = ScriptableObject.CreateInstance<GameItem>();
|
|
item1.itemName = "Sword";
|
|
item1.icon = null; // Assign the icon if available
|
|
|
|
var item2 = ScriptableObject.CreateInstance<GameItem>();
|
|
item2.itemName = "Shield";
|
|
item2.icon = null; // Assign the icon if available
|
|
|
|
AddItem(item1);
|
|
AddItem(item2);
|
|
}
|
|
} |