diff options
Diffstat (limited to 'src/resources/monsterinfo.cpp')
-rw-r--r-- | src/resources/monsterinfo.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp index 503990e7..2fc16bef 100644 --- a/src/resources/monsterinfo.cpp +++ b/src/resources/monsterinfo.cpp @@ -25,7 +25,6 @@ MonsterInfo::MonsterInfo() { - } MonsterInfo::~MonsterInfo() @@ -35,8 +34,7 @@ MonsterInfo::~MonsterInfo() mSounds.clear(); } - -void MonsterInfo::addSound(MonsterSoundEvent event, std::string filename) +void MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename) { if (mSounds.find(event) == mSounds.end()) { @@ -46,24 +44,41 @@ void MonsterInfo::addSound(MonsterSoundEvent event, std::string filename) mSounds[event]->push_back("sfx/" + filename); } +const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const +{ + static std::string empty(""); + std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i = + mSounds.find(event); + return (i == mSounds.end()) ? empty : + i->second->at(rand() % i->second->size()); +} -std::string MonsterInfo::getSound(MonsterSoundEvent event) const +const std::string &MonsterInfo::getAttackParticleEffect(int attackType) const { - std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i; + static std::string empty(""); + std::map<int, MonsterAttack*>::const_iterator i = + mMonsterAttacks.find(attackType); + return (i == mMonsterAttacks.end()) ? empty : (*i).second->particleEffect; +} - i = mSounds.find(event); +SpriteAction MonsterInfo::getAttackAction(int attackType) const +{ + std::map<int, MonsterAttack*>::const_iterator i = + mMonsterAttacks.find(attackType); + return (i == mMonsterAttacks.end()) ? ACTION_ATTACK : (*i).second->action; +} - if (i == mSounds.end()) - { - return ""; - } - else - { - return i->second->at(rand()%i->second->size()); - } +void MonsterInfo::addMonsterAttack(int id, + const std::string &particleEffect, + SpriteAction action) +{ + MonsterAttack *a = new MonsterAttack; + a->particleEffect = particleEffect; + a->action = action; + mMonsterAttacks[id] = a; } -void MonsterInfo::addParticleEffect(std::string filename) +void MonsterInfo::addParticleEffect(const std::string &filename) { mParticleEffects.push_back(filename); } |