How to automatically change the prefabs of breakout bricks on hit?
I'm trying to make a simple breakout game but at the same time I'm trying to learn about programming patterns. In this game, there is supposed to be multiple types/tiers of bricks, say red and green bricks. For each type of bricks, there are multiple prefabs for it that represent the different stages of a brick, for example a red brick could have 3 prefabs ( red_brick, partially_destroyed_red_brick, and semi_destroyed_red_brick).
Whenever a brick is hit, I would like to change its prefab to another one, for example if a red_brick was hit the next prefab to be displayed would be partially_destroyed_red_brick, and so on, until we reach the last stage of a brick, in which case it should be destroyed.
Now I know that there are probably millions of ways by which this could be achieved but I was looking for the most optimal and modular way. In other words, I want it to be easier to include more types of bricks in the future, without altering a lot of code.
Your answer
Follow this Question
Related Questions
Reference to components of UI widget 0 Answers
Modular entity construction 0 Answers
How to make the player can use flutter Jump like Yoshi in Super Mario World? 0 Answers
SpriteRender not loading sprites?,SpriteRender isn't changing the sprite 0 Answers
Index out of range exeption error help 0 Answers