I have a non-MonoBehaviour script called Item which contains two classes.
public class Item
{
public string itemName;
//public string itemRarity;
public Item(string newItemName)
{
itemName = newItemName;
}
}
and
public class ItemRandomizer
{
List<Item> itemContainer = new List<Item>();
public void AddItem(Item item, int amount)
{
for (int i = 0; i < amount; i++)
{
itemContainer.Add(item);
}
}
public Item GetRandomItem()
{
int index = Random.Range(0, itemContainer.Count);
// want to return item combined with rarity
return itemContainer[index];
}
I want GetRandomItem to not only return a random item "type", e.g., gloves, contained in the itemContainer list, but also combine it with a rarity (common, rare, legendary) and return that if possible.
How can I code this functionality in a flexible way so that two base items with the same drop chance can have varying drop chances when it comes to their rare versions? Swords and axes have the same drop chance, but a rare sword might be rarer than a rare axe. I'd like to maintain that kind of flexibility.
Also, if I make public string itemRarity a property of the Item class, but I want to set the rarity tier in GetRandomItem() in the ItemRandomizer class, how should I do that? Thus far, I've almost exclusively used MonoBehaviour classes so any pointers are appreciated.