-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeapon.cpp
More file actions
127 lines (96 loc) · 2.51 KB
/
Copy pathWeapon.cpp
File metadata and controls
127 lines (96 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "Weapon.h"
namespace SSJServer {
Bullet* Weapon::CreateBullet(Point ownerPosition, Degrees ownerAngle, WeaponType type){
BulletFactory::setOwnerPosition(ownerPosition);
BulletFactory::setOwnerAngle(ownerAngle);
switch(type){
case Glock:
return BulletFactory::CreateGlockBullet();
break;
case Uzi:
return BulletFactory::CreateUziBullet();
break;
case Ak47:
return BulletFactory::CreateAk47Bullet();
break;
case M16:
return BulletFactory::CreateM16Bullet();
break;
case Shotgun:
return BulletFactory::CreateShotgunBullet();
break;
case SniperRifle:
return BulletFactory::CreateSniperRifleBullet();
break;
case Bazooka:
return BulletFactory::CreateBazookaBullet();
break;
case Grenade:
return BulletFactory::CreateGrenadeBullet();
break;
case Knife:
return BulletFactory::CreateKnifeBullet();
break;
}
return NULL;
}
void Weapon::Shoot(){
this->timeBetweenBullets = this->clock.getElapsedTime();
this->clock.restart();
if(timeBetweenBullets.asSeconds() > this->fireRate){
//LayerContainer::GetGameLayer("trzecia")->addObject(Weapon::CreateBullet(this->owner->getMapPosition(), this->owner->getAngle(), this->type));
}
}
WeaponType Weapon::getName(){
return this->type;
}
Weapon::Weapon(){
this->ammo = maxAmmo;
this->clock.restart();
}
void Weapon::Hit(){
}
void Weapon::HitByBlast(){
}
int Weapon::getMaxAmmo(){
return this->maxAmmo;
}
int Weapon::getAmmo(){
return this->ammo;
}
void Weapon::setMaxAmmo(int maxAmmo){
this->maxAmmo = maxAmmo;
}
void Weapon::decreaseAmmo(){
if(this->ammo > 0)
this->ammo -= 1;
}
void Weapon::setAmmo(int ammo){
this->ammo = ammo;
}
void Weapon::setReloadTime(int reloadTime){
this->reloadTime = reloadTime;
}
void Weapon::setDamage(int damage){
this->damage = damage;
}
void Weapon::setFireRate(int fireRate){
this->fireRate = fireRate;
}
Weapon::~Weapon(){
}
void Weapon::update(){
}
void Weapon::SynchronizationObject(Json::Value){
}
Json::Value Weapon::serialize()
{
Json::Value object;
object[_J(_objectName)] = _Weapon;
object[_J(_mapPositionX)] = this->getMapPosition().x;
object[_J(_mapPositionY)] = this->getMapPosition().y;
object[_J(_activity)] = this->activity;
object[_J(_name)] = this->name;
return object;
}
}