]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.cpp
switched geometric scalars from floating to fixed
[l2e.git] / src / battle / states / PerformAttacks.cpp
index a01a8fe0c540dd5b3b5c611b4dff52354fd72b20..2f750b2b4149c45d7794d40e6307347211755a94 100644 (file)
@@ -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"
 
 using app::Application;
 using app::Input;
-using geometry::Vector;
+using math::Vector;
 using graphics::AnimationRunner;
 using std::vector;
 
 namespace battle {
 
-void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) {
-       ctrl = &c;
+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::ExitState(Application &c, SDL_Surface *screen) {
+void PerformAttacks::OnExitState(SDL_Surface *screen) {
        battle->ClearAllAttacks();
-       ctrl = 0;
 }
 
-void PerformAttacks::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void PerformAttacks::OnResumeState(SDL_Surface *screen) {
 
 }
 
-void PerformAttacks::PauseState(Application &ctrl, SDL_Surface *screen) {
+void PerformAttacks::OnPauseState(SDL_Surface *screen) {
 
 }
 
 
-void PerformAttacks::Resize(int width, int height) {
+void PerformAttacks::OnResize(int width, int height) {
 
 }
 
@@ -62,19 +61,26 @@ void PerformAttacks::HandleEvents(const Input &input) {
        battle->ApplyDamage();
        battle->NextAttack();
        if (battle->AttacksFinished()) {
-               ctrl->PopState();
+               Ctrl().PopState();
                return;
        }
 
        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());
@@ -123,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()) {
@@ -196,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();
                }
        }
@@ -209,7 +217,7 @@ void PerformAttacks::ResetAnimation() {
 }
 
 
-void PerformAttacks::UpdateWorld(float deltaT) {
+void PerformAttacks::UpdateWorld(Uint32 deltaT) {
 
 }
 
@@ -218,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);
@@ -228,7 +237,7 @@ void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offs
        if (!titleBarText || !titleBarTimer.Running()) return;
 
        int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
-       battle->Res().titleFrame->Draw(screen, Vector<int>(offset.X(), offset.Y()), battle->Width(), height);
+       battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height);
 
        Vector<int> textPosition(
                        (battle->Width() - (std::strlen(titleBarText) * battle->Res().titleFont->CharWidth())) / 2,
@@ -245,7 +254,7 @@ void PerformAttacks::RenderNumbers(SDL_Surface *screen, const Vector<int> &offse
        }
 }
 
-void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
+void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const math::Vector<int> &offset) const {
        if (!targetAnimation.Valid() || !targetAnimation.Running()) return;
        const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection());
        if (ts.TargetsHeroes()) {