-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFighter.cpp
49 lines (40 loc) · 946 Bytes
/
Fighter.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
#include "Fighter.h"
Fighter::Fighter(REGION r_region, int r_ArrivalTimeStamp, double r_Health, int r_FirePower, int r_ReloadTime, int r_ID,int r_Speed)
:Enemy( r_region, r_ArrivalTimeStamp, r_Health, r_FirePower, r_ReloadTime, r_ID, r_Speed)
{
Clr = DARKOLIVEGREEN;//default color (the same for the rest)
Type = 1;
}
Fighter::Fighter()
{}
double Fighter::CalcDamageOnTower()
{
return (1/double(Distance)*FirePower);
}
void Fighter::Move(int& Unpaved)
{
int Diff=Distance-Unpaved;
if(Diff>EnemySpeed)
Distance-=EnemySpeed;
else
{
Distance-=Diff-1;
}
}
void Fighter::Attack(int TimeStep,double& HealthOfTower,int& Unpaved)
{
if(TimeStep == (AttackTime+1))
{
AttackTime += ReloadTime + 1;
double EnemyDamage = CalcDamageOnTower();
HealthOfTower -= EnemyDamage;
}
Move(Unpaved);
}
void Fighter::CalcDamageOnEnemy(double FirePower)
{
Health=Health-((1/double(Distance))*FirePower);
}
Fighter::~Fighter(void)
{
}