Player does not get any gadgets on spawn now.

This commit is contained in:
Felix Ableitner 2013-08-30 15:35:20 +02:00
parent 55fbf1be20
commit 0daf1cf6d6
2 changed files with 15 additions and 11 deletions

View file

@ -9,9 +9,7 @@
#include <Thor/Vectors.hpp>
#include "generator/Generator.h"
#include "sprites/items/Heal.h"
#include "sprites/items/RingOfFire.h"
#include "generator/Generator.h"
#include "sprites/Enemy.h"
#include "sprites/Player.h"
#include "util/Loader.h"
@ -58,8 +56,6 @@ Game::Game(tgui::Window& window) :
void Game::initPlayer() {
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
mGenerator.getPlayerSpawn()));
mPlayer->setLeftGadget(std::shared_ptr<Gadget>(new Heal()));
mPlayer->setRightGadget(std::shared_ptr<Gadget>(new RingOfFire(mWorld)));
mWorld.insertCharacter(mPlayer);
}

View file

@ -289,22 +289,28 @@ Character::setRightGadget(std::shared_ptr<Gadget> gadget) {
void
Character::useLeftGadget() {
mLeftGadget->use(*this);
if (mLeftGadget)
mLeftGadget->use(*this);
}
void
Character::useRightGadget() {
mRightGadget->use(*this);
if (mRightGadget)
mRightGadget->use(*this);
}
std::string
Character::getLeftGadgetName() const {
return mLeftGadget->getName();
return (mLeftGadget)
? mLeftGadget->getName()
: "";
}
std::string
Character::getRightGadgetName() const {
return mRightGadget->getName();
return (mRightGadget)
? mRightGadget->getName()
: "";
}
/**
@ -331,8 +337,10 @@ Character::pickUpItem() {
}
std::shared_ptr<Gadget> gadget = std::dynamic_pointer_cast<Gadget>(closest);
if (gadget) {
mWorld.insert(mRightGadget);
mRightGadget->drop(getPosition());
if (mRightGadget) {
mWorld.insert(mRightGadget);
mRightGadget->drop(getPosition());
}
mRightGadget = mLeftGadget;
mLeftGadget = gadget;
}