00001
00002
00003
00004
00005
00006
00007
00009
00016 #ifndef __MAP_ACTIONS_HEADER__
00017 #define __MAP_ACTIONS_HEADER__
00018
00019 #include <string>
00020 #include <vector>
00021
00022 #include "defs.h"
00023 #include "utils.h"
00024 #include "map.h"
00025
00026 namespace hoa_map {
00027
00028 namespace private_map {
00029
00040 class SpriteAction {
00041 public:
00042 SpriteAction(VirtualSprite *sprite) :
00043 _sprite(sprite), _finished(false), _forced(false) {}
00044
00045 virtual ~SpriteAction()
00046 {}
00047
00049 virtual void Execute() = 0;
00050
00054 const bool IsFinished()
00055 { return _finished; }
00056
00061 bool IsFinishedReset()
00062 { if (!_finished) return false; else _finished = false; return true; }
00063
00067 bool IsForced() const
00068 { return _forced; }
00069
00070 void SetFinished(bool fin)
00071 { _finished = fin; }
00072
00073 void SetForced(bool forc)
00074 { _forced = forc; }
00075
00076 void SetSprite(VirtualSprite* sp)
00077 { _sprite = sp; }
00078
00079 protected:
00081 VirtualSprite *_sprite;
00082
00084 bool _finished;
00085
00087 bool _forced;
00088 };
00089
00090
00101 class ActionPathMove : public SpriteAction {
00102 public:
00103
00104
00106 PathNode destination;
00107
00109 std::vector<PathNode> path;
00110
00112 uint32 current_node;
00113
00114
00115
00116 ActionPathMove(VirtualSprite* sprite) :
00117 SpriteAction(sprite), current_node(0) {}
00118
00119 ~ActionPathMove()
00120 {}
00121
00122 void Execute();
00123
00124 void SetDestination(int16 x, int16 y)
00125 { destination.col = x; destination.row = y; }
00126 };
00127
00128
00138 class ActionRandomMove : public SpriteAction {
00139 public:
00140
00145 uint32 total_movement_time;
00146
00148 uint32 movement_timer;
00149
00153 uint32 total_direction_time;
00154
00156 uint32 direction_timer;
00157
00161 MapZone* zone;
00162
00163
00164
00165 ActionRandomMove(VirtualSprite* sprite) :
00166 SpriteAction(sprite), total_movement_time(10000), movement_timer(0), total_direction_time(2000), direction_timer(0) {}
00167
00168 ~ActionRandomMove()
00169 {}
00170
00171 void Execute();
00172 };
00173
00174
00193 class ActionAnimate : public SpriteAction {
00194 public:
00198 std::vector<uint16> frames;
00199
00203 std::vector<uint32> display_times;
00204
00206 uint32 current_frame;
00207
00209 uint32 timer;
00210
00212 int8 loop_count;
00213
00222 int8 loops;
00223
00224 ActionAnimate(VirtualSprite* sprite) :
00225 SpriteAction(sprite), current_frame(0), timer(0), loops(0) {}
00226
00227 ~ActionAnimate()
00228 {}
00229
00230 void Execute();
00231
00232 void AddFrame(uint16 frame, uint32 time)
00233 { frames.push_back(frame); display_times.push_back(time); }
00234
00235 void SetLoops(int8 count)
00236 { loops = count; }
00237 };
00238
00239
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 }
00258
00259 }
00260
00261 #endif