]> git.localhorst.tv Git - l2e.git/blob - src/battle/AttackAnimation.h
added Maxim's melee animation
[l2e.git] / src / battle / AttackAnimation.h
1 /*
2  * AttackAnimation.h
3  *
4  *  Created on: Aug 13, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_ATTACKANIMATION_H_
9 #define BATTLE_ATTACKANIMATION_H_
10
11 #include "../app/Timer.h"
12 #include "../geometry/Point.h"
13 #include "../geometry/Vector.h"
14
15 #include <vector>
16 #include <SDL.h>
17
18 namespace app { class State; }
19 namespace graphics { class Animation; }
20
21 namespace battle {
22
23 class BattleState;
24
25 class AttackAnimation {
26
27 public:
28         AttackAnimation() : battle(0), state(0), cursor(0) { }
29         ~AttackAnimation();
30
31 public:
32         void StartTimer(int ms);
33         void PlayAttackAnimation();
34         void PlaySpellAnimation();
35         void PlayTargetAnimation(graphics::Animation *);
36         void PlayFullscreenAnimation(graphics::Animation *);
37         void WaitForTimer();
38         void WaitForAnimations();
39
40 public:
41         void Start(BattleState *, app::State *);
42         void Update();
43         bool Running() const;
44         bool Finished() const;
45         void Render(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
46
47 private:
48         bool ExecuteCommand();
49         bool ExecuteStartTimer();
50         bool ExecuteAttackAnimation();
51         bool ExecuteSpellAnimation();
52         bool ExecuteTargetAnimation();
53         bool ExecuteFullscreenAnimation();
54         bool ExecuteWaitTimer();
55         bool ExecuteWaitAnimations();
56
57 private:
58         enum Command {
59                 NOOP,
60                 START_TIMER,
61                 ATTACK_ANIMATION,
62                 SPELL_ANIMATION,
63                 TARGET_ANIMATION,
64                 FULLSCREEN_ANIMATION,
65                 WAIT_TIMER,
66                 WAIT_ANIMATIONS,
67         };
68         union Code {
69                 Code(Command c) : command(c) { }
70                 Code(int n) : number(n) { }
71                 Code(void *p) : ptr(p) { }
72                 Command command;
73                 int number;
74                 void *ptr;
75         };
76         BattleState *battle;
77         app::State *state;
78         std::vector<Code> text;
79         app::Timer<Uint32> timer;
80         struct AnimationMemo {
81                 graphics::Animation *animation;
82                 geometry::Point<int> position;
83         };
84         std::vector<AnimationMemo> animations;
85         std::vector<graphics::Animation *> foreignAnimations;
86         int cursor;
87
88 };
89
90 }
91
92 #endif /* BATTLE_ATTACKANIMATION_H_ */