-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulletsniper.cpp
63 lines (58 loc) · 1.55 KB
/
bulletsniper.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
63
#include "bulletsniper.h"
#include "board.h"
#include "creature.h"
#include "math.h"
BulletSniper::BulletSniper(float _speed, int _width, int _height, int _damage, float _aimX, float _aimY, float _startX, float _startY, int _range)
:Bullet(_speed,_width,_height,_damage,_aimX,_aimY,_startX,_startY,_range)
{
}
BulletSniper::~BulletSniper()
{
}
//przestrzela osobe
void BulletSniper::checkField(Board *_map)
{
if(X<=0||Y<=0||Y+Height>=_map->getHeight()||X+Width>=_map->getWidth())
{
ToRemove=true;
return;
}
else if( BulletRange <= sqrt( pow((X-StartX),2) + pow((Y-StartY),2)) )
{
ToRemove=true;
return;
}
else
{
float X_c=X+Width/2;
float Y_c=Y+Height/2;
Object *obj=NULL;
Creature *cre=NULL;
for(int i=0;i<_map->getNumberOfObstacle();i++)
{
if(_map->getObstacle(i)->CanPass()==false)
{
obj=_map->getObstacle(i);
if( this->isOn(X_c,Y_c,obj) )
{
ToRemove=true;
return;
}
}
}
for(int i=0;i<_map->getNumberOfMobiles();i++)
{
cre=dynamic_cast<Creature*>(_map->getMobile(i));
if(cre)
{
obj=_map->getMobile(i);
if( this->isOn(X_c,Y_c,obj) )
{
//reduceHp(cre);//?????????????????????????????????????????
return;
}
}
cre=NULL;//
}
}
}