X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=93a09ef77d8baa79726a59149880a1518364451f;hb=854e5229c3f30bf88aa08d7f0aff56a1411c3367;hp=f5a8c87334af8e064170b6b7771cfb7aca47703e;hpb=35f8a25fc914f10a8e987357bab94584af0992fb;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index f5a8c87..93a09ef 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -17,6 +17,7 @@ #include "../../common/Spell.h" #include "../../geometry/operators.h" #include "../../geometry/Point.h" +#include "../../graphics/Animation.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -31,7 +32,6 @@ 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) { @@ -66,18 +66,67 @@ void PerformAttacks::HandleEvents(const Input &input) { ctrl->PopState(); } } else { + if (cursor == 0) { + 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(); } } else { + const AttackChoice &ac(battle->AttackChoiceAt(cursor)); if (titleBarText) { titleBarText = 0; + + switch (ac.GetType()) { + case AttackChoice::SWORD: + if (battle->HeroAt(cursor).AttackAnimation()) { + battle->HeroAt(cursor).AttackAnimation()->Start(*this); + } + break; + case AttackChoice::MAGIC: + 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()) { + if (battle->HeroAt(cursor).SpellAnimation()) { + battle->HeroAt(cursor).SpellAnimation()->Start(*this); + } + } else { + if (battle->HeroAt(cursor).AttackAnimation()) { + battle->HeroAt(cursor).AttackAnimation()->Start(*this); + } + } + } + break; + case AttackChoice::ITEM: + break; + case AttackChoice::UNDECIDED: + break; + } + ++cursor; if (cursor == battle->NumHeroes()) { cursor = 0; monsters = true; } } else { - const AttackChoice &ac(battle->AttackChoiceAt(cursor)); + if (cursor > 0) { + 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: titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet"; @@ -113,7 +162,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); }