I can't find a good way to achieve a good Weapon/Ammunition system.
Let me explain:
I have different kind of Ammunitions, such as Rocket, Grenades, Bullets, Electricity...
I want a weapon system were Ammunitions are independent: that means multiple weapons can use the same kind of ammo.
Let's say I have these 4 kind of Ammunitions:
+Rockets
+Grenades
+Bullets
For each weapon I will implement in the game, I want to establish which kind of Ammunition the weapon's PrimaryFire and SecondaryFire must decrease Ammo from.
EXAMPLE:
I have a Shotgun which only uses Bullets, and another casual weapon which uses Bullets as PrimaryFire and Electricity as Secondary.
In this example, you see I have two weapons which share the same Ammo: Bullets
So this confirms my concept: Ammunitions are independent. They are just there waiting for a Weapon which uses them.
Is this a classic application of inheritance and polymorphism?
Couldn't you create a base class called Ammunition which would house the common attributes of all of the ammunition in the base class, and then derive Rockets, Grenades, Bullets? The base class could have a virtual fire() method that each of the derived classes over-ride to specifically handle their own firing events.
From there, each weapon could have a data-member Ammunition* (pointer to ammunition) for primaryFire and secondaryFire which could point to ANY type of ammunition and call it's appropriate fire() method.
I come from a long experience with C++, so I do know what polymorphism is.
Anyway, the Fire() method is described by the weapon, it's not something an Ammunition has.
Ammunitions in my case are just pieces with a name (or, better, enumeration) to identify them and two integers: MaxAmmo (for storing the maximum ammount of ammo it can hold) and CurrentAmmo (for keeping track of the current ammount of ammo in the player's inventory)