From 41b407e611966cf2499e7e2cf70834944f1ba2df Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 18 Sep 2013 15:39:47 +0200 Subject: [PATCH] Disabled automatic pickup of Health Orb (has to be done manually). --- src/Game.cpp | 7 +------ src/main.cpp | 2 -- src/sprites/abstract/Character.cpp | 11 ++++++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index e879d9e..7139839 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -187,12 +187,7 @@ Game::updateGui() { mWindow.getSize().y - mRightGadget->getSize().y); auto item = mWorld.getClosestItem(mPlayer->getPosition()); - auto orb = std::dynamic_pointer_cast(item); - if (orb && mPlayer->getHealth() < mPlayer->getMaxHealth()) { - mPlayer->onDamage(- orb->getAmountHealed()); - mWorld.remove(item); - } - else if (item) { + if (item) { mPickupInstruction->setText("F - pick up " + item->getName()); mPickupInstruction->setPosition( mWindow.getSize().x / 2 - mPickupInstruction->getSize().x / 2, diff --git a/src/main.cpp b/src/main.cpp index 84d5a91..479390b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,8 +12,6 @@ #include "util/Vector.h" -// TODO: remove right click move (also in readme) - /** * Creates Game object. */ diff --git a/src/sprites/abstract/Character.cpp b/src/sprites/abstract/Character.cpp index f6056e4..3964936 100644 --- a/src/sprites/abstract/Character.cpp +++ b/src/sprites/abstract/Character.cpp @@ -343,7 +343,10 @@ Character::pickUpItem() { return; } - std::shared_ptr weapon = std::dynamic_pointer_cast(closest); + auto weapon = std::dynamic_pointer_cast(closest); + auto gadget = std::dynamic_pointer_cast(closest); + auto orb = std::dynamic_pointer_cast(closest); + if (weapon) { mWorld.insert(mActiveWeapon); mActiveWeapon->drop(getPosition()); @@ -351,8 +354,7 @@ Character::pickUpItem() { ? setFirstWeapon(weapon) : setSecondWeapon(weapon); } - std::shared_ptr gadget = std::dynamic_pointer_cast(closest); - if (gadget) { + else if (gadget) { if (mRightGadget) { mWorld.insert(mRightGadget); mRightGadget->drop(getPosition()); @@ -360,6 +362,9 @@ Character::pickUpItem() { mRightGadget = mLeftGadget; mLeftGadget = gadget; } + else if (orb) { + onDamage(- orb->getAmountHealed()); + } mWorld.remove(closest); }