| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | |
| | | { |
| | | Destroy(gameObject); |
| | | } |
| | | if (SaveSystem.isGameLoaded) |
| | | { |
| | | LoadInventory(); |
| | | } |
| | | } |
| | | |
| | | private void LoadInventory() |
| | | { |
| | | SaveDataPlayer save = SaveSystem.LoadPlayer(); |
| | | if (save != null) |
| | | { |
| | | foreach (SaveDataInventorySlot item in save.inventoryItems) |
| | | { |
| | | Item loadedItem = ItemDatabase.Instance.GetItem(item.itemId); |
| | | if (loadedItem != null) |
| | | { |
| | | items.Add(new InventorySlot(loadedItem, item.quantity)); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError($"Failed to load item with ID: {item.itemId}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public bool AddItem(Item item, int quantity = 1) |