Changeset 10587
- Timestamp:
- Sep 15, 2015, 4:43:03 PM (9 years ago)
- Location:
- code/branches/towerdefenseFabien/src/modules/towerdefense
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc
r10586 r10587 320 320 //if ships are at the end they get destroyed 321 321 322 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itBegin = enemies_.begin(); 323 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator it = itBegin; 324 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itEnd = enemies_.end(); 325 326 while(it != itEnd) 322 for (std::list<WeakPtr<TowerDefenseEnemy> >::iterator it = enemies_.begin(); it != enemies_.end(); ) 327 323 { 328 324 //destroys enemys at the end of the path and reduces the life by 1. No credits gifted … … 331 327 if(distance < 50) 332 328 { 333 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itTemp = it;334 ++ it;335 329 orxout() << "enemy deleted" << endl; 336 enemies_.erase(itTemp);337 (*itTemp)->destroy();330 (*it)->destroy(); 331 enemies_.erase(it++); 338 332 this->reduceLifes(1); 339 333 if (this->getLifes() == 0) -
code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.h
r10586 r10587 96 96 int lifes_; 97 97 Timer nextwaveTimer_; 98 std:: vector<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_;98 std::list<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_; 99 99 TowerDefenseField* fields_[16][16]; 100 100 std::vector<orxonox::WeakPtr<TowerDefenseField> > waypoints_;
Note: See TracChangeset
for help on using the changeset viewer.