Sorry for the title, I did not know how else to describe the question. I am writing a turn-based strategy game and am looking for a way to enable design-time additions of game mechanics where the mechanics each require some different math.
What I'd like to do is to be able to create a ScriptableObject and then modify it with the formula and various descriptions (all through the inspector), then add it to the game.
As an example, my game has cities where each city has several attributes such as population and various technology levels. I'd like to be able to add various "resource generators" at design-time via the inspector with the formula for how the resource is generated per turn.
Some examples of resource generators:
- A "gold" resource generator with the "population * 0.025" formula to indicate that, each turn, the city generates 2.5% of it's population as gold.
- A "research" resource generator with "assigned population * 0.5" as the formula to indicate that, each turn, the population assigned to research generates 0.5 pts of research per person.
- A "production" resource generator with the "assigned population * production tech level * 0.75" with a max value of "1000 * city level" where excess production gets dumped to gold.
And so on. These are examples, but the formulas should allow for arbitrary interactions with other values in the game.
Some of the simpler formulas seems pretty easy, i.e. create a scriptable object attached to a primary value (say population) and then a simple modifier. But I'm stuck on how to do the more complex ones.
Anyone have an idea about how to accomplish something like this?