2016-04-12 16:11:36 +00:00
|
|
|
#include "resource_manager.hpp"
|
2016-04-11 00:49:40 +00:00
|
|
|
#include "kill_block.hpp"
|
2016-04-11 12:16:20 +00:00
|
|
|
#include "game.hpp"
|
2016-04-11 14:32:19 +00:00
|
|
|
#include "player.hpp"
|
2016-04-11 00:49:40 +00:00
|
|
|
|
|
|
|
const unsigned int KillBlock::TYPE_ID = 5;
|
|
|
|
|
|
|
|
KillBlock::KillBlock() : Block() {}
|
|
|
|
KillBlock::~KillBlock() {}
|
|
|
|
|
|
|
|
Object::Ptr KillBlock::clone() const {
|
|
|
|
return Object::Ptr(new KillBlock(*this));
|
|
|
|
}
|
|
|
|
|
|
|
|
void KillBlock::prepareDraw(ResourceManager& resources) {
|
|
|
|
Block::prepareDraw(resources);
|
|
|
|
sprite.setTexture(resources.getTexture("kill_block.tga"));
|
|
|
|
}
|
|
|
|
|
2016-04-11 14:32:19 +00:00
|
|
|
void KillBlock::activate(Game& game, Object::Ptr object) {
|
2016-04-11 12:16:20 +00:00
|
|
|
Block::activate(game, object);
|
2016-04-11 14:32:19 +00:00
|
|
|
|
|
|
|
// si un joueur touche un bloc de mort, on le tue
|
|
|
|
if (object->getTypeId() == Player::TYPE_ID) {
|
|
|
|
game.kill(object);
|
2016-04-11 18:01:41 +00:00
|
|
|
game.setMode(Game::Mode::LOST);
|
|
|
|
game.setDeathCause(Game::DeathCause::KILLED);
|
2016-04-11 14:32:19 +00:00
|
|
|
}
|
2016-04-11 00:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int KillBlock::getTypeId() const {
|
|
|
|
return TYPE_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KillBlock::init(std::ifstream& file, Object::Ptr object) {
|
|
|
|
// lecture des propriétés d'un bloc
|
|
|
|
Block::init(file, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object::Ptr KillBlock::load(std::ifstream& file) {
|
|
|
|
Object::Ptr object = Object::Ptr(new KillBlock);
|
|
|
|
KillBlock::init(file, object);
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KillBlock::save(std::ofstream& file) const {
|
|
|
|
// écriture des propriétés d'un bloc
|
|
|
|
Block::save(file);
|
|
|
|
}
|