X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=43414eb89a60d86e7964ad2f63861da7818f5b8e;hb=2255d436a0c2acc10b015827366a72b2ece86094;hp=a1a5b8b260226a5ad816765b1d14e419417f9582;hpb=3f8fac16c7ae2cbe7da47b98aba9b558825723e7;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index a1a5b8b..43414eb 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -10,6 +10,7 @@ #include "../BattleState.h" #include "../Hero.h" #include "../Monster.h" +#include "../TargetSelection.h" #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Ikari.h" @@ -29,21 +30,21 @@ using std::vector; namespace battle { -void PerformAttacks::OnEnterState(Application &c, SDL_Surface *screen) { +void PerformAttacks::OnEnterState(SDL_Surface *screen) { battle->CalculateAttackOrder(); numberAnimation.reserve(battle->MaxMonsters() > battle->NumHeroes() + 1 ? battle->MaxMonsters() : battle->NumHeroes() + 1); numberPosition.reserve(numberAnimation.size()); } -void PerformAttacks::OnExitState(Application &c, SDL_Surface *screen) { +void PerformAttacks::OnExitState(SDL_Surface *screen) { battle->ClearAllAttacks(); } -void PerformAttacks::OnResumeState(Application &ctrl, SDL_Surface *screen) { +void PerformAttacks::OnResumeState(SDL_Surface *screen) { } -void PerformAttacks::OnPauseState(Application &ctrl, SDL_Surface *screen) { +void PerformAttacks::OnPauseState(SDL_Surface *screen) { } @@ -66,13 +67,20 @@ void PerformAttacks::HandleEvents(const Input &input) { battle->CalculateDamage(); - if (battle->CurrentAttack().isMonster) { + if (battle->CurrentAttack().IsMonster()) { Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); titleBarText = monster.Name(); targetAnimation = AnimationRunner(monster.MeleeAnimation()); moveAnimation = AnimationRunner(monster.AttackAnimation()); monster.SetAnimation(moveAnimation); AddNumberAnimations(battle->MonsterAt(battle->CurrentAttack().index).GetAttackChoice().Selection()); + } else if (battle->CurrentAttack().IsCapsule()) { + Capsule &capsule(battle->GetCapsule()); + titleBarText = capsule.Name(); + targetAnimation = AnimationRunner(capsule.MeleeAnimation()); + moveAnimation = AnimationRunner(capsule.AttackAnimation()); + capsule.SetAnimation(moveAnimation); + AddNumberAnimations(capsule.GetAttackChoice().Selection()); } else { Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); const AttackChoice &ac(battle->HeroAt(battle->CurrentAttack().index).GetAttackChoice()); @@ -121,10 +129,12 @@ void PerformAttacks::HandleEvents(const Input &input) { if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(850); if (moveAnimation.Valid()) { moveAnimation.Start(*this); - if (battle->CurrentAttack().isMonster) { + if (battle->CurrentAttack().IsMonster()) { battle->MonsterAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); - } else { + } else if (battle->CurrentAttack().IsHero()) { battle->HeroAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); + } else { + battle->GetCapsule().SetAnimation(moveAnimation); } } if (targetAnimation.Valid()) { @@ -194,7 +204,7 @@ bool PerformAttacks::HasAnimationsRunning() const { void PerformAttacks::ResetAnimation() { if (moveAnimation.Valid()) { moveAnimation.Clear(); - if (!battle->CurrentAttack().isMonster) { + if (!battle->CurrentAttack().IsMonster()) { battle->HeroAt(battle->CurrentAttack().index).GetAnimation().Clear(); } } @@ -216,6 +226,7 @@ void PerformAttacks::Render(SDL_Surface *screen) { battle->RenderBackground(screen, offset); battle->RenderMonsters(screen, offset); battle->RenderHeroes(screen, offset); + battle->RenderCapsule(screen, offset); battle->RenderSmallHeroTags(screen, offset); RenderTitleBar(screen, offset); RenderNumbers(screen, offset);