Changeset 10589
- Timestamp:
- Sep 15, 2015, 4:48:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc
r10588 r10589 322 322 for (std::list<WeakPtr<TowerDefenseEnemy> >::iterator it = enemies_.begin(); it != enemies_.end(); ) 323 323 { 324 //destroys enemys at the end of the path and reduces the life by 1. No credits gifted 325 Vector3 ship = (*it)->getRVWorldPosition(); 326 float distance = ship.distance(endpoint_); 327 if(distance < 50) 328 { 329 orxout() << "enemy deleted" << endl; 330 (*it)->destroy(); 324 if (*it == NULL) 325 { 326 // the enemy was destroyed by a tower - remove it from the list 331 327 enemies_.erase(it++); 332 this->reduceLifes(1); 333 if (this->getLifes() == 0) 328 } 329 else 330 { 331 //destroys enemys at the end of the path and reduces the life by 1. No credits gifted 332 Vector3 ship = (*it)->getRVWorldPosition(); 333 float distance = ship.distance(endpoint_); 334 if(distance < 50) 334 335 { 335 this->end(); 336 orxout() << "enemy deleted" << endl; 337 (*it)->destroy(); 338 enemies_.erase(it++); 339 this->reduceLifes(1); 340 if (this->getLifes() == 0) 341 { 342 this->end(); 343 } 336 344 } 337 }338 else339 {340 ++ it;345 else 346 { 347 ++ it; 348 } 341 349 } 342 350 }
Note: See TracChangeset
for help on using the changeset viewer.