(yeah funny title i know, you’ll see what i mean though. )
Hey, I’m working on a Tower Defense game and i was working on an Upgrade System for my Towers.
An Upgrade for a Tower can be as simple as a Stat Boost or a change in the Projectile used, systems that i already put in place successfully, but some upgrades can also completely change the Behavior of a Turret:
- The simplest example i can give is that of a Support Tower, which job is to give Buffs to Towers, De-Buff to Enemies or others, that once Upgraded can also fire at Enemies;
What i thought is that for that kind of thing to work i have to give the Support Tower the Scripts that make an Offensive Tower able to shoot at things, and what i made up is a System to makes this work (kinda lol):
(Im going to simplify the thing because i dont need a way to make it work, i just need to know if this is a good idea or not)
- Every Tower has an “AutoComponentAdd” Script; This has a List of strings, those being the names(Types) of the Scripts i want to add. With a method I get all these string, make them Type, and add them to the Turrets.
- These lists of strings can be given to the script from an Upgrade or by me from the Inspector (probably just for testing reasons).
- I open the Tower GUI in-game, I click the Button to Upgrade it and the Upgrade gives to this Script the strings, and from these strings I get a “Type” and then use it with AddComponent to finally add the Component.
I know its a really rough idea, but i would first like to know if this is actually a good idea to do this “Complete Behaviour Change” thing with the Upgrades, or if there’s another, better, way before i make it a fleshed out system.
So, is this a stupid approach to the problem? lol
If you didnt understand a thing, I’m available for clarifications.
Thanks in advance for everyone replying to this