00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "movement.h"
00020 #include "movementmanager.h"
00021
00022 #include "graphicmanager.h"
00023
00024
00025 MovementManager::MovementManager(
00026 const GraphicManager* gm,
00027 const Map* map):
00028 pcGraphicMgr( gm ),
00029 pcMap( map )
00030 {
00031 OPENCITY_DEBUG("ctor");
00032
00033
00034 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00035 tabmvt[ i ] = NULL;
00036 }
00037 }
00038
00039
00040
00041 MovementManager::~MovementManager()
00042 {
00043 OPENCITY_DEBUG("dtor");
00044
00045 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00046 delete tabmvt[ i ];
00047 }
00048 }
00049
00050
00051
00052 const int
00053 MovementManager::Add(
00054 Movement* const pNew )
00055 {
00056 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00057 if (tabmvt[ i ] == NULL) {
00058 tabmvt[ i ] = pNew;
00059 return i;
00060 }
00061 }
00062
00063 return -1;
00064 }
00065
00066
00067
00068 void
00069 MovementManager::Remove(
00070 const int ciIndex )
00071 {
00072
00073
00074 if ((ciIndex > -1) && (ciIndex < OC_MOVEMENT_MAX )) {
00075 if (tabmvt[ ciIndex ] != NULL) {
00076 delete tabmvt[ ciIndex ];
00077 tabmvt[ ciIndex ] = NULL;
00078 }
00079 return;
00080 }
00081
00082
00083 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00084 if (tabmvt[ i ] != NULL) {
00085 delete tabmvt[ i ];
00086 tabmvt[ i ] = NULL;
00087 }
00088 }
00089 }
00090
00091
00092
00093 void
00094 MovementManager::Move(
00095 const int ciIndex )
00096 {
00097
00098
00099 if ((ciIndex > -1) && (ciIndex < OC_MOVEMENT_MAX )) {
00100 if (tabmvt[ ciIndex ] != NULL)
00101 if (tabmvt[ ciIndex ]->Move() == false) {
00102 delete tabmvt[ ciIndex ];
00103 tabmvt[ ciIndex ] = NULL;
00104 }
00105 return;
00106 }
00107
00108
00109 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00110 if (tabmvt[ i ] != NULL)
00111 if (tabmvt[ i ]->Move() == false) {
00112 delete tabmvt[ i ];
00113 tabmvt[ i ] = NULL;
00114 }
00115 }
00116 }
00117
00118
00119
00120 void
00121 MovementManager::Display(
00122 const int ciIndex )
00123 {
00124
00125
00126 if ((ciIndex > -1) && (ciIndex < OC_MOVEMENT_MAX )) {
00127 if (tabmvt[ ciIndex ] != NULL)
00128 this->pcGraphicMgr->Display(
00129 tabmvt[ ciIndex ]->_fCurrentW,
00130 tabmvt[ ciIndex ]->_fCurrentL,
00131 tabmvt[ ciIndex ]->_fCurrentH,
00132 tabmvt[ ciIndex ] );
00133 return;
00134 }
00135
00136
00137 for (uint i = 0; i < OC_MOVEMENT_MAX; i++) {
00138 if (tabmvt[ i ] != NULL)
00139 this->pcGraphicMgr->Display(
00140 tabmvt[ i ]->_fCurrentW,
00141 tabmvt[ i ]->_fCurrentL,
00142 tabmvt[ i ]->_fCurrentH,
00143 tabmvt[ i ] );
00144 }
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178