Hello guys,
I’m working on an inventory system for my game, and I’ve been following some tutorials on how I can do it, but all the tutorials that I have found works with some kind of pickable objects.
I want to do something different, I want to generate random items and straight push them into my inventory items list.
I made a simple class to store some data like properties, rarity and the path of the Sprite. That class is named Drop.
public class Drop
{
public int id;
public string iconPath;
public Sprite icon;
public enum Tipo
{
Helmet, // 0
Armor, // 1
Bottom, // 2
Gloves, // 3
Boots, // 4
Ring, // 5
Shield, // 6
Sword, // 7
HeavySword, // 8
Dagger, // 9
Bow, // 10
Axe, // 11
HeavyAxe, // 12
Hammer, // 13
HeavyHammer, //14
Necklace // 15
}
public Tipo tipoEquip;
public enum Rarity
{
Comum, //0
Incomum, //1
Raro, //2
Epico, //3
Lendario //4
}
public Rarity raridade;
public enum MainAttribute
{
Atk, //0
Def, //1
Vida, //2
AtkSpeed, //3
Acerto, //4
CritChance, //5
CritDamage, //6
MoveSpeed //7
}
public MainAttribute mainAttribute;
public bool hasAtk;
public bool hasDef;
public bool hasVida;
public bool hasAtkSpeed;
public bool hasMoveSpeed;
public bool hasAcerto;
public bool hasCritChance;
public bool hasCritDamage;
public float atk;
public int def;
public float vida;
public float atkSpeed;
public float moveSpeed;
public int acerto;
public float critChance;
public float critDamage;
public int mainValue;
}
I’m having some ideas of how I can do the generation, but all of them seems to be wrong, the best is this:
I thought that I could create a code that instantiates a prefab of an item and assign a Drop class to it, fill the values, generate some kind of id, and then add this item to the inventory, and eventually save that information in json to reload when needed.
Would that work? Can you guys help me with this?