-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy.cpp
43 lines (38 loc) · 1.01 KB
/
Enemy.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
#include "Enemy.h"
Enemy::Enemy(int health, double xPos, double yPos, int radius, WeaponType activeWeapon):
Character(health, xPos, yPos, radius, activeWeapon){}
bool Enemy::Visit (AbstractGun &gun)
{
if (InRange(gun.GetX(), gun.GetY(), gun.GetProperties().GetRadius()))
{
Hit(gun.GetProperties().GetDamage());
return true;
}
return false;
}
bool Enemy::Visit (Grenade &grenade)
{
if (InRange(grenade.GetX(), grenade.GetY(), grenade.GetProperties().GetRadius()) && grenade.WillDestroy())
{
Hit(grenade.GetProperties().GetDamage());
return true;
}
return false;
}
bool Enemy::Visit (Bomb &bomb)
{
if (InRange(bomb.GetX(), bomb.GetY(), bomb.GetProperties().GetRadius()))
{
Hit(bomb.GetProperties().GetDamage());
return true;
}
return false;
}
bool Enemy::Visit (Nuke &nuke)
{
if (InRange(nuke.GetX(), nuke.GetY(), nuke.GetProperties().GetRadius()))
{
Hit(nuke.GetProperties().GetDamage());
}
return false;
}