Player does not get any gadgets on spawn now.
This commit is contained in:
parent
55fbf1be20
commit
0daf1cf6d6
2 changed files with 15 additions and 11 deletions
|
@ -10,8 +10,6 @@
|
||||||
#include <Thor/Vectors.hpp>
|
#include <Thor/Vectors.hpp>
|
||||||
|
|
||||||
#include "generator/Generator.h"
|
#include "generator/Generator.h"
|
||||||
#include "sprites/items/Heal.h"
|
|
||||||
#include "sprites/items/RingOfFire.h"
|
|
||||||
#include "sprites/Enemy.h"
|
#include "sprites/Enemy.h"
|
||||||
#include "sprites/Player.h"
|
#include "sprites/Player.h"
|
||||||
#include "util/Loader.h"
|
#include "util/Loader.h"
|
||||||
|
@ -58,8 +56,6 @@ Game::Game(tgui::Window& window) :
|
||||||
void Game::initPlayer() {
|
void Game::initPlayer() {
|
||||||
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
|
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
|
||||||
mGenerator.getPlayerSpawn()));
|
mGenerator.getPlayerSpawn()));
|
||||||
mPlayer->setLeftGadget(std::shared_ptr<Gadget>(new Heal()));
|
|
||||||
mPlayer->setRightGadget(std::shared_ptr<Gadget>(new RingOfFire(mWorld)));
|
|
||||||
mWorld.insertCharacter(mPlayer);
|
mWorld.insertCharacter(mPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,22 +289,28 @@ Character::setRightGadget(std::shared_ptr<Gadget> gadget) {
|
||||||
|
|
||||||
void
|
void
|
||||||
Character::useLeftGadget() {
|
Character::useLeftGadget() {
|
||||||
|
if (mLeftGadget)
|
||||||
mLeftGadget->use(*this);
|
mLeftGadget->use(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Character::useRightGadget() {
|
Character::useRightGadget() {
|
||||||
|
if (mRightGadget)
|
||||||
mRightGadget->use(*this);
|
mRightGadget->use(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Character::getLeftGadgetName() const {
|
Character::getLeftGadgetName() const {
|
||||||
return mLeftGadget->getName();
|
return (mLeftGadget)
|
||||||
|
? mLeftGadget->getName()
|
||||||
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Character::getRightGadgetName() const {
|
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);
|
std::shared_ptr<Gadget> gadget = std::dynamic_pointer_cast<Gadget>(closest);
|
||||||
if (gadget) {
|
if (gadget) {
|
||||||
|
if (mRightGadget) {
|
||||||
mWorld.insert(mRightGadget);
|
mWorld.insert(mRightGadget);
|
||||||
mRightGadget->drop(getPosition());
|
mRightGadget->drop(getPosition());
|
||||||
|
}
|
||||||
mRightGadget = mLeftGadget;
|
mRightGadget = mLeftGadget;
|
||||||
mLeftGadget = gadget;
|
mLeftGadget = gadget;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue