]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.h
extracted battle logic into a class
[l2e.git] / src / battle / states / PerformAttacks.h
index e0d3df821a0a66f944884048eef1f6c2fbd0d43c..37328dc89db6e01700a94855ac2aa6c9c95c9091 100644 (file)
@@ -1,21 +1,20 @@
-/*
- * PerformAttacks.h
- *
- *  Created on: Aug 10, 2012
- *      Author: holy
- */
-
 #ifndef BATTLE_PERFORMATTACKS_H_
 #define BATTLE_PERFORMATTACKS_H_
 
+namespace battle {
+       class Battle;
+       class BattleState;
+       class TargetSelection;
+}
+
 #include "../../app/State.h"
 
-#include "../BattleState.h"
-#include "../../geometry/Vector.h"
+#include "../NumberAnimation.h"
+#include "../../math/Vector.h"
+#include "../../graphics/Animation.h"
 
 #include <vector>
 
-namespace graphics { class Animation; }
 
 namespace battle {
 
@@ -23,35 +22,50 @@ class PerformAttacks
 : public app::State {
 
 public:
-       explicit PerformAttacks(BattleState *battle)
-       : ctrl(0), battle(battle), moveAnimation(0), titleBarText(0), cursor(-1) { }
+       PerformAttacks(Battle *battle, BattleState *parent);
 
 public:
-       virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
-       virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
-       virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
-       virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
-
-       virtual void Resize(int width, int height);
-
        virtual void HandleEvents(const app::Input &);
-       virtual void UpdateWorld(float deltaT);
+       virtual void UpdateWorld(Uint32 deltaT);
        virtual void Render(SDL_Surface *);
 
 private:
-       void RenderTitleBar(SDL_Surface *screen, const geometry::Vector<int> &offset);
+       virtual void OnEnterState(SDL_Surface *screen);
+       virtual void OnExitState(SDL_Surface *screen);
+       virtual void OnResumeState(SDL_Surface *screen);
+       virtual void OnPauseState(SDL_Surface *screen);
+
+       virtual void OnResize(int width, int height);
+
+private:
+       void CheckAnimations();
+       bool HasAnimationsRunning() const;
+       void ResetAnimation();
+
+private:
+       void AddNumberAnimations(const TargetSelection &);
+
+       void RenderTitleBar(SDL_Surface *screen) const;
+       void RenderNumbers(SDL_Surface *screen) const;
+       void RenderTargetAnimation(SDL_Surface *screen) const;
 
 private:
-       app::Application *ctrl;
-       BattleState *battle;
-       graphics::Animation *moveAnimation;
+       Battle *battle;
+       BattleState *parent;
+       graphics::AnimationRunner moveAnimation;
+       graphics::AnimationRunner targetAnimation;
        const char *titleBarText;
        app::Timer<Uint32> titleBarTimer;
-       std::vector<BattleState::Order> order;
+       app::Timer<Uint32> targetAnimationTimer;
+       std::vector<NumberAnimation> numberAnimation;
+       std::vector<math::Vector<int> > numberPosition;
+       math::Vector<int> framePosition;
+       math::Vector<int> frameSize;
+       math::Vector<int> textPosition;
        int cursor;
 
 };
 
 }
 
-#endif /* BATTLE_PERFORMATTACKS_H_ */
+#endif