Papa Doge
Member
I'm planning out the logic for an RTS that has buildable/upgradable structures. For example, the player might build a sentry that has turret guns at first but then can pay an upgrade cost to add or maybe replace with a flamethrower.
In planning this out I'm considering two paths...
A) The sentry object has a variable called "has_flamethrower" that is set too true if the player has paid the upgrade cost. Then in the step event, I would have a block of code that says "if (has_flamethrower == true)" and if it is, change the sprite index, change the structure portrait (displayed in the HUD when selected), and finally run some code that makes the turret spew flames when enemies are within range.
B) The sentry object is first placed as a standard sentry with default sprites and functionality. When the player pays the upgrade price, I could swap this standard sentry with an enhanced sentry that has the flamethrower capabilities, flamethrower sprite, and flamethrower HUD portrait.
I estimate to have in the ballpark minimum of 13 different structures that will use this system for upgrades, so it needs to be somewhat scalable.
-----
Of the two options above, does one stand out as clearly the better way to go? Are there other options I should be considering here like a parent child relationship of some kind?
In planning this out I'm considering two paths...
A) The sentry object has a variable called "has_flamethrower" that is set too true if the player has paid the upgrade cost. Then in the step event, I would have a block of code that says "if (has_flamethrower == true)" and if it is, change the sprite index, change the structure portrait (displayed in the HUD when selected), and finally run some code that makes the turret spew flames when enemies are within range.
B) The sentry object is first placed as a standard sentry with default sprites and functionality. When the player pays the upgrade price, I could swap this standard sentry with an enhanced sentry that has the flamethrower capabilities, flamethrower sprite, and flamethrower HUD portrait.
I estimate to have in the ballpark minimum of 13 different structures that will use this system for upgrades, so it needs to be somewhat scalable.
-----
Of the two options above, does one stand out as clearly the better way to go? Are there other options I should be considering here like a parent child relationship of some kind?