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 Player;
00011 class List;
00012
00013 class Command
00014 {
00015 public:
00016 virtual void execute()=0;
00017 virtual std::string getString()=0;
00018 static Command *loadCommand(List *command);
00019
00020 };
00021
00022 class JumpCommand : public Command
00023 {
00024 public:
00025 JumpCommand(Person* person, xDirection xDir);
00026 JumpCommand(List *command);
00027 void execute();
00028 std::string getString();
00029 static std::string id() {return _id;}
00030 private:
00031
00032 std::string _person;
00033 xDirection _xDir;
00034
00035 static const std::string _id;
00036 };
00037
00038 class JumpResetCommand : public Command
00039 {
00040 public:
00041 JumpResetCommand(Person* person);
00042 JumpResetCommand(List *command);
00043 void execute();
00044 std::string getString();
00045 static std::string id() {return _id;}
00046 private:
00047
00048 std::string _person;
00049
00050 static const std::string _id;
00051 };
00052
00053 class CrouchCommand : public Command
00054 {
00055 public:
00056 CrouchCommand(Person* person, bool crouch = true);
00057 CrouchCommand(List *command);
00058 void execute();
00059 std::string getString();
00060 static std::string id() {return _id;}
00061 private:
00062 Person* _person;
00063 bool _crouch;
00064
00065 static const std::string _id;
00066 };
00067
00068 class MoveCommand: public Command
00069 {
00070 public:
00071 MoveCommand(Person *person, xDirection xDir);
00072 MoveCommand(List *command);
00073
00074 void execute();
00075 std::string getString();
00076 static std::string id() {return _id;}
00077 private:
00078
00079 std::string _person;
00080 xDirection _xDir;
00081
00082 static const std::string _id;
00083 };
00084
00085 class TurnCommand: public Command
00086 {
00087 public:
00088 TurnCommand(Person *person, xDirection xDir);
00089 TurnCommand(List *command);
00090
00091 void execute();
00092 std::string getString();
00093 static std::string id() {return _id;}
00094 private:
00095 Person * _person;
00096 xDirection _xDir;
00097
00098 static const std::string _id;
00099 };
00100
00101 class PlayMusicCommand: public Command
00102 {
00103 public:
00104 PlayMusicCommand( std::string filename );
00105 PlayMusicCommand( List* command );
00106 void execute();
00107 std::string getString();
00108 static std::string id() { return _id; }
00109 private:
00110 Mix_Music* _music;
00111 std::string _filename;
00112
00113 static const std::string _id;
00114 };
00115
00116 class PlaySoundCommand: public Command
00117 {
00118 public:
00119 PlaySoundCommand( std::string filename );
00120 PlaySoundCommand( List* command );
00121 void execute();
00122 std::string getString();
00123 static std::string id() { return _id; }
00124 private:
00125 std::string _filename;
00126
00127 static const std::string _id;
00128 };
00129
00130 class FollowPlayerCommand: public Command
00131 {
00132 public:
00133 FollowPlayerCommand(Person *person);
00134 FollowPlayerCommand(List *command);
00135
00136 void execute();
00137 std::string getString();
00138 static std::string id() {return _id;}
00139 private:
00140 Person * _person;
00141
00142 static const std::string _id;
00143 };
00144
00145 class FollowPlayerInRangeCommand: public Command
00146 {
00147 public:
00148 FollowPlayerInRangeCommand(Person *person, int range);
00149 FollowPlayerInRangeCommand(List *command);
00150
00151 void execute();
00152 std::string getString();
00153 static std::string id() {return _id;}
00154 private:
00155 Person * _person;
00156 int _range;
00157
00158 static const std::string _id;
00159 };
00160
00161 class RunFromPlayerInRangeCommand: public Command
00162 {
00163 public:
00164 RunFromPlayerInRangeCommand(Person *person, int range);
00165 RunFromPlayerInRangeCommand(List *command);
00166
00167 void execute();
00168 std::string getString();
00169 static std::string id() {return _id;}
00170 private:
00171 Person * _person;
00172 int _range;
00173
00174 static const std::string _id;
00175 };
00176
00177 class ShootInRangeCommand: public Command
00178 {
00179 public:
00180 ShootInRangeCommand(Person *person, int range);
00181 ShootInRangeCommand(List *command);
00182
00183 void execute();
00184 std::string getString();
00185 static std::string id() { return _id; }
00186 private:
00187 Person * _person;
00188 int _shootRange;
00189 static const std::string _id;
00190 };
00191
00192 class ShootCommand: public Command
00193 {
00194 public:
00195 ShootCommand(Person *person);
00196 ShootCommand(List *command);
00197
00198 void execute();
00199 std::string getString();
00200 static std::string id() { return _id; }
00201 private:
00202
00203 std::string _person;
00204 static const std::string _id;
00205 };
00206
00207 class SecondaryShootCommand: public Command
00208 {
00209 public:
00210 SecondaryShootCommand(Player *player);
00211 SecondaryShootCommand(List *command);
00212
00213 void execute();
00214 std::string getString();
00215 static std::string id() { return _id; }
00216 private:
00217 Player * _player;
00218 static const std::string _id;
00219 };
00220
00221 class CutSceneTextCommand : public Command
00222 {
00223 public:
00224 CutSceneTextCommand(std::string text);
00225 CutSceneTextCommand(List *command);
00226
00227 void execute();
00228 std::string getString();
00229 static std::string id() { return _id; }
00230 private:
00231 std::string _text;
00232 static const std::string _id;
00233 };
00234
00235 class SetCameraCommand : public Command
00236 {
00237 public:
00238 SetCameraCommand(Object *object);
00239 SetCameraCommand(List *command);
00240
00241 void execute();
00242 std::string getString();
00243 static std::string id() {return _id;}
00244 private:
00245 Object *_object;
00246 static const std::string _id;
00247 };
00248
00249 class SetControlCommand : public Command
00250 {
00251 public:
00252 SetControlCommand(Object *object);
00253 SetControlCommand(List *command);
00254
00255 void execute();
00256 std::string getString();
00257 static std::string id() {return _id;}
00258 private:
00259 Object *_object;
00260 static const std::string _id;
00261 };
00262
00263 class PlayScriptCommand : public Command
00264 {
00265 public:
00266 PlayScriptCommand(std::string filename);
00267 PlayScriptCommand(List *command);
00268
00269 void execute();
00270 std::string getString();
00271 static std::string id() {return _id;}
00272 private:
00273 std::string _filename;
00274 static const std::string _id;
00275 };
00276
00277 class SetCutSceneCommand : public Command
00278 {
00279 public:
00280 SetCutSceneCommand(bool cutScene);
00281 SetCutSceneCommand(List *command);
00282
00283 void execute();
00284 std::string getString();
00285 static std::string id() {return _id;}
00286 private:
00287 bool _cutScene;
00288 static const std::string _id;
00289 };
00290
00291 class AimCommand: public Command
00292 {
00293 public:
00294 AimCommand(Person *person, yDirection yDir);
00295 AimCommand(Person *person, Object *target = NULL);
00296 AimCommand(List *command);
00297
00298 void execute();
00299 std::string getString();
00300 static std::string id() {return _id;}
00301 private:
00302
00303 std::string _person;
00304 yDirection _yDir;
00305 xDirection _xDir;
00306
00307 Object* _target;
00308
00309 static const std::string _id;
00310 };
00311
00312 class AddHealthCommand: public Command
00313 {
00314 public:
00315 AddHealthCommand(Person *person, int dHealth);
00316 AddHealthCommand(List *command);
00317
00318 void execute();
00319 std::string getString();
00320 static std::string id() {return _id;}
00321 private:
00322 Person* _person;
00323 int _dHealth;
00324
00325 static const std::string _id;
00326 };
00327
00328 class Door;
00329 class SetDoorLockCommand: public Command
00330 {
00331 public:
00332 SetDoorLockCommand(Door *door, bool locked);
00333 SetDoorLockCommand(List *command);
00334
00335 void execute();
00336 std::string getString();
00337 static std::string id() {return _id;}
00338 private:
00339 Door* _door;
00340 bool _locked;
00341
00342 static const std::string _id;
00343 };
00344
00345 class AddScoreCommand: public Command
00346 {
00347 public:
00348 AddScoreCommand(int score);
00349 AddScoreCommand(List *command);
00350
00351 void execute();
00352 std::string getString();
00353 static std::string id() {return _id;}
00354 private:
00355 int _score;
00356
00357 static const std::string _id;
00358 };
00359
00360 class AddWeaponCommand: public Command
00361 {
00362 public:
00363 AddWeaponCommand(Player *player, std::string filename);
00364 AddWeaponCommand(List *command);
00365
00366 void execute();
00367 std::string getString();
00368 static std::string id() {return _id;}
00369 private:
00370 std::string _filename;
00371 Player *_player;
00372
00373 static const std::string _id;
00374 };
00375
00376 class EndLevelCommand: public Command
00377 {
00378 public:
00379 EndLevelCommand();
00380 EndLevelCommand(List * list);
00381
00382 void execute();
00383 std::string getString();
00384 static std::string id() {return _id;}
00385 private:
00386
00387 static const std::string _id;
00388
00389 };
00390
00391 class StopPersonCommand: public Command
00392 {
00393 public:
00394 StopPersonCommand(Person *person);
00395 StopPersonCommand(List * list);
00396
00397 void execute();
00398 std::string getString();
00399 static std::string id() {return _id;}
00400 private:
00401
00402 std::string _person;
00403
00404 static const std::string _id;
00405 };
00406
00407 class SaveCommand: public Command
00408 {
00409 public:
00410 SaveCommand() {;}
00411 SaveCommand(List *list) {;}
00412
00413 void execute();
00414 std::string getString();
00415 static std::string id() {return _id;}
00416 private:
00417 static const std::string _id;
00418 };
00419
00420 class RestoreCommand: public Command
00421 {
00422 public:
00423 RestoreCommand() {;}
00424 RestoreCommand(List *list) {;}
00425
00426 void execute();
00427 std::string getString();
00428 static std::string id() {return _id;}
00429 private:
00430 static const std::string _id;
00431 };
00432
00433 class SetPositionCommand: public Command
00434 {
00435 public:
00436 SetPositionCommand(Object *object, int xPos, int yPos);
00437 SetPositionCommand(List *command);
00438
00439 void execute();
00440 std::string getString();
00441 static std::string id() {return _id;}
00442 private:
00443
00444 std::string _object;
00445 int _xPos;
00446 int _yPos;
00447
00448 static const std::string _id;
00449 };
00450
00451 class KillCommand: public Command
00452 {
00453 public:
00454 KillCommand(Person *person);
00455 KillCommand(List *command);
00456
00457 void execute();
00458 std::string getString();
00459 static std::string id() {return _id;}
00460 private:
00461 std::string _person;
00462
00463 static const std::string _id;
00464 };
00465
00466 class LiveCommand: public Command
00467 {
00468 public:
00469 LiveCommand(Person *person);
00470 LiveCommand(List *command);
00471
00472 void execute();
00473 std::string getString();
00474 static std::string id() {return _id;}
00475 private:
00476 std::string _person;
00477
00478 static const std::string _id;
00479 };
00480
00481 class CutScene;
00482
00483 class ActivateCutSceneCommand: public Command
00484 {
00485 public:
00486 ActivateCutSceneCommand(CutScene *cutScene);
00487 ActivateCutSceneCommand(List *command);
00488
00489 void execute();
00490 std::string getString();
00491 static std::string id() {return _id;}
00492 private:
00493 std::string _cutScene;
00494
00495 static const std::string _id;
00496 };
00497
00498 class Enemy;
00499 class ActivateEnemyCommand: public Command
00500 {
00501 public:
00502 ActivateEnemyCommand(Enemy *enemy);
00503 ActivateEnemyCommand(List *command);
00504
00505 void execute();
00506 std::string getString();
00507 static std::string id() {return _id;}
00508 private:
00509 std::string _enemy;
00510
00511 static const std::string _id;
00512 };
00513
00514 class InvincibleCommand: public Command
00515 {
00516 public:
00517 InvincibleCommand(Person *person, bool inv);
00518 InvincibleCommand(List *command);
00519
00520 void execute();
00521 std::string getString();
00522 static std::string id() {return _id;}
00523 private:
00524 std::string _person;
00525 bool _inv;
00526
00527 static const std::string _id;
00528 };
00529
00530 class FlushCommand: public Command
00531 {
00532 public:
00533 FlushCommand();
00534 FlushCommand(List *command);
00535
00536 void execute();
00537 std::string getString();
00538 static std::string id() {return _id;}
00539 private:
00540 static const std::string _id;
00541 };
00542
00543 #endif