00001 #ifndef COMMAND_H 00002 #define COMMAND_H 00003 00004 #include <string> 00005 #include "SDL_mixer.h" 00006 #include "Sprite.h" 00007 00008 class Object; 00009 class Person; 00010 class List; 00011 00012 class Command 00013 { 00014 public: 00015 virtual void execute()=0; 00016 virtual std::string getString()=0; 00017 static Command *loadCommand(List *command); 00018 00019 }; 00020 00021 class JumpCommand : public Command 00022 { 00023 public: 00024 JumpCommand(Person* person, xDirection xDir); 00025 JumpCommand(List *command); 00026 void execute(); 00027 std::string getString(); 00028 static std::string id() {return _id;} 00029 private: 00030 Person* _person; 00031 xDirection _xDir; 00032 00033 static const std::string _id; 00034 }; 00035 00036 class JumpResetCommand : public Command 00037 { 00038 public: 00039 JumpResetCommand(Person* person); 00040 JumpResetCommand(List *command); 00041 void execute(); 00042 std::string getString(); 00043 static std::string id() {return _id;} 00044 private: 00045 Person* _person; 00046 00047 static const std::string _id; 00048 }; 00049 00050 class CrouchCommand : public Command 00051 { 00052 public: 00053 CrouchCommand(Person* person, bool crouch = true); 00054 CrouchCommand(List *command); 00055 void execute(); 00056 std::string getString(); 00057 static std::string id() {return _id;} 00058 private: 00059 Person* _person; 00060 bool _crouch; 00061 00062 static const std::string _id; 00063 }; 00064 00065 class MoveCommand: public Command 00066 { 00067 public: 00068 MoveCommand(Person *person, xDirection xDir); 00069 MoveCommand(List *command); 00070 00071 void execute(); 00072 std::string getString(); 00073 static std::string id() {return _id;} 00074 private: 00075 Person * _person; 00076 xDirection _xDir; 00077 00078 static const std::string _id; 00079 }; 00080 00081 class TurnCommand: public Command 00082 { 00083 public: 00084 TurnCommand(Person *person, xDirection xDir); 00085 TurnCommand(List *command); 00086 00087 void execute(); 00088 std::string getString(); 00089 static std::string id() {return _id;} 00090 private: 00091 Person * _person; 00092 xDirection _xDir; 00093 00094 static const std::string _id; 00095 }; 00096 00097 class PlayMusicCommand: public Command 00098 { 00099 public: 00100 PlayMusicCommand( std::string filename ); 00101 PlayMusicCommand( List* command ); 00102 void execute(); 00103 std::string getString(); 00104 static std::string id() { return _id; } 00105 private: 00106 Mix_Music* _music; 00107 std::string _filename; 00108 00109 static const std::string _id; 00110 }; 00111 00112 class PlaySoundCommand: public Command 00113 { 00114 public: 00115 PlaySoundCommand( std::string filename ); 00116 PlaySoundCommand( List* command ); 00117 void execute(); 00118 std::string getString(); 00119 static std::string id() { return _id; } 00120 private: 00121 std::string _filename; 00122 00123 static const std::string _id; 00124 }; 00125 00126 class FollowPlayerCommand: public Command 00127 { 00128 public: 00129 FollowPlayerCommand(Person *person); 00130 FollowPlayerCommand(List *command); 00131 00132 void execute(); 00133 std::string getString(); 00134 static std::string id() {return _id;} 00135 private: 00136 Person * _person; 00137 00138 static const std::string _id; 00139 }; 00140 00141 class FollowPlayerInRangeCommand: public Command 00142 { 00143 public: 00144 FollowPlayerInRangeCommand(Person *person, int range); 00145 FollowPlayerInRangeCommand(List *command); 00146 00147 void execute(); 00148 std::string getString(); 00149 static std::string id() {return _id;} 00150 private: 00151 Person * _person; 00152 int _range; 00153 00154 static const std::string _id; 00155 }; 00156 00157 class ShootInRangeCommand: public Command 00158 { 00159 public: 00160 ShootInRangeCommand(Person *person, int range); 00161 ShootInRangeCommand(List *command); 00162 00163 void execute(); 00164 std::string getString(); 00165 static std::string id() { return _id; } 00166 private: 00167 Person * _person; 00168 int _shootRange; 00169 static const std::string _id; 00170 }; 00171 00172 class ShootCommand: public Command 00173 { 00174 public: 00175 ShootCommand(Person *person); 00176 ShootCommand(List *command); 00177 00178 void execute(); 00179 std::string getString(); 00180 static std::string id() { return _id; } 00181 private: 00182 Person * _person; 00183 static const std::string _id; 00184 }; 00185 00186 class CutSceneTextCommand : public Command 00187 { 00188 public: 00189 CutSceneTextCommand(std::string text); 00190 CutSceneTextCommand(List *command); 00191 00192 void execute(); 00193 std::string getString(); 00194 static std::string id() { return _id; } 00195 private: 00196 std::string _text; 00197 static const std::string _id; 00198 }; 00199 00200 class SetCameraCommand : public Command 00201 { 00202 public: 00203 SetCameraCommand(Object *object); 00204 SetCameraCommand(List *command); 00205 00206 void execute(); 00207 std::string getString(); 00208 static std::string id() {return _id;} 00209 private: 00210 Object *_object; 00211 static const std::string _id; 00212 }; 00213 00214 class SetControlCommand : public Command 00215 { 00216 public: 00217 SetControlCommand(Object *object); 00218 SetControlCommand(List *command); 00219 00220 void execute(); 00221 std::string getString(); 00222 static std::string id() {return _id;} 00223 private: 00224 Object *_object; 00225 static const std::string _id; 00226 }; 00227 00228 class PlayScriptCommand : public Command 00229 { 00230 public: 00231 PlayScriptCommand(std::string filename); 00232 PlayScriptCommand(List *command); 00233 00234 void execute(); 00235 std::string getString(); 00236 static std::string id() {return _id;} 00237 private: 00238 std::string _filename; 00239 static const std::string _id; 00240 }; 00241 00242 class SetCutSceneCommand : public Command 00243 { 00244 public: 00245 SetCutSceneCommand(bool cutScene); 00246 SetCutSceneCommand(List *command); 00247 00248 void execute(); 00249 std::string getString(); 00250 static std::string id() {return _id;} 00251 private: 00252 bool _cutScene; 00253 static const std::string _id; 00254 }; 00255 00256 class AimCommand: public Command 00257 { 00258 public: 00259 AimCommand(Person *person, yDirection yDir); 00260 AimCommand(Person *person, Object *target = NULL); 00261 AimCommand(List *command); 00262 00263 void execute(); 00264 std::string getString(); 00265 static std::string id() {return _id;} 00266 private: 00267 Person* _person; 00268 yDirection _yDir; 00269 xDirection _xDir; 00270 00271 Object* _target; 00272 00273 static const std::string _id; 00274 }; 00275 00276 class AddHealthCommand: public Command 00277 { 00278 public: 00279 AddHealthCommand(Person *person, int dHealth); 00280 AddHealthCommand(List *command); 00281 00282 void execute(); 00283 std::string getString(); 00284 static std::string id() {return _id;} 00285 private: 00286 Person* _person; 00287 int _dHealth; 00288 00289 static const std::string _id; 00290 }; 00291 00292 class Door; 00293 class SetDoorLockCommand: public Command 00294 { 00295 public: 00296 SetDoorLockCommand(Door *door, bool locked); 00297 SetDoorLockCommand(List *command); 00298 00299 void execute(); 00300 std::string getString(); 00301 static std::string id() {return _id;} 00302 private: 00303 Door* _door; 00304 bool _locked; 00305 00306 static const std::string _id; 00307 }; 00308 00309 class AddScoreCommand: public Command 00310 { 00311 public: 00312 AddScoreCommand(int score); 00313 AddScoreCommand(List *command); 00314 00315 void execute(); 00316 std::string getString(); 00317 static std::string id() {return _id;} 00318 private: 00319 int _score; 00320 00321 static const std::string _id; 00322 }; 00323 00324 class EndLevelCommand: public Command 00325 { 00326 public: 00327 EndLevelCommand(); 00328 EndLevelCommand(List * list); 00329 00330 void execute(); 00331 std::string getString(); 00332 static std::string id() {return _id;} 00333 private: 00334 00335 static const std::string _id; 00336 00337 }; 00338 00339 class StopPersonCommand: public Command 00340 { 00341 public: 00342 StopPersonCommand(Person *person); 00343 StopPersonCommand(List * list); 00344 00345 void execute(); 00346 std::string getString(); 00347 static std::string id() {return _id;} 00348 private: 00349 Person *_person; 00350 00351 static const std::string _id; 00352 }; 00353 00354 #endif