X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=93a09ef77d8baa79726a59149880a1518364451f;hb=854e5229c3f30bf88aa08d7f0aff56a1411c3367;hp=35253ce099c2ae6bcf1617b81145798855379ce8;hpb=222167ba3722dc7f47ff7510006bd516e0010a50;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 35253ce..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) { @@ -58,26 +58,75 @@ void PerformAttacks::HandleEvents(const Input &input) { if (titleBarText) { titleBarText = 0; ++cursor; - while (cursor < (int)battle->Monsters().size() && !battle->MonsterPositionOccupied(cursor)) { + while (cursor < battle->MaxMonsters() && !battle->MonsterPositionOccupied(cursor)) { ++cursor; } - if (cursor >= (int)battle->Monsters().size()) { + if (cursor >= battle->MaxMonsters()) { battle->ClearAllAttacks(); 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 == (int)battle->Heroes().size()) { + 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); }