Have a weapon class and have derived classes like (Glock, M16 and etc) from it and create all the data by making instances like
Code: Select all
class Glock : public Weapon
{
private:
public:
}
Glock glock;
Or I could create instances of the weapon class like such:
Code: Select all
Weapon M16(32,4,2,9) //In parameters: Magsize, bulletdmg, X, Y)
Weapon Glock(17,2,8,9)
What i was thinking is that I can set each loadout with default weapons for each type like:
Code: Select all
Loadout Assault;
Assault->Primary.SetDefaultPrimary(&M16); //the assault loadout's primary weapon is the M16
Assault->Primary.SetDefaultSecondary(&Glock);
Assault->Primary.SetDefaultProjectile(&RPG);
cout << "Current Weapon:" << Assault->Primary.Name << endl;
cout << "Bullet Dmg:" << Assault->Primary.BulletDmg << endl; //for test
Current Weapon: M16
Bullet Damage: 4
So the in the player class, the player doesn't necessarily have the weapon but instead the Loadout class handles that. So whatever loadout the player has, the weapons he'll have is whatever weapons are in that loadout. Problem is that Loadouts are not gonna always have default weapons. In game, the player can change his weapon by picking up weapons or switching them. Loadouts can also be customized to fit the players wants.
Other notes:
The system runs like this. The player chooses their loadout and based on the pick, the player's primary, secondary and projectile weapons are chosen. In the beginning of the game, each loadout already has the defaults set.
Code: Select all
Player -----> Loadout ----> Weapon