Changeset 6387 in orxonox.OLD for branches/network/src/story_entities/campaign.cc
- Timestamp:
- Jan 2, 2006, 11:00:14 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/campaign.cc
r6386 r6387 38 38 assert( root != NULL); 39 39 40 this->campaignData = new CampaignData( );40 this->campaignData = new CampaignData(root); 41 41 this->loadParams(root); 42 42 43 } 43 44 … … 47 48 */ 48 49 Campaign::~Campaign () 49 {} 50 { 51 if( this->campaignData) 52 delete this->campaignData; 53 } 50 54 51 55 … … 58 62 static_cast<StoryEntity*>(this)->loadParams(root); 59 63 60 LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams)61 .describe("A List of Worlds to be loaded in this Campaign");62 63 64 PRINTF(4)("Loaded Campaign specific stuff\n"); 64 } 65 66 67 /** 68 * loads a WorldList 69 * @param root: the XML-element to load from 70 */ 71 void Campaign::loadWorldListParams(const TiXmlElement* root) 72 { 73 if( root == NULL) 74 return; 75 76 LOAD_PARAM_START_CYCLE(root, element); 77 { 78 StoryEntity* created = (StoryEntity*) Factory::fabricate(element); 79 if( created != NULL) 80 this->campaignData->addStoryEntity(created); 81 } 82 LOAD_PARAM_END_CYCLE(element); 83 84 } 85 86 87 /** 88 * initializes the class 89 */ 90 ErrorMessage Campaign::init() 91 { 92 this->isInit = true; 65 93 66 } 94 67 … … 98 71 * @param storyID the id of the StoryEntity 99 72 */ 100 ErrorMessageCampaign::start()73 bool Campaign::start() 101 74 { 102 75 PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID()); 103 76 77 this->isRunning = true; 78 this->run(); 79 80 PRINTF(2)("There is no StoryEnity left to play, quitting\n"); 81 } 82 83 84 /** 85 * pauses the campaign 86 */ 87 bool Campaign::pause() 88 { 89 this->isPaused = true; 90 } 91 92 93 /** 94 * resumes the campaign after a pause 95 */ 96 bool Campaign::resume() 97 { 98 PRINTF(4)("Resuming the current Campaign\n"); 99 this->isPaused = false; 100 } 101 102 103 /** 104 * stops the campaign 105 */ 106 bool Campaign::stop() 107 { 108 PRINTF(4)("Stopping the current Campaign\n"); 109 this->isRunning = false; 110 if( this->currentEntity != NULL) 111 { 112 this->currentEntity->stop(); 113 } 114 } 115 116 117 /** 118 * runs the campaign 119 */ 120 void Campaign::run() 121 { 104 122 ErrorMessage errorCode; 105 123 int storyID = WORLD_ID_0; … … 116 134 this->currentEntity->unloadData(); 117 135 } 118 119 PRINTF(2)("There is no StoryEnity left to play, quitting\n");120 }121 122 123 /**124 * pauses the campaign125 */126 ErrorMessage Campaign::pause()127 {128 if( this->currentEntity != NULL)129 this->isPaused = true;130 }131 132 133 /**134 * resumes the campaign after a pause135 */136 ErrorMessage Campaign::resume()137 {138 if( this->currentEntity != NULL)139 this->isPaused = false;140 }141 142 143 /**144 * stops the campaign145 */146 ErrorMessage Campaign::stop()147 {148 this->isRunning = false;149 if( this->currentEntity != NULL)150 {151 this->currentEntity->stop();152 }153 136 } 154 137 … … 159 142 void Campaign::switchToNextLevel() 160 143 { 161 PRINTF(4)(" Campaign:nextLevel()\n");144 PRINTF(4)("Switching to the next StoryEntity\n"); 162 145 this->currentEntity->stop(); 163 146 } … … 165 148 166 149 167 /* CampaignData */ 150 /* ========================================================================================================== 151 CampaignData 152 ========================================================================================================== 153 */ 168 154 169 155 /** 170 156 * constructor for CampaignData 171 157 */ 172 CampaignData::CampaignData( )158 CampaignData::CampaignData(const TiXmlElement* root) 173 159 { 174 160 this->setClassID(CL_CAMPAIGN_DATA, "CampaignData"); 175 161 this->currentEntity = NULL; 162 163 this->loadParams(root); 176 164 } 177 165 … … 180 168 * destructor for CampaignData 181 169 */ 182 CampaignData::~ CampaignData() 183 {} 170 CampaignData::~CampaignData() 171 { 172 PRINTF(0)("Deleting CampaignData\n"); 173 while( !this->storyEntities.empty()) 174 { 175 StoryEntity* bo = this->storyEntities.front(); 176 PRINTF(0)("CampaignData is been deleted: nr %i\n", bo->getStoryID()); 177 delete bo; 178 } 179 } 180 181 182 183 /** 184 * loads the Parameters of a Campaign 185 * @param root: The XML-element to load from 186 */ 187 void CampaignData::loadParams(const TiXmlElement* root) 188 { 189 LoadParamXML(root, "WorldList", this, CampaignData, loadParamsWorldList) 190 .describe("A List of Worlds to be loaded in this Campaign"); 191 192 } 193 194 195 /** 196 * loads a WorldList 197 * @param root: the XML-element to load from 198 */ 199 void CampaignData::loadParamsWorldList(const TiXmlElement* root) 200 { 201 if( root == NULL) 202 return; 203 204 LOAD_PARAM_START_CYCLE(root, element); 205 { 206 StoryEntity* created = (StoryEntity*) Factory::fabricate(element); 207 if( created != NULL) 208 this->addStoryEntity(created); 209 } 210 LOAD_PARAM_END_CYCLE(element); 211 } 184 212 185 213
Note: See TracChangeset
for help on using the changeset viewer.