-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFighterAsteroidCollision.cpp
More file actions
47 lines (41 loc) · 1.22 KB
/
FighterAsteroidCollision.cpp
File metadata and controls
47 lines (41 loc) · 1.22 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
#include "FighterAsteroidCollision.h"
#include "Messages_defs.h"
#include "GameManager.h"
#include "Collisions.h"
#include "Messages_defs.h"
FighterAsteroidCollision::FighterAsteroidCollision() {
fighter_ = nullptr;
asteroids_ = nullptr;
}
FighterAsteroidCollision::~FighterAsteroidCollision() {}
void FighterAsteroidCollision::update(Container* c, Uint32 time) {
bool auxRunning = static_cast<GameManager*>(c)->getRunning();
if (auxRunning) {
if (fighter_ != nullptr || asteroids_ != nullptr) {
for (Asteroid* a : *asteroids_) {
if (fighter_->isActive() && a->isActive()) {
if (Collisions::collidesWithRotation(fighter_, a)) {
//Mensaje de colision
static_cast<GameManager*>(c)->getGame()->send(this, msg::FighterAsteroidCollisionMsg(c->getId(), msg::Broadcast, fighter_, a));
}
}
}
}
}
}
void FighterAsteroidCollision::receive(Container * c, const msg::Message & m) {
switch (m.type_) {
case msg::ASTEROIDS_INFO: {
const msg::AsteroidsInfo m_ = static_cast<const msg::AsteroidsInfo&>(m);
asteroids_ = m_.asteroids_;
break;
}
case msg::FIGHTER_INFO: {
const msg::FighterInfo m_ = static_cast<const msg::FighterInfo&>(m);
fighter_ = m_.fighter_;
break;
}
default:
break;
}
}