-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZombie.cpp
62 lines (50 loc) · 1.3 KB
/
Zombie.cpp
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
#include "ShootingGame.h"
#include "Zombie.h"
#include "Hero.h"
#include "Bullet.h"
#include "HealthBonus.h"
#include "ArmorBonus.h"
using namespace std;
Zombie :: Zombie(double xIn, double yIn, double hpmaxIn, double hpcurrentIn, double speedIn, double damageIn, double attackCDIn, double attackRateIn, double rangeIn, ShootingGame* shootIn) : LivingEntity(xIn, yIn, hpmaxIn, hpcurrentIn, speedIn, damageIn, shootIn)
{
range = rangeIn;
attackCD = attackCDIn;
attackRate = attackRateIn;
}
bool Zombie::attackCounter(float fElapsedTime) {
attackCD -= fElapsedTime;
if (attackCD <= 0) {
return 1;
}
else {
return 0;
}
}
void Zombie::CdReset() {
attackCD = attackRate;
}
void Zombie::HealthBonusCreate(ShootingGame* theGame) {
theGame->HealthCreate(theGame, x, y);
}
void Zombie::ArmorBonusCreate(ShootingGame* theGame) {
theGame->ArmorCreate(theGame, x, y);
}
void Zombie::GrenadeBonusCreate(ShootingGame* theGame) {
theGame->GrenadeCreate(theGame, x, y);
}
bool Zombie::isInRange(shared_ptr<Hero> myHero) {
if (myHero->distanceCalculator(x, y) < range) {
return 1;
}
else {
return 0;
}
}
bool Zombie::isGonnaGetHit(shared_ptr<Entity> myEntity) {
if (myEntity->distanceCalculator(x, y) < range) {
return 1;
}
else {
return 0;
}
}