Changeset 10151 for code/branches
- Timestamp:
- Dec 3, 2014, 5:06:11 PM (10 years ago)
- Location:
- code/branches/towerdefenseHS14/src/modules/towerdefense
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
r10144 r10151 299 299 path.push_back(coord1); 300 300 301 if(time>1 && TowerDefenseEnemyvector.size() < 30) 302 { 303 addTowerDefenseEnemy(path, rand() %3 +1 ); 304 time = time-1; 305 } 301 if(time>1 && TowerDefenseEnemyvector.size() < 30) 302 { 303 addTowerDefenseEnemy(path, rand() %3 +1 ); 304 time = time-1; 305 } 306 307 Vector3* endpoint = new Vector3(500, 700, 150); 308 309 for(int i =0; i < TowerDefenseEnemyvector.size(); ++i) 310 { 311 312 //orxout() << TowerDefenseEnemyvector.at(i) << endl; 313 //continue; 314 315 //ArtificialController* controller = (ArtificialController*)this->getController(); 316 if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive()) 317 { 318 orxout() << "Variable i: " << i << endl; 319 320 Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition(); 321 322 float distance = ship.distance(*endpoint); 323 324 //orxout() << "distance" << distance << endl; 325 if(distance <50){ 326 // orxout() << "ENEMY KILLED!!!!" << endl; 327 TowerDefenseEnemyvector.at(i)->destroy(); 328 } 329 } 330 else 331 { 332 //TowerDefenseEnemyvector.erase(TowerDefenseEnemyvector.begin() +i); 333 } 334 } 335 336 int count= 0; 337 for(int i =0; i < TowerDefenseEnemyvector.size(); ++i) 338 { 339 if(TowerDefenseEnemyvector.at(i)!= NULL) 340 { 341 ++count; 342 } 343 } 344 345 if(count== 0) 346 { 347 time2 +=dt; 348 if(time2 > 10) 349 { 350 TowerDefenseEnemyvector.clear(); 351 time=0; 352 time2=0; 353 } 354 } 355 306 356 307 357 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
r10142 r10151 54 54 virtual ~TowerDefense(); 55 55 56 std::vector< TowerDefenseEnemy*> TowerDefenseEnemyvector;56 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector; 57 57 bool towermatrix[16][16]; 58 58 void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); … … 89 89 TowerDefenseCenterpoint *center_; 90 90 float time; 91 float time2; 91 92 92 93 /* handles stats */ -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc
r10142 r10151 42 42 SUPER(TowerDefenseEnemy, tick, dt); 43 43 44 //ArtificialController* controller = (ArtificialController*)this->getController();45 Vector3 ship = this->getRVWorldPosition();46 Vector3* endpoint = new Vector3(500, 700, 150);47 48 float distance = ship.distance(*endpoint);49 50 //orxout() << "distance" << distance << endl;51 if(distance <50){52 // orxout() << "ENEMY KILLED!!!!" << endl;53 this->destroy(); }54 44 } 55 45
Note: See TracChangeset
for help on using the changeset viewer.