]> git.localhorst.tv Git - l2e.git/blob - src/battle/AttackAnimation.h
added AttackAnimation
[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 Wait(int ms);
33         void WaitForAnimation();
34         void PlayAttackAnimation();
35         void PlaySpellAnimation();
36         void PlayTargetAnimation(graphics::Animation *);
37         void PlayFullscreenAnimation(graphics::Animation *);
38
39 public:
40         void Start(BattleState *, app::State *);
41         void Update();
42         bool Finished() const;
43         void Render(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
44
45 private:
46         bool ExecuteCommand();
47
48         bool ExecuteWait();
49         bool ExecuteWaitAnimation();
50         bool ExecuteAttackAnimation();
51         bool ExecuteSpellAnimation();
52         bool ExecuteTargetAnimation();
53         bool ExecuteFullscreenAnimation();
54
55 private:
56         enum Command {
57                 WAIT,
58                 WAIT_ANIMATION,
59                 ATTACK_ANIMATION,
60                 SPELL_ANIMATION,
61                 TARGET_ANIMATION,
62                 FULLSCREEN_ANIMATION,
63         };
64         union Code {
65                 Code(Command c) : command(c) { }
66                 Code(int n) : number(n) { }
67                 Code(void *p) : ptr(p) { }
68                 Command command;
69                 int number;
70                 void *ptr;
71         };
72         BattleState *battle;
73         app::State *state;
74         std::vector<Code> text;
75         app::Timer<Uint32> timer;
76         struct AnimationMemo {
77                 graphics::Animation *animation;
78                 geometry::Point<int> position;
79         };
80         std::vector<AnimationMemo> animations;
81         std::vector<graphics::Animation *> foreignAnimations;
82         int cursor;
83
84 };
85
86 }
87
88 #endif /* BATTLE_ATTACKANIMATION_H_ */