Hi all,
So I’m trying to make a 2D game where I have 50 unique collectables(items). These collectables are obtained by the player under certain circumstances, ex: defeating monsters, in-game events…etc.
Upon getting these collectables, the icon of it will appear on the “show room” panel, and the status of it becomes “unlocked”.
These collectable has no real interactions with the game, they only contains some data like an example below:
public class Collectable
{
public int id {get;set;}
public string name {get;set;}
public ItemType type {get;set;}
public int rarity {get;set;}
public float bonus {get;set;}
}
Notice that “bonus” is the bonus given to the player in some in-game events, ex: 0.2 additional chance to obtain Collectable XXX upon defeating monsters.
Now I have two questions:
-Should I create only one class like above then assign the values to it at runtime upon creation, or, create a Collectable base class and then create other 50 classes that inherit from the base class?
Or if there’s any better way you suggest?
//Option 1:
public void CreateCollectables()
{
collectablelist.Add(new Collectable(){1,"item1", ItemType.Battle,1,0.1});
collectablelist.Add(new Collectable(){1,"item2", ItemType.Type1,1,0.1});
collectablelist.Add(new Collectable(){1,"item3", ItemType.Type2,1,0.1});
...
...
collectablelist.Add(new Collectable(){1,"item50", ItemType.Event,1,0.1});
}
//Option 2:
public class Collectable1 : Collectable{
public Collectable1()
{
id = 1;
name= "item1"
...
}
}
//then
public void CreateCollectables()
{
collectablelist.Add(new Collectable1());
collectablelist.Add(new Collectable2());
collectablelist.Add(new Collectable3());
...
...
collectablelist.Add(new Collectable50());
}
-If I were to map a collectable to a slot in the panel, what would be the ideal structure?
public class Collectable
{
...
CollectableSlot slot;
}
//or?
public class CollectableSlot
{
...
Collectable collectable;
}
Any comments are welcomed, thank you!