-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunit_animation.hpp
82 lines (61 loc) · 2.21 KB
/
unit_animation.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
This file is part of Heroes of Wesnoth.
Copyright (C) 2007, 2008, 2009 Jon Ander Peñalba <[email protected]>
Heroes of Wesnoth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.
Heroes of Wesnoth is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Heroes of Wesnoth. If not, see <http://www.gnu.org/licenses/>
*/
/// @file
///
/// @author Jonan
#ifndef UNIT_ANIMATION_HPP
#define UNIT_ANIMATION_HPP
#include "util.hpp"
// Types of animations
enum {ATTACK, DIE, MOVE};
class Cell;
class Unit;
///
class UnitAnimation {
public:
UnitAnimation(void) : animation_in_progress(false) {} // Constructor
~UnitAnimation(void) {} // Destructor
// @{
/// Get functions.
int getType (void) {return type; }
Unit* getUnit (void) {return unit; }
Cell* getFinalPosition (void) {return final_position;}
// @}
/// Returns true if there's an animation in progress.
/// @return True if there's an animation in progress.
bool animationInProgress(void) {return animation_in_progress;}
/// Starts a new animation.
/// @param[in] type Type of animation.
/// @param[in] unit Unit to animate.
/// @param[in] cell Some types of animations need to specify a cell.
void startNewAnimation(int type, Unit &unit, Cell *cell = NULL);
/// Performs all needed actions in a frame of the animation.
/// @return True if this was the last frame of the animation.
bool frame(void);
private:
static const int FRAMES_PER_MOVE = 4;
// Starts a given animation.
void startAnimation(int type);
Unit *unit;
Cell *initial_position, *final_position;
bool cells_connected;
int type, state;
int frames;
bool animation_in_progress;
// To move the unit
int *path;
int movements, actual_move;
DISALLOW_COPY_AND_ASSIGN(UnitAnimation);
};
#endif // UNIT_ANIMATION_HPP