X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=c34e1144cdc6e4e54de9ca9ec1b6130bb6dafbd6;hb=b9fdb4fd361fbc0c8e2c0df9615e6eed540917a1;hp=f5a8c87334af8e064170b6b7771cfb7aca47703e;hpb=35f8a25fc914f10a8e987357bab94584af0992fb;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index f5a8c87..c34e114 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -19,6 +19,7 @@ #include "../../geometry/Point.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" +#include "../../graphics/SimpleAnimation.h" #include @@ -26,6 +27,7 @@ using app::Application; using app::Input; using geometry::Point; using geometry::Vector; +using graphics::SimpleAnimation; namespace battle { @@ -66,18 +68,62 @@ void PerformAttacks::HandleEvents(const Input &input) { ctrl->PopState(); } } else { + if (cursor == 0) { + battle->HeroAnimationAt(battle->NumHeroes() - 1).Stop(); + } titleBarText = battle->MonsterAt(cursor).Name(); } } else { + const AttackChoice &ac(battle->AttackChoiceAt(cursor)); if (titleBarText) { titleBarText = 0; + + switch (ac.GetType()) { + case AttackChoice::SWORD: + battle->HeroAnimationAt(cursor) = SimpleAnimation( + battle->HeroAt(cursor).Sprite(), + battle->HeroAt(cursor).AttackFrameTime(), + battle->HeroAt(cursor).AttackFrames(), 2); + break; + case AttackChoice::MAGIC: + battle->HeroAnimationAt(cursor) = SimpleAnimation( + battle->HeroAt(cursor).Sprite(), + battle->HeroAt(cursor).SpellFrameTime(), + battle->HeroAt(cursor).SpellFrames(), 3); + 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); + } else { + battle->HeroAnimationAt(cursor) = SimpleAnimation( + battle->HeroAt(cursor).Sprite(), + battle->HeroAt(cursor).AttackFrameTime(), + battle->HeroAt(cursor).AttackFrames(), 2); + } + } + break; + case AttackChoice::ITEM: + break; + case AttackChoice::UNDECIDED: + break; + } + battle->HeroAnimationAt(cursor).Start(*this); + ++cursor; if (cursor == battle->NumHeroes()) { cursor = 0; monsters = true; } } else { - const AttackChoice &ac(battle->AttackChoiceAt(cursor)); + if (cursor > 0) { + battle->HeroAnimationAt(cursor - 1).Stop(); + } switch (ac.GetType()) { case AttackChoice::SWORD: titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet"; @@ -113,7 +159,7 @@ void PerformAttacks::Render(SDL_Surface *screen) { battle->RenderBackground(screen, offset); battle->RenderMonsters(screen, offset); battle->RenderHeroes(screen, offset); - // render small tags + battle->RenderSmallHeroTags(screen, offset); RenderTitleBar(screen, offset); }