- Timestamp:
- May 7, 2015, 4:35:21 PM (10 years ago)
- Location:
- code/branches/towerdefenseFS15
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseFS15/data/levels/towerDefense.oxw
r10406 r10430 37 37 <TowerDefenseSelecter team=0 camerapositiontemplate=selectercameras> 38 38 <attached> 39 <Model p osition="0,0,0" mesh="cube.mesh" scale=45/>39 <Model pitch=90 position="0,0,-30" mesh="TD_Selection.mesh" scale=30 /> 40 40 </attached> 41 41 </TowerDefenseSelecter> -
code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc
r10368 r10430 196 196 if(this->isLookingAtTargetNew(Degree(5).valueRadians())) 197 197 { 198 orxout() << target_->getIdentifier()->getName() << " / " << target_->getWorldPosition() << " / " << target_->getHealth() << " / " << target_->getTeam() << " / " << this->getTeam() << " / " << turret->getTeam() << endl; 199 if (target_->getController()) 200 orxout() << target_->getController()->getIdentifier()->getName() << " / " << target_->getController()->getTeam() << endl; 198 201 199 this->getControllableEntity()->fire(0); 202 200 } -
code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
r10408 r10430 86 86 /* Part of a temporary hack to allow the player to add towers */ 87 87 #include "core/command/ConsoleCommand.h" 88 #include <cmath> 88 89 89 90 … … 92 93 static const std::string __CC_addTower_name = "addTower"; 93 94 static const std::string __CC_upgradeTower_name = "upgradeTower"; 95 static const int upgradeCost = 20; 96 static const int towerCost = 20; 97 94 98 95 99 SetConsoleCommand("TowerDefense", __CC_addTower_name, &TowerDefense::addTower ).addShortcut().defaultValues(1); … … 119 123 this->lifes_ = 0; 120 124 this->timeSetTower_ = 0; 125 spaceships =15; 126 eggs=3; 127 ufos=7; 128 randomships=5; 121 129 122 130 … … 199 207 200 208 //set initial credits, lifes and WaveNumber 201 this->setCredit(100 0);209 this->setCredit(100); 202 210 this->setLifes(100); 203 211 this->setWaveNumber(0); … … 223 231 en1->addTemplate("enemytowerdefense1"); 224 232 en1->setScale(3); 233 en1->lookAt(Vector3(0,0,100000)); 225 234 en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4); 226 235 break; … … 229 238 en1->addTemplate("enemytowerdefense2"); 230 239 en1->setScale(2); 240 en1->lookAt(Vector3(0,0,100000)); 241 en1->roll(Degree(120)); 231 242 en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4); 232 243 // en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2)) … … 236 247 en1->addTemplate("enemytowerdefense3"); 237 248 en1->setScale(1); 249 en1->lookAt(Vector3(0,0,100000)); 250 en1->roll(Degree(120)); 238 251 en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4); 239 252 break; … … 291 304 y = coord->GetY(); 292 305 293 const int upgradeCost = 20;294 306 295 307 if (!this->hasEnoughCreditForTower(upgradeCost)) … … 311 323 { 312 324 (towerTurretMatrix [x][y])->upgradeTower(); 325 switch(towerTurretMatrix[x][y]->upgrade) 326 { 327 case 1 : 328 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 329 break; 330 331 case 2 : 332 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 333 break; 334 case 3 : 335 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 336 break; 337 case 4 : 338 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 339 break; 340 341 } 342 313 343 this->buyTower(upgradeCost); 314 344 } … … 325 355 y = coord->GetY(); 326 356 327 const int towerCost = 20;328 357 329 358 if (!this->hasEnoughCreditForTower(towerCost)) … … 359 388 //Create Model 360 389 Model* newTowerModel = new Model(this->center_->getContext()); 361 newTowerModel->setMeshSource("Tower.mesh"); 362 newTowerModel->setScale(45); 363 newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 50); 390 newTowerModel->setMeshSource("TD_T1.mesh"); 391 newTowerModel->setScale(30); 392 newTowerModel->pitch(Degree(90)); 393 newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80); 364 394 365 395 //Creates tower … … 387 417 388 418 419 void TowerDefense::nextwave() 420 { 421 TowerDefenseEnemyvector.clear(); 422 waves_++; 423 time=0; 424 float randomnumber1 = rand()*100*5; 425 float randomnumber2 = rand()*100*1; 426 float randomnumber3 = rand()*100*1.5; 427 428 float totalnumber = (randomnumber1 + randomnumber2 + randomnumber3)*1.3; 429 430 int newspaceships = (int)(maxspaceships* randomnumber1 / totalnumber); 431 int neweggs = (int)(maxspaceships*randomnumber2 / totalnumber); 432 int newufos = (int)(maxspaceships*randomnumber3 / totalnumber); 433 int newrandomships = maxspaceships -spaceships - eggs - ufos; 434 int spaceships =newspaceships; 435 int eggs=neweggs; 436 int ufos=newufos; 437 int randomships=newrandomships; 438 439 } 440 389 441 void TowerDefense::tick(float dt) 390 442 { … … 392 444 time +=dt; 393 445 timeSetTower_ +=dt; 394 orxout() << dt << "time" << endl;395 446 396 447 //Check if tower has to be set (because TowerDefenseSelecter asks for it) … … 401 452 { 402 453 403 int x coord= selecter->selectedPos_->GetX();404 int y coord= selecter->selectedPos_->GetY();454 int x = selecter->selectedPos_->GetX(); 455 int y = selecter->selectedPos_->GetY(); 405 456 Model* dummyModel2 = new Model(this->center_->getContext()); 406 457 407 458 408 459 409 if(towerModelMatrix[x coord][ycoord] == NULL)460 if(towerModelMatrix[x][y] == NULL) 410 461 { 411 addTower(x coord,ycoord);462 addTower(x,y); 412 463 } 413 464 else 414 465 { 415 if(!((towerModelMatrix [x coord][ycoord])->getMeshSource() == dummyModel2->getMeshSource()))466 if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())) 416 467 { 417 towerTurretMatrix[xcoord][ycoord]->upgradeTower(); 468 towerTurretMatrix[x][y]->upgradeTower(); 469 if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax) 470 { 471 this->buyTower((int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade)))); 472 switch(towerTurretMatrix[x][y]->upgrade) 473 { 474 case 1 : 475 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 476 break; 477 478 case 2 : 479 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 480 break; 481 case 3 : 482 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 483 break; 484 case 4 : 485 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 486 break; 487 488 } 489 490 491 } 418 492 } 419 493 } … … 429 503 int enemytype = this->getWaveNumber() % 3 +1; 430 504 431 float randomnumber1 = rand()*100*5;432 float randomnumber2 = rand()*100*1;433 float randomnumber3 = rand()*100*1.5;434 435 float totalnumber = randomnumber1 + randomnumber2 + randomnumber3;436 int maxspaceships = 30;437 int spaceships = (int)(maxspaceships* randomnumber1 / totalnumber);438 int eggs = (int)(maxspaceships*randomnumber2 / totalnumber);439 int ufos = (int)(maxspaceships*randomnumber3 / totalnumber);440 505 441 506 if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships) 442 507 { 443 //adds different types of enemys depending on the WaveNumber 444 addTowerDefenseEnemy(path, enemytype); 508 orxout() << "enemyerstellen" << endl; 509 //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult 510 if(spaceships>0) 511 { 512 addTowerDefenseEnemy(path, 1); 513 spaceships--; 514 515 }else if(ufos>0) 516 { 517 addTowerDefenseEnemy(path, 3); 518 ufos--; 519 }else if(eggs>0) 520 { 521 addTowerDefenseEnemy(path, 2); 522 eggs--; 523 }else if(randomships>0) 524 { 525 addTowerDefenseEnemy(path, rand() % 3 +1); 526 randomships--; 527 528 } 529 445 530 } 446 531 … … 497 582 } 498 583 584 499 585 // Function to test if we can add waypoints using code only. Doesn't work yet 500 586 -
code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h
r10408 r10430 73 73 void buyTower(int cost){ credit_ -= cost;} 74 74 void addCredit(int credit) { credit_+=credit; } 75 void nextwave() { TowerDefenseEnemyvector.clear(); waves_++; time=0;}75 void nextwave(); 76 76 int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; } 77 77 TowerDefenseSelecter* selecter; 78 int spaceships; 79 int eggs; 80 int ufos; 81 int randomships; 82 int maxspaceships = 30; 83 78 84 79 85 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); -
code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseTower.cc
r10408 r10430 30 30 this->addTemplate("towerdefensetower"); 31 31 32 upgradeMax = 5; 32 33 33 34 … … 61 62 bool TowerDefenseTower::upgradeTower() 62 63 { 63 if(upgrade < 3)64 if(upgrade < upgradeMax) 64 65 { 65 66 upgrade++; -
code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseTower.h
r10335 r10430 49 49 void setGame(TowerDefense* Towerdefense) 50 50 { assert(Towerdefense); game_ = Towerdefense; } 51 int upgrade; 52 int upgradeMax; 51 53 private: 52 54 TowerDefense* game_; 53 int upgrade; 55 54 56 }; 55 57 }
Note: See TracChangeset
for help on using the changeset viewer.