X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=238849b3f5da06638e04925fe5311d246e6a7783;hb=d2f44bfe5d159647431cee8ab29898bd3618d980;hp=10fb8bb11294c6f0f517d1def1efd528cbd86cbb;hpb=d4609ba1798d82cce128b5985d60cb212b760246;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 10fb8bb..238849b 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -75,7 +75,7 @@ void PerformAttacks::HandleEvents(const Input &input) { titleBarText = monster.Name(); moveAnimation = monster.AttackAnimation(); targetAnimation = monster.MeleeAnimation(); - // TODO: add number animations + AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection()); } else { Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index)); @@ -90,24 +90,7 @@ void PerformAttacks::HandleEvents(const Input &input) { targetAnimation = hero.MeleeAnimation(); } moveAnimation = hero.AttackAnimation(); - - if (ac.Selection().TargetsEnemies()) { - for (int i(0); i < battle->MaxMonsters(); ++i) { - if (ac.Selection().IsSelected(i)) { - numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); - numberPosition.push_back( - battle->MonsterPositions()[i]); - } - } - } else { - for (int i(0); i < battle->NumHeroes(); ++i) { - if (ac.Selection().IsSelected(i)) { - numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); - numberPosition.push_back( - battle->HeroesPositions()[i]); - } - } - } + AddNumberAnimations(ac.Selection()); break; case AttackChoice::MAGIC: titleBarText = ac.GetSpell()->Name(); @@ -147,6 +130,34 @@ void PerformAttacks::HandleEvents(const Input &input) { } } +void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) { + if (ts.TargetsEnemies()) { + for (int i(0); i < battle->MaxMonsters(); ++i) { + if (ts.IsBad(i)) { + numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); + numberPosition.push_back( + battle->MonsterPositions()[i]); + } else if (ts.IsGood(i)) { + numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite)); + numberPosition.push_back( + battle->MonsterPositions()[i]); + } + } + } else { + for (int i(0); i < battle->NumHeroes(); ++i) { + if (ts.IsBad(i)) { + numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); + numberPosition.push_back( + battle->HeroesPositions()[i]); + } else if (ts.IsGood(i)) { + numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite)); + numberPosition.push_back( + battle->HeroesPositions()[i]); + } + } + } +} + void PerformAttacks::CheckAnimations() { if (targetAnimation && targetAnimationTimer.JustHit()) { targetAnimation->Start(*this);