Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
titleBarText = monster.Name();
moveAnimation = monster.AttackAnimation();
+ targetAnimation = monster.MeleeAnimation();
+ AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection());
} else {
Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
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();
}
}
+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);
void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
if (!targetAnimation || !targetAnimation->Running()) return;
- if (battle->CurrentAttack().isMonster) return; // no monsters for now
- const TargetSelection &ts(battle->AttackChoiceAt(battle->CurrentAttack().index).Selection());
+ const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection());
const vector<Point<int> > &positions(ts.TargetsHeroes() ? battle->HeroesPositions() : battle->MonsterPositions());
for (vector<Point<int> >::size_type i(0), end(positions.size()); i < end; ++i) {
if (ts.IsSelected(i)) {