- Home /
Robust Weapons System
Hi there and thanks for looking.
The question I have is, I am currently redesigning my weapon system as we have changed the game a bit. I want to be able to have any number of weapons, Add , Remove them in updates etc.
I did have a weapon system that worked great for the last revision of the game but now we have changed it that system just won't cut it any more. We currently have over 20 weapons that can be switched with our MSW all of our weapons have their own stats, (Bullet Speed, Damage, max ammo, Upgrade Cost etc)
With the new system we need to be able to have the same kind off system. The weapons need to have their own stats. We will be allowing players to upgrade their weapons via our upgrade screen the problem i have encountered is i want to be able to access the weapons via their name, As of now we can access them but it is like this
currentAmmoType[0].damage = 10;
We need to be able to access it like this or something similar
EnergyBlaster.damage = 10;
As off now i also have it set up so that there is just one class with an array of them and i access them all from there. This is the part i am sure will not work with our new system and i just can't seem to design it correctly. I have been thinking of using a singleton but i just don't want to go down that road. I would love to be able to have an enum and on that weapon just state it is this weapon (EnergyBlaster) and then manipulate it's stats.
I know i can create a script for each weapon and i would do that but i just cant think on how i would be able to allow the player to switch their weapon and i dont think that this is a very nice way t do things. I am a bit of a neat freak which is why i will not do things like above (currentAmmoType[0].damage = 10) i just cant bring my self to do it like this as i know this is a really stupid way of doing it.
I may be over thinking this which is why i am confusing my self on how to design this.
Any Help would be greatly appreciated.
Answer by Khada · Aug 22, 2012 at 05:50 PM
You want a Dictionary!
Thanks! i will check this out. If anyone else has any ideas please share ;)
Again Thanks $$anonymous$$hada
You're welcome. Trust me, it's the best way to access a list of items via string etc. When you figure out that I'm right, be sure to mark the question as answered xD
Did that end up working for you? Don't forget to mark the question as answered if it did.
I haven't used it yet tbh but from what i have read i am sure it will do the job i need
Thanks
Your answer
