]> git.localhorst.tv Git - l2e.git/blob - src/battle/AttackAnimation.h
revised attack animation codes
[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 Finished() const;
44         void Render(SDL_Surface *screen, const geometry::Vector<int> &offset) const;
45
46 private:
47         bool ExecuteCommand();
48         bool ExecuteStartTimer();
49         bool ExecuteAttackAnimation();
50         bool ExecuteSpellAnimation();
51         bool ExecuteTargetAnimation();
52         bool ExecuteFullscreenAnimation();
53         bool ExecuteWaitTimer();
54         bool ExecuteWaitAnimations();
55
56 private:
57         enum Command {
58                 NOOP,
59                 START_TIMER,
60                 ATTACK_ANIMATION,
61                 SPELL_ANIMATION,
62                 TARGET_ANIMATION,
63                 FULLSCREEN_ANIMATION,
64                 WAIT_TIMER,
65                 WAIT_ANIMATIONS,
66         };
67         union Code {
68                 Code(Command c) : command(c) { }
69                 Code(int n) : number(n) { }
70                 Code(void *p) : ptr(p) { }
71                 Command command;
72                 int number;
73                 void *ptr;
74         };
75         BattleState *battle;
76         app::State *state;
77         std::vector<Code> text;
78         app::Timer<Uint32> timer;
79         struct AnimationMemo {
80                 graphics::Animation *animation;
81                 geometry::Point<int> position;
82         };
83         std::vector<AnimationMemo> animations;
84         std::vector<graphics::Animation *> foreignAnimations;
85         int cursor;
86
87 };
88
89 }
90
91 #endif /* BATTLE_ATTACKANIMATION_H_ */