Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Weapon.h"
- Weapon::Weapon(WeaponType type)
- {
- m_type = type;
- if (m_type == PISTOL)
- {
- m_clipSize = 6;
- }
- else if (m_type == SHOTGUN)
- {
- m_clipSize = 2;
- }
- else if (m_type == RIFLE)
- {
- m_clipSize = 13;
- }
- m_ammoCount = 0;
- }
- Weapon::Weapon(WeaponType type, int clipSize)
- {
- m_type = type;
- m_clipSize = clipSize;
- m_ammoCount = 0;
- }
- Weapon::Weapon(WeaponType type, int clipSize, int ammoCount)
- {
- m_type = type;
- m_clipSize = clipSize;
- m_ammoCount = ammoCount;
- }
- bool Weapon::Fire()
- {
- if(m_ammoCount > 0)
- {
- cout << "BANG" << endl;
- m_ammoCount--;
- }
- else
- {
- cout << "CLICK" << endl;
- }
- return true;
- }
- void Weapon::Reload(int ammoCount)
- {
- if (ammoCount >= (m_clipSize - m_ammoCount))
- {
- ammoCount = (m_clipSize - m_ammoCount);
- m_ammoCount += ammoCount;
- cout << "RELOADING" << endl;
- }
- else
- {
- m_ammoCount += ammoCount;
- cout << "RELOADING" << endl;
- }
- }
- int Weapon::CheckAmmo()
- {
- cout << "AMMO " << m_ammoCount << endl;
- return m_ammoCount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement