The idea is that the player has a few block types to choose from, with each block type itself having specific sub types.
For example, the player has the option of choosing a red block or a blue block. Not only that, but the player also needs to know what specific kind of red block or blue block it is. That means that the red block can have different attributes, like it can be a block of fire, a block that causes an instant game over, a block that takes away health, etc.
In the case of the blue block, it could either be a block of ice, a block of water, a block that gives health, etc.
What I would like to know is what would be the best way to handle this using scriptable objects and keeping things abstract? For example, I was thinking about having a scriptable object that acts as a database for the blocks. The player class would ask the database to give it a block according to its color and attribute.
A method like the one below won’t work because I don’t want the player to be able ask the database for a blue block, but with an attribute that should only belong to a red block.
GetBlock(Color.Blue, Attribute.Fire);
public Block GetBlock(Color color, Attribute attribute)
{
}
I know an alternative would be to create methods that ask to get a specific block like in the method below.
public BlueBlock GetBlueBlock(BlueBlockAttribute attribute)
{
}
However, the issue with this is that it’s too specific, and isn’t really SOLID code as I would have to keep adding methods to this script every time I want to introduce a new block color.