Best way for associating Weapon and Ammo?
Currently, my Weapon system is like this:
each weapon-derived class has its own field called AMMO and its own enumeration called WeaponType used to identify that weapon in the game. This way, if I want to pickup some ammo for that weapon, I just need to do something like:
That will cycle through my
until it finds the weapon with that enumeration and, once found, gives it some ammo
I don't like this system. I find it unflexible.
I want AMMUNITIONS to be independent and for each weapon that I will introduce in the game, I should define which kinds of ammo it uses for its PrimaryFire and which ones for its SecondaryFire
Let's pretend I want to make a Lightning gun in Unreal Tournament style. Well, there will be ammunitions called, for example, "Electricity"
Now let's say I want to make another weapon, which uses Bullets for its PrimaryFire, but as secondary fire it uses Electricity ammunitions.
From this example, you see that Electricity and Bullet are two kinds of Ammunitions that don't really belong to a specific weapon. They're independent
How could I achieve this?
Follow this question
Once you sign in you will be able to subscribe for any updates here