-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulletsHoleCollision.cpp
More file actions
51 lines (45 loc) · 1.17 KB
/
BulletsHoleCollision.cpp
File metadata and controls
51 lines (45 loc) · 1.17 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
#include "BulletsHoleCollision.h"
#include "Messages_defs.h"
#include "GameManager.h"
#include "Collisions.h"
#include "Messages_defs.h"
BulletsHoleCollision::BulletsHoleCollision()
{
bullets_ = nullptr;
holes_ = nullptr;
}
BulletsHoleCollision::~BulletsHoleCollision() {}
void BulletsHoleCollision::update(Container * c, Uint32 time)
{
bool auxRunning = static_cast<GameManager*>(c)->getRunning();
if (auxRunning) {
if (holes_ != nullptr || bullets_ != nullptr) {
for (Bullet* b : *bullets_) {
for (VeryDarkHole* a : *holes_) {
if (b->isActive() && a->isActive()) {
if (Collisions::collidesWithRotation(b, a)) {
static_cast<GameManager*>(c)->getGame()->send(this, msg::BulletHoleCollision(c->getId(), msg::Broadcast, b, a));
}
}
}
}
}
}
}
void BulletsHoleCollision::receive(Container * c, const msg::Message & m)
{
switch (m.type_) {
case msg::DARKHOLES_INFO: {
const msg::DarkHoleInfo m_ = static_cast<const msg::DarkHoleInfo&>(m);
holes_ = m_.holes_;
break;
}
case msg::BULLETS_INFO: {
const msg::BulletsInfoMsg m_ = static_cast<const msg::BulletsInfoMsg&>(m);
bullets_ = m_.bullets_;
break;
}
default:
break;
}
}