- Timestamp:
- Dec 11, 2018, 6:20:24 PM (6 years ago)
- Location:
- code/branches/Merge_HS18
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Merge_HS18
- Property svn:mergeinfo changed
/code/branches/TowerDefense_HS18 (added) merged: 12025,12038,12125-12126,12137,12153,12165
- Property svn:mergeinfo changed
-
code/branches/Merge_HS18/src/modules/towerdefense/TowerDefense.cc
r12180 r12182 76 76 #include "TowerDefenseCenterpoint.h" 77 77 #include "worldentities/SpawnPoint.h" 78 #include "controllers/WaypointController.h" 78 #include "worldentities/StaticEntity.h" 79 #include "TowerDefenseController.h" //muss ich noch in den richtigen Ordner verschieben 79 80 #include "graphics/Model.h" 80 81 #include "infos/PlayerInfo.h" … … 82 83 #include "core/CoreIncludes.h" 83 84 #include "Highscore.h" 85 #include "util/Output.h" 86 #include "TowerDefenseRangeViewer.h" 87 84 88 85 89 namespace orxonox … … 92 96 93 97 selecter = nullptr; 98 rangeViewer = nullptr; 94 99 this->player_ = nullptr; 95 100 this->setHUDTemplate("TowerDefenseHUD"); … … 124 129 selecter = new TowerDefenseSelecter(this->center_->getContext()); 125 130 } 131 if(rangeViewer == nullptr){ 132 rangeViewer = new TowerDefenseRangeViewer(this->center_->getContext()); 133 } 126 134 selecter->addTemplate(center_->getSelecterTemplate()); 135 rangeViewer->addTemplate("therangeviewer"); 136 rangeViewer->setPosition(-10000,0,-500); 127 137 center_->attach(selecter); 138 center_->attach(rangeViewer); 128 139 } 129 140 else // If no centerpoint was specified, an error is thrown and the level is exited. … … 136 147 137 148 createFields(); 149 138 150 TeamDeathmatch::start(); 139 151 … … 157 169 en1->addTemplate("enemytowerdefense1"); 158 170 en1->setScale(3); 159 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 171 en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.5*(en1->getHealth())); 172 en1->setShieldHealth(en1->getShieldHealth() + this->getWaveNumber()*1/3*0.5*(en1->getShieldHealth())); 160 173 break; 161 174 … … 163 176 en1->addTemplate("enemytowerdefense2"); 164 177 en1->setScale(2); 165 en1->setHealth(en1->getHealth() + this->getWaveNumber()* 4);178 en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.3*(en1->getHealth())); 166 179 break; 167 180 … … 169 182 en1->addTemplate("enemytowerdefense3"); 170 183 en1->setScale(1); 171 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 184 en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.2*(en1->getHealth())); 185 en1->setShieldHealth(en1->getShieldHealth() + this->getWaveNumber()*1/3*0.5*(en1->getShieldHealth())); 172 186 break; 173 187 } … … 175 189 en1->setTeam(2); 176 190 177 WaypointController* controller = (WaypointController*)(en1->getXMLController()); 178 179 if (controller != nullptr && waypoints_.size() > 1) 191 //Jedem Enemy wird ein eigener Controller uebergeben 192 TowerDefenseController* controller = new TowerDefenseController(this->center_->getContext()); 193 controller->setControllableEntity(en1); 194 en1->setController(controller); 195 196 if (waypoints_.size() > 1) 180 197 { 181 198 en1->setPosition(waypoints_.at(0)->getPosition() + offset_); … … 192 209 } 193 210 194 enemies_.push_back(en1); 211 auto pair = std::make_pair(orxonox::WeakPtr<TowerDefenseEnemy>(en1), controller); 212 enemies_.push_back(pair); 195 213 } 196 214 … … 280 298 timeSinceLastSpawn_ += dt; 281 299 300 if(selecter != nullptr && getField(selecter->selectedPos_)->canUpgrade() == true ){ 301 rangeViewer->setPosition(((selecter->selectedPos_->GetX())-8)*100, ((selecter->selectedPos_->GetY())-8)*100, 200); 302 } else { 303 rangeViewer->setPosition(-10000,0,-500); 304 } 305 282 306 //build/upgrade tower at selecter position 283 307 if (selecter != nullptr && selecter->buildTower_ == true) … … 295 319 } 296 320 } 321 297 322 298 for (std::list<WeakPtr<TowerDefenseEnemy>>::iterator it = enemies_.begin(); it != enemies_.end(); ) 299 { 300 if (*it == nullptr) 301 { 302 // the enemy was destroyed by a tower - remove it from the list 303 enemies_.erase(it++); 304 addCredit(1); 323 for (EnemyList::iterator it = enemies_.begin(); it != enemies_.end(); ) 324 { 325 WeakPtr<TowerDefenseEnemy> enemy = it->first; 326 TowerDefenseController* ctrl = it->second; 327 328 if (enemy == nullptr) 329 { 330 331 // the enemy was destroyed by a tower - remove it from the list AND destroy the corresponding controler 332 ctrl->destroy(); 333 it = enemies_.erase(it); 334 335 int currentType = this->getWaveNumber() % 3 + 1; 336 switch (currentType){ //Entscheidet, wie viele Credits vergeben werden sollen 337 case 1: //currently boss wave 338 addCredit(100); 339 if (this->getLifes() <= 90) 340 { 341 this->setLifes(this->getLifes() + 10); 342 } 343 break; 344 345 case 2: //currently mass wave 346 addCredit(5); 347 break; 348 349 case 3: //currently moderate wave 350 addCredit(10); 351 break; 352 } 305 353 } 306 354 else 307 355 { 308 356 //if ships are at the end they get destroyed 309 Vector3 ship = (*it)->getRVWorldPosition();357 Vector3 ship = enemy->getRVWorldPosition(); 310 358 float distance = ship.distance(endpoint_); 311 359 if(distance < 40) 312 360 { 313 (*it)->destroy(); 314 enemies_.erase(it++); 361 enemy->getController()->destroy(); 362 enemy->destroy(); 363 364 it = enemies_.erase(it); 315 365 this->reduceLifes(1); 316 366 if (this->getLifes() == 0) … … 332 382 timeSinceLastSpawn_ -= 1.0; 333 383 -- waveSize_; 334 addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1); 384 addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1); //Gegnertyp rotiert durch die 3 moeglichen, er beginnt bei Typ 2!!! 335 385 } 336 386 else if (timeUntilNextWave_ <= 0.0 && waveSize_ <= 0) 337 387 { 388 int currentType = this->getWaveNumber() % 3 + 1; 338 389 //New wave 339 390 ++ waveNumber_; … … 341 392 342 393 timeUntilNextWave_ = waveNumber_+20.0f; 343 waveSize_ = waveNumber_+5; 394 // Entscheidung, wie gross die einzelnen waves sein sollen. 395 switch (currentType){ 396 case 1: //currently boss wave 397 waveSize_ = waveNumber_+10; 398 break; 399 400 case 2: //currently mass wave 401 waveSize_ = (waveNumber_+10)/2; 402 break; 403 404 case 3: //currently moderate wave 405 waveSize_ = 1; 406 break; 407 } 344 408 } 345 409 … … 353 417 std::string fields = center_->getFields(); 354 418 int pos = 0; 355 for (int j = 15; j >= 0; --j) 356 { 357 for (int i = 0; i < 16; ++i)419 for (int j = 15; j >= 0; --j) //Vertical number of rows 420 { 421 for (int i = 0; i <= 15; ++i) //Horizontal number of rows 358 422 { 359 423 coord.Set(i,j); … … 416 480 } 417 481 482 //Falls kein anliegender Weg gefunden wurde. 418 483 delete nextCoord; 419 484 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.