diff options
author | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-07-18 00:48:14 +0000 |
---|---|---|
committer | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-07-18 00:48:14 +0000 |
commit | 159285c5aa24611ceee7e3847a87bf9ea5f7fb7a (patch) | |
tree | fa48eb8bb8ed1e62ede1e7a2f95632c2243facab /src/monster.cpp | |
parent | 4dbc9b7af344d3ff006a40e3e0c06ce160f365f9 (diff) | |
download | mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.gz mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.bz2 mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.tar.xz mana-client-159285c5aa24611ceee7e3847a87bf9ea5f7fb7a.zip |
Import of client tree
Diffstat (limited to 'src/monster.cpp')
-rw-r--r-- | src/monster.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index e2a07e86..1a7f6c4e 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id$ + * $Id: monster.cpp 3823 2007-12-28 18:36:58Z crush_tmw $ */ #include "monster.h" @@ -27,14 +27,21 @@ #include "game.h" #include "sound.h" #include "particle.h" +#include "text.h" +#include "localplayer.h" + +#include "gui/gui.h" #include "resources/monsterdb.h" #include "utils/tostring.h" +static const int NAME_X_OFFSET = 16; +static const int NAME_Y_OFFSET = 16; Monster::Monster(Uint32 id, Uint16 job, Map *map): - Being(id, job, map) + Being(id, job, map), + mText(0) { const MonsterInfo& info = MonsterDB::get(job - 1002); @@ -59,6 +66,14 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): } } +Monster::~Monster() +{ + if (mText) + { + player_node->setTarget(0); + } +} + void Monster::logic() { @@ -141,3 +156,31 @@ Monster::getInfo() const { return MonsterDB::get(mJob - 1002); } + +void Monster::showName(bool show) +{ + if (mText) + { + delete mText; + } + if (show) + { + mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, + mPy + NAME_Y_OFFSET - getHeight(), + gcn::Graphics::CENTER, + speechFont, gcn::Color(255, 32, 32)); + } + else + { + mText = 0; + } +} + +void Monster::updateCoords() +{ + if (mText) + { + mText->adviseXY(mPx + NAME_X_OFFSET, + mPy + NAME_Y_OFFSET - getHeight()); + } +} |