X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=93a09ef77d8baa79726a59149880a1518364451f;hb=854e5229c3f30bf88aa08d7f0aff56a1411c3367;hp=c34e1144cdc6e4e54de9ca9ec1b6130bb6dafbd6;hpb=b9fdb4fd361fbc0c8e2c0df9615e6eed540917a1;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index c34e114..93a09ef 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -17,9 +17,9 @@ #include "../../common/Spell.h" #include "../../geometry/operators.h" #include "../../geometry/Point.h" +#include "../../graphics/Animation.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" -#include "../../graphics/SimpleAnimation.h" #include @@ -27,13 +27,11 @@ using app::Application; using app::Input; using geometry::Point; using geometry::Vector; -using graphics::SimpleAnimation; namespace battle { void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) { ctrl = &c; - // TODO: push battle animation if enemy is faster } void PerformAttacks::ExitState(Application &c, SDL_Surface *screen) { @@ -69,7 +67,12 @@ void PerformAttacks::HandleEvents(const Input &input) { } } else { if (cursor == 0) { - battle->HeroAnimationAt(battle->NumHeroes() - 1).Stop(); + if (battle->HeroAt(battle->NumHeroes() - 1).AttackAnimation()) { + battle->HeroAt(battle->NumHeroes() - 1).AttackAnimation()->Stop(); + } + if (battle->HeroAt(battle->NumHeroes() - 1).SpellAnimation()) { + battle->HeroAt(battle->NumHeroes() - 1).SpellAnimation()->Stop(); + } } titleBarText = battle->MonsterAt(cursor).Name(); } @@ -80,31 +83,27 @@ void PerformAttacks::HandleEvents(const Input &input) { switch (ac.GetType()) { case AttackChoice::SWORD: - battle->HeroAnimationAt(cursor) = SimpleAnimation( - battle->HeroAt(cursor).Sprite(), - battle->HeroAt(cursor).AttackFrameTime(), - battle->HeroAt(cursor).AttackFrames(), 2); + if (battle->HeroAt(cursor).AttackAnimation()) { + battle->HeroAt(cursor).AttackAnimation()->Start(*this); + } break; case AttackChoice::MAGIC: - battle->HeroAnimationAt(cursor) = SimpleAnimation( - battle->HeroAt(cursor).Sprite(), - battle->HeroAt(cursor).SpellFrameTime(), - battle->HeroAt(cursor).SpellFrames(), 3); + if (battle->HeroAt(cursor).SpellAnimation()) { + battle->HeroAt(cursor).SpellAnimation()->Start(*this); + } break; case AttackChoice::DEFEND: break; case AttackChoice::IKARI: if (ac.GetItem()->HasIkari()) { if (ac.GetItem()->GetIkari()->IsMagical()) { - battle->HeroAnimationAt(cursor) = SimpleAnimation( - battle->HeroAt(cursor).Sprite(), - battle->HeroAt(cursor).SpellFrameTime(), - battle->HeroAt(cursor).SpellFrames(), 3); + if (battle->HeroAt(cursor).SpellAnimation()) { + battle->HeroAt(cursor).SpellAnimation()->Start(*this); + } } else { - battle->HeroAnimationAt(cursor) = SimpleAnimation( - battle->HeroAt(cursor).Sprite(), - battle->HeroAt(cursor).AttackFrameTime(), - battle->HeroAt(cursor).AttackFrames(), 2); + if (battle->HeroAt(cursor).AttackAnimation()) { + battle->HeroAt(cursor).AttackAnimation()->Start(*this); + } } } break; @@ -113,7 +112,6 @@ void PerformAttacks::HandleEvents(const Input &input) { case AttackChoice::UNDECIDED: break; } - battle->HeroAnimationAt(cursor).Start(*this); ++cursor; if (cursor == battle->NumHeroes()) { @@ -122,7 +120,12 @@ void PerformAttacks::HandleEvents(const Input &input) { } } else { if (cursor > 0) { - battle->HeroAnimationAt(cursor - 1).Stop(); + if (battle->HeroAt(cursor - 1).AttackAnimation()) { + battle->HeroAt(cursor - 1).AttackAnimation()->Stop(); + } + if (battle->HeroAt(cursor - 1).SpellAnimation()) { + battle->HeroAt(cursor - 1).SpellAnimation()->Stop(); + } } switch (ac.GetType()) { case AttackChoice::SWORD: