X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=c34e1144cdc6e4e54de9ca9ec1b6130bb6dafbd6;hb=f615f4edc547d1ca74275382cc7a9cdd8cf30ba6;hp=5906650e0418a42949ed44bb26ffaf3e697bd821;hpb=04b582180c8f86f50f08f5141a2514a1fcda3e01;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 5906650..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";