This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/items/Shield.cpp

41 lines
826 B
C++
Raw Normal View History

2013-07-10 21:25:53 +00:00
/*
* Shield.cpp
*
* Created on: 06.07.2013
* Author: Felix
*/
#include "Shield.h"
#include "../abstract/Character.h"
#include "../sprites/RotatingShield.h"
#include "../World.h"
2013-07-10 21:41:24 +00:00
Shield::Shield() :
Gadget("Shield") {
}
2013-07-10 21:25:53 +00:00
void
Shield::onUse(Character& character) {
mCharacter = &character;
if (mRotatingShield)
mRotatingShield->setDelete(true);
sf::Vector2f offset = mCharacter->getDirection() * mCharacter->getRadius();
mRotatingShield = std::shared_ptr<RotatingShield>(
new RotatingShield(mCharacter->getPosition() + offset));
mCharacter->mWorld.insert(mRotatingShield);
}
void
Shield::onThink(int elapsed) {
if (mRotatingShield) {
mRotatingShield->setDirection(mCharacter->getPosition() -
mRotatingShield->getPosition());
}
}
sf::Time
Shield::getCooldownTime() {
return sf::seconds(10);
}