- Timestamp:
- Nov 28, 2018, 11:50:56 AM (6 years ago)
- Location:
- code/branches/TowerDefense_HS18/src/modules/towerdefense
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/TowerDefense_HS18/src/modules/towerdefense/CMakeLists.txt
r10629 r12125 10 10 TowerDefenseField.cc 11 11 TDCoordinate.cc 12 TowerDefenseController.cc 12 13 ) 13 14 -
code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefense.cc
r11716 r12125 76 76 #include "TowerDefenseCenterpoint.h" 77 77 #include "worldentities/SpawnPoint.h" 78 #include " controllers/WaypointController.h"78 #include "TowerDefenseController.h" //muss ich noch in den richtigen Ordner verschieben 79 79 #include "graphics/Model.h" 80 80 #include "infos/PlayerInfo.h" … … 175 175 en1->setTeam(2); 176 176 177 WaypointController* controller = (WaypointController*)(en1->getXMLController()); 178 179 if (controller != nullptr && waypoints_.size() > 1) 177 //Jedem Enemy wird ein eigener Controller uebergeben 178 TowerDefenseController* controller = new TowerDefenseController(this->center_->getContext()); 179 controller->setControllableEntity(en1); 180 en1->setController(controller); 181 182 if (waypoints_.size() > 1) 180 183 { 181 184 en1->setPosition(waypoints_.at(0)->getPosition() + offset_); … … 192 195 } 193 196 194 enemies_.push_back(en1); 197 auto pair = std::make_pair(orxonox::WeakPtr<TowerDefenseEnemy>(en1), controller); 198 enemies_.push_back(pair); 195 199 } 196 200 … … 291 295 } 292 296 } 297 293 298 294 for (std::list<WeakPtr<TowerDefenseEnemy>>::iterator it = enemies_.begin(); it != enemies_.end(); ) 295 { 296 if (*it == nullptr) 297 { 298 // the enemy was destroyed by a tower - remove it from the list 299 enemies_.erase(it++); 299 for (EnemyList::iterator it = enemies_.begin(); it != enemies_.end(); ) 300 { 301 WeakPtr<TowerDefenseEnemy> enemy = it->first; 302 TowerDefenseController* ctrl = it->second; 303 304 if (enemy == nullptr) 305 { 306 307 // the enemy was destroyed by a tower - remove it from the list AND destroy the corresponding controler 308 ctrl->destroy(); 309 it = enemies_.erase(it); 300 310 addCredit(1); 301 311 } … … 303 313 { 304 314 //if ships are at the end they get destroyed 305 Vector3 ship = (*it)->getRVWorldPosition();315 Vector3 ship = enemy->getRVWorldPosition(); 306 316 float distance = ship.distance(endpoint_); 307 317 if(distance < 40) 308 318 { 309 (*it)->destroy(); 310 enemies_.erase(it++); 319 enemy->getController()->destroy(); 320 enemy->destroy(); 321 322 it = enemies_.erase(it); 311 323 this->reduceLifes(1); 312 324 if (this->getLifes() == 0) … … 412 424 } 413 425 426 //Falls kein anliegender Weg gefunden wurde. 414 427 delete nextCoord; 415 428 return nullptr; -
code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefense.h
r11099 r12125 32 32 #include "TDCoordinate.h" 33 33 #include "TowerDefenseSelecter.h" 34 #include "TowerDefenseController.h" 34 35 #include "towerdefense/TowerDefensePrereqs.h" 35 36 #include "gametypes/TeamDeathmatch.h" … … 40 41 namespace orxonox 41 42 { 43 using EnemyList = std::list<std::pair<orxonox::WeakPtr<TowerDefenseEnemy>, TowerDefenseController*>>; 44 42 45 /** 43 46 @brief … … 86 89 int waveNumber_; 87 90 int lifes_; 88 std::list<orxonox::WeakPtr<TowerDefenseEnemy>>enemies_;91 EnemyList enemies_; 89 92 TowerDefenseField* fields_[16][16]; 90 93 std::vector<orxonox::WeakPtr<TowerDefenseField>> waypoints_; -
code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefenseEnemy.cc
r11099 r12125 29 29 TowerDefenseEnemy::~TowerDefenseEnemy() 30 30 { 31 32 31 } 33 32
Note: See TracChangeset
for help on using the changeset viewer.