Changeset 3238 in orxonox.OLD for orxonox/branches/nico/src/campaign.cc
- Timestamp:
- Dec 20, 2004, 2:42:54 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/nico/src/campaign.cc
r2816 r3238 34 34 35 35 36 Error Campaign::init()36 ErrorMessage Campaign::init() 37 37 { 38 38 this->isInit = true; … … 48 48 want to queue up in the campaign. 49 49 */ 50 void Campaign::addEntity(StoryEntity* se, Uint32storyID)50 void Campaign::addEntity(StoryEntity* se, int storyID) 51 51 { 52 52 se->setStoryID(storyID); … … 60 60 61 61 62 void Campaign::removeEntity( Uint32storyID)62 void Campaign::removeEntity(int storyID) 63 63 { 64 64 this->removeEntity(this->getStoryEntity(storyID)); … … 73 73 74 74 75 Error Campaign::start()75 ErrorMessage Campaign::start() 76 76 { 77 77 this->start(0); 78 78 } 79 79 80 Error Campaign::start(Uint32storyID = 0)80 ErrorMessage Campaign::start(int storyID = 0) 81 81 { 82 82 printf("World::start() - starting new StoryEntity Nr:%i\n", storyID); 83 Error errorCode;84 if( !this->isInit) return errorCode;85 if( storyID == WORLD_ID_GAMEEND) return errorCode;83 ErrorMessage errorCode; 84 if( !this->isInit) return errorCode; 85 if( storyID == WORLD_ID_GAMEEND) return errorCode; 86 86 this->running = true; 87 87 StoryEntity* se = this->getStoryEntity(storyID); 88 while(se != NULL && this->running) 88 this->currentEntity = se; 89 while( se != NULL && this->running) 89 90 { 90 se = this->getStoryEntity(storyID); 91 this->currentEntity = se; 92 93 se->displayEntityScreen(); 91 se->displayLoadScreen(); 94 92 se->load(); 95 93 se->init(); 96 se->release EntityScreen();94 se->releaseLoadScreen(); 97 95 se->start(); 96 se->destroy(); 97 98 delete se; 98 99 99 100 int nextWorldID = se->getNextStoryID(); 100 if(nextWorldID == WORLD_ID_GAMEEND) return errorCode;101 //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID); 101 102 se = this->getStoryEntity(nextWorldID); 102 if(se == NULL) 103 printf("Campaign::start() - ERROR: world it not found, oh oh..."); 103 this->currentEntity = se; 104 if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 105 { 106 printf("Campaign::start() - quitting campaing story loop\n"); 107 if(se != NULL) 108 delete se; 109 return errorCode; 110 } 111 104 112 } 105 113 } 106 114 107 Error Campaign::stop()115 ErrorMessage Campaign::stop() 108 116 { 109 117 this->running = false; … … 111 119 { 112 120 this->currentEntity->stop(); 113 delete this->currentEntity;114 this->currentEntity = NULL;121 //delete this->currentEntity; 122 //this->currentEntity = NULL; 115 123 } 116 124 } 117 125 118 Error Campaign::pause()126 ErrorMessage Campaign::pause() 119 127 { 120 128 if(this->currentEntity != NULL) … … 123 131 124 132 125 Error Campaign::resume()133 ErrorMessage Campaign::resume() 126 134 { 127 135 if(this->currentEntity != NULL) … … 130 138 131 139 140 void Campaign::destroy() 141 { 142 if(this->currentEntity != NULL) 143 { 144 this->currentEntity->destroy(); 145 delete this->currentEntity; 146 this->currentEntity = NULL; 147 } 148 } 149 150 /* 151 \brief this changes to the next level 152 */ 132 153 void Campaign::nextLevel() 133 154 { 134 printf("Campaign|nextLevel\n"); 135 int nextID = this->currentEntity->getNextStoryID(); 136 this->stop(); 137 this->start(nextID); 155 printf("Campaign:nextLevel()\n"); 156 //int nextID = this->currentEntity->getNextStoryID(); 157 //this->stop(); 158 //this->start(nextID); 159 this->currentEntity->stop(); 138 160 } 139 161 162 /* 163 \brief change to the previous level - not implemented 164 165 this propably useless 166 */ 140 167 void Campaign::previousLevel() 141 168 {} 142 169 143 170 144 StoryEntity* Campaign::getStoryEntity(Uint32 storyID) 171 /* 172 \brief lookup a entity with a given id 173 \param story id to be lookuped 174 \returns the entity found or NULL if search ended without match 175 */ 176 StoryEntity* Campaign::getStoryEntity(int storyID) 145 177 { 178 //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID); 179 if( storyID == WORLD_ID_GAMEEND) 180 return NULL; 146 181 ListTemplate<StoryEntity>* l; 147 StoryEntity* entity ;148 l = this->entities->get _next();182 StoryEntity* entity = NULL; 183 l = this->entities->getNext(); 149 184 while( l != NULL) 150 185 { 151 entity = l->get_object(); 152 l = l->get_next(); 153 if(entity->getStoryID() == storyID) 154 return entity; 186 entity = l->getObject(); 187 l = l->getNext(); 188 int id = entity->getStoryID(); 189 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 190 if(id == storyID) 191 { 192 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 193 return entity; 194 } 155 195 } 156 196 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.