45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "InventoryItem", menuName = "GameData/InventoryItem", order = 1)]
|
|
[System.Serializable]
|
|
public class InventoryItem : ScriptableObject
|
|
{
|
|
public string itemName;
|
|
public int price;
|
|
public int gems;
|
|
public int stat;
|
|
public Sprite image;
|
|
}
|
|
|
|
|
|
[System.Serializable]
|
|
public class InventoryEntry
|
|
{
|
|
public string Item;
|
|
public int Count;
|
|
public InventoryEntry(string item, int count)
|
|
{
|
|
Item = item;
|
|
Count = count;
|
|
}
|
|
}
|
|
|
|
public static class Inventory
|
|
{
|
|
public static InventoryItem GetInventoryItem(string itemName)
|
|
{
|
|
Object[] shopItems = Resources.LoadAll("ScriptableObjects/ShopItems");
|
|
// Debug.Log("Searching thru " + shopItems.Length + " SOs");
|
|
foreach (Object itemObj in shopItems)
|
|
{
|
|
InventoryItem item = itemObj as InventoryItem;
|
|
if (item.itemName == itemName)
|
|
{
|
|
return item;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
} |