Hello,
I like games with upgrades, lots of different upgrades to be precise. But I haven’t found a good implementation yet that I like.
I would like it to be modular and easy to upgrade. So something to hardcode with if statements is out. I would have to add new if statements for each upgrade.
I would like each upgrade to be its own resource or scene. So that the upgrade code only has to be managed there.
But I just can’t find a good solution to the problem.
Let’s say I have a building in the game that produces 1 thing per second. There is a function that increases the thing by one every second.
I could say the building checks all unlocked updates before each production and adds the production multipliers. Would work.
But what if I want to add an upgrade that produces 2 extra things with every production? Now I would have to adapt the code of the building so that it recognizes the new upgrade type.
I think it would be best if the building would call the upgrade’s function instead of its own. But what if I have multiple upgrades for the same thing. What if there are many buildings and countless upgrades, at some point there will be performance problems.
So I’m not looking for a solution to a specific problem, the building is just a possible example. I am looking for a good approach to build an upgrade system that is easy to maintain and expand. So I don’t need code for it, the concept is what I’m looking for.