]> git.localhorst.tv Git - l2e.git/commitdiff
run monsters' attack animation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 19 Aug 2012 20:10:07 +0000 (22:10 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 19 Aug 2012 20:10:07 +0000 (22:10 +0200)
src/battle/BattleState.cpp
src/battle/states/PerformAttacks.cpp

index 7ea17d82c4e0c29f99e19444baf5fff338331b1b..b934039ef0a0a55b799a96d4d5af6e6a7ab26dbb 100644 (file)
@@ -420,7 +420,14 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offse
 void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset) {
        for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
                if (MonsterPositionOccupied(i)) {
-                       monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset);
+                       // TODO: better solution for running animations
+                       if (monsters[i].AttackAnimation() && monsters[i].AttackAnimation()->Running()) {
+                               monsters[i].AttackAnimation()->DrawCenter(screen, monsterPositions[i] + offset);
+                       } else if (monsters[i].SpellAnimation() && monsters[i].SpellAnimation()->Running()) {
+                               monsters[i].SpellAnimation()->DrawCenter(screen, monsterPositions[i] + offset);
+                       } else {
+                               monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset);
+                       }
                }
        }
 }
index 9a81e00ccc1b062970761497a2287de524f7c5da..86d7a7c69e35564fa9324192dff88530acc4f4c2 100644 (file)
@@ -71,9 +71,9 @@ void PerformAttacks::HandleEvents(const Input &input) {
        battle->CalculateDamage();
 
        if (battle->CurrentAttack().isMonster) {
-               const Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
+               Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
                titleBarText = monster.Name();
-               moveAnimation = 0;
+               moveAnimation = monster.AttackAnimation();
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
                const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));