diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-08-13 17:30:59 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-08-13 17:33:08 -0600 |
commit | f46cfb91278b27f4943f5512778129fe985c678e (patch) | |
tree | 0be219d66e723bcca8de2d584d66bc65d040fb26 /src/monster.cpp | |
parent | be85ca9d91ff867faf140328d0bcbb2062b58cdf (diff) | |
download | mana-f46cfb91278b27f4943f5512778129fe985c678e.tar.gz mana-f46cfb91278b27f4943f5512778129fe985c678e.tar.bz2 mana-f46cfb91278b27f4943f5512778129fe985c678e.tar.xz mana-f46cfb91278b27f4943f5512778129fe985c678e.zip |
Clean up Being and it's derivatives
Move stuff only needed for Players into Player (like slots and sprite
limits). Move name handling into Being (no need for three copies of
this code). Clean up terminology (including Map terminology). Remove
hair-related variables.
Diffstat (limited to 'src/monster.cpp')
-rw-r--r-- | src/monster.cpp | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index 3bdf1a62..cc2285fe 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -33,29 +33,24 @@ #include "resources/monsterinfo.h" Monster::Monster(int id, int job, Map *map): - Being(id, job, map), - mText(0) + Being(id, job, map) { const MonsterInfo& info = getInfo(); // Setup Monster sprites - int c = BASE_SPRITE; const std::list<std::string> &sprites = info.getSprites(); for (std::list<std::string>::const_iterator i = sprites.begin(); i != sprites.end(); i++) { - if (c == VECTOREND_SPRITE) break; - std::string file = "graphics/sprites/" + *i; - mSprites[c] = AnimatedSprite::load(file); - c++; + mSprites.push_back(AnimatedSprite::load(file)); } // Ensure that something is shown - if (c == BASE_SPRITE) + if (mSprites.size() == 0) { - mSprites[c] = AnimatedSprite::load("graphics/sprites/error.xml"); + mSprites.push_back(AnimatedSprite::load("graphics/sprites/error.xml")); } if (mParticleEffects) @@ -69,15 +64,11 @@ Monster::Monster(int id, int job, Map *map): } mNameColor = &guiPalette->getColor(Palette::MONSTER); + mTextColor = &guiPalette->getColor(Palette::MONSTER); Being::setName(getInfo().getName()); } -Monster::~Monster() -{ - delete mText; -} - #ifdef EATHENA_SUPPORT void Monster::logic() { @@ -93,11 +84,6 @@ void Monster::logic() } #endif -Being::Type Monster::getType() const -{ - return MONSTER; -} - void Monster::setAction(Action action, int attackType) { SpriteAction currentAction = ACTION_INVALID; @@ -115,7 +101,8 @@ void Monster::setAction(Action action, int attackType) break; case ATTACK: currentAction = getInfo().getAttackAction(attackType); - mSprites[BASE_SPRITE]->reset(); + for (SpriteIterator it = mSprites.begin(); it != mSprites.end(); it++) + (*it)->reset(); //attack particle effect particleEffect = getInfo().getAttackParticleEffect(attackType); @@ -147,11 +134,9 @@ void Monster::setAction(Action action, int attackType) if (currentAction != ACTION_INVALID) { - for (int i = 0; i < VECTOREND_SPRITE; i++) - { - if (mSprites[i]) - mSprites[i]->play(currentAction); - } + for (SpriteIterator it = mSprites.begin(); it != mSprites.end(); it++) + if (*it) + (*it)->play(currentAction); mAction = action; } } @@ -183,29 +168,18 @@ const MonsterInfo &Monster::getInfo() const return MonsterDB::get(mJob); } -void Monster::setShowName(bool show) +void Monster::updateCoords() { - delete mText; - - if (show) - { - mText = new Text(getInfo().getName(), - getPixelX(), - getPixelY() - getHeight(), - gcn::Graphics::CENTER, - &guiPalette->getColor(Palette::MONSTER)); - } - else + if (mDispName) { - mText = 0; + mDispName->adviseXY(getPixelX(), + getPixelY() - getHeight() - mDispName->getHeight()); } } -void Monster::updateCoords() +void Monster::showName() { - if (mText) - { - mText->adviseXY(getPixelX(), - getPixelY() - getHeight() - mText->getHeight()); - } + Being::showName(); + + updateCoords(); } |