Hi, so I am programming a 2D RPG in which I need to create items (obviously) and I have set up two generic scripts to define this.
Item.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Item
{
public Image artwork;
public new string name;
public string description;
public int price = 0;
public string damageText;
public string healthText;
public ItemType type;
public ItemRarity rarity;
public Item(Image artwork, string name, string description, int price, string damageText, string healthText, ItemType type, ItemRarity rarity)
{
this.artwork = artwork;
this.name = name;
this.description = description;
this.price = price;
this.damageText = damageText;
this.healthText = healthText;
this.type = type;
this.rarity = rarity;
} // Constructor
}
And then I also have Items.cs:
using System.Collections;
using System.Collections.Generic;
public class Items
{
private static Dictionary<int, Item> itemDictionary = new Dictionary<int, Item>();
public static void addItem(int id, Item item)
{
itemDictionary[id] = item;
}
public static Item getItem(int id)
{
return itemDictionary[id];
}
}
How would I make it so I can edit the Items dictionary and define new items and ids with that in the editor along with all of the stats listed in Item.cs?