Changeset 10452 for code/branches/presentationFS15
- Timestamp:
- May 21, 2015, 4:26:39 PM (10 years ago)
- Location:
- code/branches/presentationFS15
- Files:
-
- 5 deleted
- 18 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationFS15
- Property svn:mergeinfo changed
/code/branches/core7 (added) merged: 10350 /code/branches/towerdefenseFS15 (added) merged: 10283,10319,10325,10335,10340,10351,10368,10378,10388,10394,10397,10406,10408,10430,10451
- Property svn:mergeinfo changed
-
code/branches/presentationFS15/data/levels/templates/enemytowerdefense.oxt
r10262 r10452 167 167 maxhealth = 200 168 168 initialhealth = 100 169 169 170 170 shieldhealth = 30 171 171 initialshieldhealth = 30 -
code/branches/presentationFS15/data/levels/towerDefense.oxw
r10258 r10452 20 20 include("templates/spaceshipAssff.oxt") 21 21 include("templates/spaceshipPirate.oxt") 22 include("templates/tower .oxt")22 include("templates/towerdefensetower.oxt") 23 23 include("templates/enemytowerdefense.oxt") 24 24 include("templates/standardTurret.oxt") 25 25 ?> 26 26 27 <!-- Specify the position of the camera --> 28 <Template name= centerpointmarkcameradefaults=0>29 < Pawn team=1>27 28 <Template name=selectercameras defaults=0> 29 <TowerDefenseSelecter> 30 30 <camerapositions> 31 <CameraPosition position="0,0,1 500"/>31 <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true /> 32 32 </camerapositions> 33 </ Pawn>33 </TowerDefenseSelecter> 34 34 </Template> 35 35 36 <!-- Loads a mesh to mark the center--> 37 <Template name=centerpointmark> 38 <Pawn team=1 camerapositiontemplate=centerpointmarkcamera> 36 <Template name=selectertemplate> 37 <TowerDefenseSelecter team=0 camerapositiontemplate=selectercameras> 39 38 <attached> 40 <Model p osition="0,0,0" mesh="cylinder.mesh" scale3D="1,1,1" /> <!-- the camera is attached to this -->39 <Model pitch=90 position="0,0,-30" mesh="TD_Selection.mesh" scale=30 /> 41 40 </attached> 42 </ Pawn>41 </TowerDefenseSelecter> 43 42 </Template> 44 45 46 <!-- Template for a tower EDIT: new towertemplate is included with "templates/tower" -->47 <!--Template name=towertemplate>48 <Tower>49 <attached>50 <Model position="0,0,0" scale=0.25 mesh="Tower_ME.mesh" />51 </attached>52 </Tower>53 </Template-->54 55 43 56 44 … … 72 60 73 61 <!-- Spawns the camera, attached to a crate --> 74 <SpawnPoint team=1 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark /> 75 <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /--> 76 77 <!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 78 <!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /--> 79 80 81 82 83 <!--invisible entity to attach towers to, since playfield is static and towers are dynamic--> 84 <StaticEntity team =1 position=0,0,0> 85 86 <attached> 87 <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 /> 88 <!-- Base --> 89 <Model position="500,700,100" mesh="sphere.mesh" scale=80 /> 90 <!--Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /--> <!-- Only temporary needed to help align the collisionshape --> 91 <!-- This was used to mark the playfield, let's let it be here for now --> 92 <!--Model position="-8,8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 93 <!--Model position="-8,-8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 94 <!--Model position="8,-8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 95 <!--Model position="8,8,0" mesh="crate.mesh" scale3D="0.3,0.3,0.3" /--> 96 </attached> 97 <collisionShapes> <!-- The collisionshape forbids other worldentities that have a collisionShape to fly through it. 98 99 TODO: Find correct size for the collisionshape; since a collisionShape is invisible 100 I added the crate wich currently has the same dimensions as the collisionshape. 101 You have to adjust the crate's scale3D as well as the collisionshape's halfExtens to 102 find the proper shape. --> 103 <BoxCollisionShape position="0,0,0" halfExtents="400,400,100" /> 104 </collisionShapes> 105 </StaticEntity> 106 107 108 62 <SpawnPoint team=0 position="0,0,0"/> 109 63 110 64 <!-- PlayField --> 111 65 <TowerDefenseCenterpoint 112 66 name=towerdefensecenter 67 68 selecterTemplate=selectertemplate 69 113 70 width=16 114 71 height=16 115 72 tileScale=100 116 towerTemplate=tower117 73 position="0,0,0" 118 74 direction="0,0,0" 119 75 collisionType=dynamic 120 76 mass=100000 121 team=1 122 /> 77 > 78 <attached> 79 <Model position="-50,-50,0" mesh="Playfield_ME.mesh" scale=80 /> 80 <Model position="500,700,100" mesh="sphere.mesh" scale=80 /> 81 </attached> 82 <camerapositions> 83 <CameraPosition position="0,0,1500" lookat="0,0,0" absolute=true/> 84 </camerapositions> 85 </TowerDefenseCenterpoint> 123 86 124 87 </Scene> -
code/branches/presentationFS15/src/modules/objects/Turret.cc
r10262 r10452 223 223 XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode); 224 224 XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode); 225 XMLPortParam(Turret, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode); 225 226 } 226 227 -
code/branches/presentationFS15/src/modules/objects/Turret.h
r10262 r10452 102 102 { return this->maxYaw_; } 103 103 104 inline void setRotationThrust(float rotationthrust) 105 { this->rotationThrust_ = rotationthrust; } 106 107 inline float getRotationThrust() 108 { return this->rotationThrust_; } 109 104 110 protected: 105 111 Vector3 startDir_; //!< The initial facing direction, in local coordinates. -
code/branches/presentationFS15/src/modules/objects/controllers/TurretController.cc
r10262 r10452 104 104 { 105 105 Pawn* entity = orxonox_cast<Pawn*>(*it); 106 if (!entity || FormationController::sameTeam(t his->getControllableEntity(), entity, this->getGametype()))106 if (!entity || FormationController::sameTeam(turret, entity, this->getGametype())) 107 107 continue; 108 108 tempScore = turret->isInRange(entity); … … 196 196 if(this->isLookingAtTargetNew(Degree(5).valueRadians())) 197 197 { 198 198 199 this->getControllableEntity()->fire(0); 199 200 } -
code/branches/presentationFS15/src/modules/tetris/Tetris.h
r9833 r10452 90 90 void clearRow(unsigned int row); 91 91 92 93 92 PlayerInfo* player_; 94 93 -
code/branches/presentationFS15/src/modules/towerdefense/CMakeLists.txt
r10258 r10452 2 2 TowerDefense.cc 3 3 TowerDefenseTower.cc 4 TowerTurret.cc5 4 TowerDefenseCenterpoint.cc 6 5 TowerDefenseHUDController.cc … … 8 7 TDCoordinate.cc 9 8 TowerDefenseEnemy.cc 10 9 TowerDefenseSelecter.cc 11 10 ) 12 11 … … 17 16 orxonox 18 17 overlays 18 objects 19 19 SOURCE_FILES ${TOWERDEFENSE_SRC_FILES} 20 20 ) -
code/branches/presentationFS15/src/modules/towerdefense/TDCoordinate.cc
r10258 r10452 17 17 { 18 18 //RegisterObject(TDCoordinate); 19 x=0; 20 y=0; 19 Set(0,0); 21 20 22 21 } 23 22 24 23 TDCoordinate::TDCoordinate(int x, int y) 25 { 26 this->x=x; 27 this->y=y; 24 { 25 Set(x,y); 26 } 27 28 void TDCoordinate::Set(int x, int y) 29 { 30 if (x < 0) 31 { 32 _x = 0; 33 } 34 else if (x > 15) 35 { 36 _x = 15; 37 } 38 else 39 { 40 _x = x; 41 } 42 43 if (y < 0) 44 { 45 _y = 0; 46 } 47 else if (y > 15) 48 { 49 _y = 15; 50 } 51 else 52 { 53 _y = y; 54 } 55 } 56 57 int TDCoordinate::GetX() 58 { 59 return _x; 60 } 61 62 int TDCoordinate::GetY() 63 { 64 return _y; 28 65 } 29 66 … … 34 71 35 72 Vector3 *coord = new Vector3(); 36 coord->x= ( x-8) * tileScale;37 coord->y= ( y-8) * tileScale;73 coord->x= (_x-8) * tileScale; 74 coord->y= (_y-8) * tileScale; 38 75 coord->z=100; 39 76 -
code/branches/presentationFS15/src/modules/towerdefense/TDCoordinate.h
r10258 r10452 16 16 { 17 17 public: 18 int x; 19 int y; 18 TDCoordinate(); 19 TDCoordinate(int x, int y); 20 virtual ~TDCoordinate() {}; 21 virtual void Set(int x, int y); 22 virtual int GetX(); 23 virtual int GetY(); 24 virtual Vector3 get3dcoordinate(); 20 25 21 TDCoordinate(); 22 23 Vector3 get3dcoordinate(); 24 25 virtual ~TDCoordinate() {}; 26 27 TDCoordinate(int x, int y); 26 private: 27 int _x; 28 int _y; 28 29 }; 29 30 -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefense.cc
r10258 r10452 37 37 * 38 38 * 39 *40 39 *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen: 41 40 * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter … … 77 76 #include "TowerDefenseCenterpoint.h" 78 77 //#include "TDCoordinate.h" 79 #include "TowerTurret.h"80 78 #include "worldentities/SpawnPoint.h" 81 79 #include "worldentities/pawns/Pawn.h" … … 88 86 /* Part of a temporary hack to allow the player to add towers */ 89 87 #include "core/command/ConsoleCommand.h" 88 #include <cmath> 89 90 90 91 91 namespace orxonox 92 92 { 93 static const std::string __CC_addTower_name = "addTower"; 94 static const std::string __CC_upgradeTower_name = "upgradeTower"; 95 static const int upgradeCost = 20; 96 static const int towerCost = 20; 97 unsigned int maxspaceships = 30; 98 int maxspaceshipsstandard = 30; 99 100 101 102 SetConsoleCommand("TowerDefense", __CC_addTower_name, &TowerDefense::addTower ).addShortcut().defaultValues(1); 103 SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0); 104 93 105 RegisterUnloadableClass(TowerDefense); 94 106 95 TowerDefense::TowerDefense(Context* context) : Deathmatch(context)107 TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context) 96 108 { 97 109 RegisterObject(TowerDefense); … … 103 115 }*/ 104 116 117 //Timer for the waves (10 seconds between the waves) 118 selecter = NULL; 119 this->player_ = NULL; 105 120 this->setHUDTemplate("TowerDefenseHUD"); 106 107 //this->stats_ = new TowerDefensePlayerStats(); 108 109 /* Temporary hack to allow the player to add towers and upgrade them */ 110 this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) ); 111 this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) ); 121 this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this))); 122 this->nextwaveTimer_.stopTimer(); 123 this->waves_ = 0; 124 this->time = 0; 125 this->credit_ = 0; 126 this->lifes_ = 0; 127 this->timeSetTower_ = 0; 128 spaceships =15; 129 eggs=3; 130 ufos=7; 131 randomships=5; 132 133 134 ModifyConsoleCommand(__CC_addTower_name).setObject(this); 135 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this); 112 136 } 113 137 … … 117 141 if (this->isInitialized()) 118 142 { 119 if( this->dedicatedAddTower_ )120 delete this->dedicatedAddTower_;143 ModifyConsoleCommand(__CC_addTower_name).setObject(NULL); 144 ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL); 121 145 } 122 146 } … … 131 155 void TowerDefense::start() 132 156 { 133 134 Deathmatch::start(); 135 136 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path 137 for (int i=0; i < 16 ; i++){ 138 for (int j = 0; j< 16 ; j++){ 139 towermatrix[i][j] = false; 157 if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place. 158 { 159 if (selecter == NULL) 160 { 161 selecter = new TowerDefenseSelecter(this->center_->getContext()); 140 162 } 141 } 142 163 selecter->addTemplate(center_->getSelecterTemplate()); 164 center_->attach(selecter); 165 } 166 else // If no centerpoint was specified, an error is thrown and the level is exited. 167 { 168 orxout(internal_error) << "Jump: No Centerpoint specified." << endl; 169 return; 170 } 171 172 TeamDeathmatch::start(); 173 174 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path 175 for (int i=0; i < 16 ; i++) 176 { 177 for (int j = 0; j< 16 ; j++) 178 { 179 towerModelMatrix[i][j] = NULL; 180 towerTurretMatrix[i][j] = NULL; 181 } 182 } 183 184 185 186 if (player_ != NULL) 187 { 188 //this->player_->startControl(selecter); 189 } 190 else 191 { 192 orxout() << "player=NULL" << endl; 193 } 194 195 196 Model* dummyModel = new Model(this->center_->getContext()); 197 198 //the path of the spacehips has to be blocked, so that no towers can be build there 143 199 for (int k=0; k<3; k++) 144 tower matrix[1][k]=true;200 towerModelMatrix[1][k]=dummyModel; 145 201 for (int l=1; l<11; l++) 146 towermatrix[l][3]=true;202 towerModelMatrix[l][3]=dummyModel; 147 203 for (int m=3; m<12; m++) 148 towermatrix[10][m]=true;204 towerModelMatrix[10][m]=dummyModel; 149 205 for (int n=10; n<14; n++) 150 towermatrix[n][11]=true;206 towerModelMatrix[n][11]=dummyModel; 151 207 for (int o=13; o<16; o++) 152 towermatrix[13][o]=true; 208 towerModelMatrix[13][o]=dummyModel; 209 153 210 154 211 //set initial credits, lifes and WaveNumber 155 this->setCredit( 200);156 this->setLifes( 50);212 this->setCredit(100); 213 this->setLifes(100); 157 214 this->setWaveNumber(0); 158 215 time=0.0; 159 216 217 /* 160 218 //adds initial towers 161 219 for (int i=0; i <7; i++){ 162 220 addTower(i+3,4); 163 }/* 164 for (int j=0; j < 7; j++){ 165 addTower(9,j+5); 166 }*/ 221 } 222 */ 167 223 } 168 224 … … 178 234 en1->addTemplate("enemytowerdefense1"); 179 235 en1->setScale(3); 180 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 236 en1->lookAt(Vector3(0,0,100000)); 237 en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4); 181 238 break; 182 239 … … 184 241 en1->addTemplate("enemytowerdefense2"); 185 242 en1->setScale(2); 186 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 243 en1->lookAt(Vector3(0,0,100000)); 244 en1->roll(Degree(120)); 245 en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4); 187 246 // en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2)) 188 247 break; … … 191 250 en1->addTemplate("enemytowerdefense3"); 192 251 en1->setScale(1); 193 en1->setHealth(en1->getHealth() + this->getWaveNumber()*4); 252 en1->lookAt(Vector3(0,0,100000)); 253 en1->roll(Degree(120)); 254 en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4); 194 255 break; 195 256 } 196 257 258 en1->setTeam(2); 197 259 en1->getController(); 198 en1->setPosition(path.at(0)->get3dcoordinate()); 260 en1->setPosition(path.at(0)->get3dcoordinate()); 199 261 TowerDefenseEnemyvector.push_back(en1); 200 262 … … 209 271 { 210 272 211 Deathmatch::end();273 TeamDeathmatch::end(); 212 274 ChatManager::message("Match is over! Gameover!"); 213 275 276 } 277 278 void TowerDefense::spawnPlayer(PlayerInfo* player) 279 { 280 assert(player); 281 this->player_ = player; 282 283 if (selecter->getPlayer() == NULL) 284 { 285 this->player_ = player; 286 player->startControl(selecter); 287 players_[player].state_ = PlayerState::Alive; 288 } 289 } 290 291 /** 292 @brief 293 Get the player. 294 @return 295 Returns a pointer to the player. If there is no player, NULL is returned. 296 */ 297 PlayerInfo* TowerDefense::getPlayer(void) const 298 { 299 return this->player_; 214 300 } 215 301 216 302 //not working yet 217 303 void TowerDefense::upgradeTower(int x,int y) 218 {/* 219 const int upgradeCost = 20; 304 { 305 TDCoordinate* coord = new TDCoordinate(x,y); 306 x = coord->GetX(); 307 y = coord->GetY(); 308 220 309 221 310 if (!this->hasEnoughCreditForTower(upgradeCost)) … … 225 314 } 226 315 227 if (towermatrix [x][y] == NULL) 316 317 Model* dummyModel2 = new Model(this->center_->getContext()); 318 319 if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource()) 228 320 { 229 321 orxout() << "no tower on this position" << endl; … … 233 325 else 234 326 { 235 (towermatrix [x][y])->upgradeTower(); 236 }*/ 327 (towerTurretMatrix [x][y])->upgradeTower(); 328 switch(towerTurretMatrix[x][y]->upgrade) 329 { 330 case 1 : 331 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 332 break; 333 334 case 2 : 335 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 336 break; 337 case 3 : 338 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 339 break; 340 case 4 : 341 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 342 break; 343 344 } 345 346 this->buyTower(upgradeCost); 347 } 237 348 } 238 349 239 350 /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret") 240 351 so towers have ability if the turrets 241 242 352 */ 353 243 354 void TowerDefense::addTower(int x, int y) 244 { 245 const int towerCost = 20; 355 { 356 TDCoordinate* coord = new TDCoordinate(x,y); 357 x = coord->GetX(); 358 y = coord->GetY(); 359 246 360 247 361 if (!this->hasEnoughCreditForTower(towerCost)) … … 251 365 } 252 366 253 if (tower matrix [x][y]==true)367 if (towerModelMatrix [x][y]!=NULL) 254 368 { 255 369 orxout() << "not possible to put tower here!!" << endl; … … 264 378 int tileScale = (int) this->center_->getTileScale(); 265 379 266 if (x > 15 || y > 15 || x < 0 || y < 0)380 /*if (x > 15 || y > 15 || x < 0 || y < 0) 267 381 { 268 382 //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet) 269 383 orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl; 270 384 return; 271 } 272 273 orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 274 275 //Reduce credit 276 this->buyTower(towerCost); 277 towermatrix [x][y]=true; 385 }*/ 386 387 //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 388 orxout() << "Will add tower at (" << x << "," << y << ")" << endl; 389 390 391 //Create Model 392 Model* newTowerModel = new Model(this->center_->getContext()); 393 newTowerModel->setMeshSource("TD_T1.mesh"); 394 newTowerModel->setScale(30); 395 newTowerModel->pitch(Degree(90)); 396 newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80); 278 397 279 398 //Creates tower 280 399 TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext()); 281 towernew->addTemplate("towerturret"); 282 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75); 400 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 275); 283 401 towernew->setGame(this); 284 } 402 towernew->setTeam(1); 403 404 //Reduce credit 405 this->buyTower(towerCost); 406 towerModelMatrix [x][y]= newTowerModel; 407 towerTurretMatrix [x][y]= towernew; 408 } 285 409 286 410 bool TowerDefense::hasEnoughCreditForTower(int towerCost) … … 296 420 297 421 422 void TowerDefense::nextwave() 423 { 424 425 orxout() << "newwave" << endl; 426 TowerDefenseEnemyvector.clear(); 427 waves_++; 428 //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_)); 429 time=0; 430 431 int helpnumber = 40 -(waves_); 432 if(helpnumber <= 0) {helpnumber =1;} 433 float numSpaceships = std::abs((rand() % 100)*5*(helpnumber)); 434 float numEggs = std::abs((rand() % 100)*1*(waves_)); 435 float numUfos = std::abs((rand() % 100)*1.5*(0.5*(waves_))) ; 436 437 float totalnumber = (numSpaceships + numEggs + numUfos)*1.3; 438 439 int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber); 440 int neweggs = (int)(maxspaceships*numEggs / totalnumber); 441 int newufos = (int)(maxspaceships*numUfos / totalnumber); 442 int newrandomships = maxspaceships -newspaceships - neweggs - newufos; 443 spaceships =newspaceships; 444 eggs=neweggs; 445 ufos=newufos; 446 randomships=newrandomships; 447 448 orxout() << spaceships << endl; 449 orxout() << eggs << endl; 450 orxout() << ufos << endl; 451 orxout() << randomships << endl; 452 453 454 455 456 457 } 458 298 459 void TowerDefense::tick(float dt) 299 460 { 300 461 SUPER(TowerDefense, tick, dt); 301 462 time +=dt; 463 timeSetTower_ +=dt; 464 465 //Check if tower has to be set (because TowerDefenseSelecter asks for it) 466 if(timeSetTower_ >= 0.25) 467 { 468 timeSetTower_ =0; 469 if(selecter != NULL && selecter->firePressed_) 470 { 471 472 int x = selecter->selectedPos_->GetX(); 473 int y = selecter->selectedPos_->GetY(); 474 Model* dummyModel2 = new Model(this->center_->getContext()); 475 476 477 478 if(towerModelMatrix[x][y] == NULL) 479 { 480 addTower(x,y); 481 } 482 else 483 { 484 if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())) 485 { 486 towerTurretMatrix[x][y]->upgradeTower(); 487 if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax) 488 { 489 int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade))); 490 if(this->credit_ >= specificupgradecost) 491 { 492 this->buyTower(specificupgradecost); 493 switch(towerTurretMatrix[x][y]->upgrade) 494 { 495 case 1 : 496 towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh"); 497 break; 498 499 case 2 : 500 towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh"); 501 break; 502 case 3 : 503 towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh"); 504 break; 505 case 4 : 506 towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh"); 507 break; 508 509 } 510 } 511 512 513 } 514 } 515 } 516 selecter->firePressed_ = false; 517 } 518 } 302 519 303 520 TDCoordinate* coord1 = new TDCoordinate(1,1); 304 521 std::vector<TDCoordinate*> path; 305 522 path.push_back(coord1); 306 if(time>1 && TowerDefenseEnemyvector.size() < 30) 307 { 308 //adds different types of enemys depending on the WaveNumber 309 addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 ); 310 time = time-1; 311 } 523 524 525 526 527 528 if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships) 529 { 530 531 //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult 532 if(spaceships>0) 533 { 534 addTowerDefenseEnemy(path, 1); 535 spaceships--; 536 537 }else if(ufos>0) 538 { 539 addTowerDefenseEnemy(path, 3); 540 ufos--; 541 }else if(eggs>0) 542 { 543 addTowerDefenseEnemy(path, 2); 544 eggs--; 545 }else if(randomships>0) 546 { 547 addTowerDefenseEnemy(path, rand() % 3 +1); 548 randomships--; 549 550 } 551 552 } 553 312 554 313 555 Vector3* endpoint = new Vector3(500, 700, 150); … … 317 559 if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive()) 318 560 { 319 //destroys enemys at the end of t ehpath and reduces the life by 1. no credits gifted561 //destroys enemys at the end of the path and reduces the life by 1. no credits gifted 320 562 321 563 Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition(); … … 333 575 } 334 576 } 577 335 578 //goes thorugh vector to see if an enemy is still alive. if not next wave is launched 336 579 int count= 0; … … 343 586 } 344 587 588 if (count == 0 && !this->nextwaveTimer_.isActive()) 589 this->nextwaveTimer_.startTimer(); 590 591 /* time2 +=dt; 345 592 if(count== 0) 346 593 { 347 time2 +=dt;348 594 if(time2 > 10) 349 595 { … … 354 600 } 355 601 } 356 357 358 } 602 */ 603 604 } 605 359 606 360 607 // Function to test if we can add waypoints using code only. Doesn't work yet … … 399 646 void TowerDefense::playerEntered(PlayerInfo* player) 400 647 { 401 Deathmatch::playerEntered(player);648 TeamDeathmatch::playerEntered(player); 402 649 403 650 const std::string& message = player->getName() + " entered the game"; … … 407 654 bool TowerDefense::playerLeft(PlayerInfo* player) 408 655 { 409 bool valid_player = Deathmatch::playerLeft(player);656 bool valid_player = TeamDeathmatch::playerLeft(player); 410 657 411 658 if (valid_player) … … 437 684 } 438 685 439 Deathmatch::pawnKilled(victim, killer);686 TeamDeathmatch::pawnKilled(victim, killer); 440 687 } 441 688 -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefense.h
r10258 r10452 38 38 #define _TowerDefense_H__ 39 39 #include "TDCoordinate.h" 40 #include "TowerDefenseSelecter.h" 40 41 #include "towerdefense/TowerDefensePrereqs.h" 41 #include "gametypes/ Deathmatch.h"42 #include "gametypes/TeamDeathmatch.h" 42 43 #include "TowerDefenseEnemy.h" 43 44 #include "util/Output.h" 44 45 #include "core/object/WeakPtr.h" 46 #include "TowerDefenseSelecter.h" 47 #include "graphics/Camera.h" 48 45 49 46 50 namespace orxonox 47 51 { 48 class _TowerDefenseExport TowerDefense : public Deathmatch52 class _TowerDefenseExport TowerDefense : public TeamDeathmatch 49 53 { 50 54 public: … … 53 57 54 58 std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector; 55 bool towermatrix[16][16]; 59 Model* towerModelMatrix[16][16]; 60 TowerDefenseTower* towerTurretMatrix[16][16]; 56 61 void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); 57 62 virtual void start(); //<! The function is called when the gametype starts 58 63 virtual void end(); 59 64 virtual void tick(float dt); 60 //virtual void playerEntered(PlayerInfo* player); 61 //virtual bool playerLeft(PlayerInfo* player); 62 //Player Stats (set,get, reduce) 65 virtual void spawnPlayer(PlayerInfo* player); 66 PlayerInfo* getPlayer(void) const; 63 67 int getCredit(){ return this->credit_; } 64 68 int getLifes(){ return this->lifes_; } … … 69 73 void buyTower(int cost){ credit_ -= cost;} 70 74 void addCredit(int credit) { credit_+=credit; } 71 void nextwave() { waves_++;}75 void nextwave(); 72 76 int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; } 77 TowerDefenseSelecter* selecter; 78 int spaceships; 79 int eggs; 80 int ufos; 81 int randomships; 82 73 83 74 84 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); … … 83 93 /* Adds a tower at x, y in the playfield */ 84 94 void addTower(int x, int y); 85 86 95 void upgradeTower(int x, int y); 87 /* Part of a temporary hack to allow the player to add towers */88 ConsoleCommand* dedicatedAddTower_;89 ConsoleCommand* dedicatedUpgradeTower_;90 96 91 97 //TODO: void spawnNewWave() … … 96 102 private: 97 103 TowerDefenseCenterpoint *center_; 104 PlayerInfo* player_; 98 105 float time; 99 float time2; 106 float timeSetTower_; 107 // float time2; 100 108 int credit_; 101 109 int waves_; 102 110 int lifes_; 111 Timer nextwaveTimer_; 103 112 104 113 /* handles stats */ 105 114 bool hasEnoughCreditForTower(int towerCost); 106 115 bool hasEnoughCreditForUpgrade(); 107 108 109 110 std::vector<TowerTurret*> towers_;111 116 }; 112 117 } -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r9667 r10452 53 53 this->width_ = 15; 54 54 this->height_ = 15; 55 this->towerTemplate_ = "";56 55 57 56 //this->setCollisionType(Static); … … 72 71 XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode); 73 72 XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode); 74 XMLPortParam(TowerDefenseCenterpoint, " towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);73 XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode); 75 74 76 75 //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode); -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseCenterpoint.h
r9667 r10452 60 60 void setWidth(unsigned int width) 61 61 { this->width_ = width; } 62 63 62 unsigned int getWidth(void) const 64 63 { return this->width_; } 65 66 64 void setHeight(unsigned int height) 67 65 { this->height_ = height; } 68 69 66 unsigned int getHeight(void) const 70 67 { return this->height_; } 71 68 void setSelecterTemplate(const std::string& newTemplate) 69 { this->selecterTemplate_ = newTemplate; } 70 const std::string& getSelecterTemplate() const 71 { return this->selecterTemplate_; } 72 72 /** 73 73 @brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10) … … 79 79 { return this->tileScale_; } 80 80 81 /**82 @brief Set the template for the towers.83 @param template The template name to be applied to each tower.84 */85 void setTowerTemplate(const std::string& templateName)86 { this->towerTemplate_ = templateName; }87 88 const std::string& getTowerTemplate(void) const89 { return this->towerTemplate_; }90 91 81 private: 92 82 void checkGametype(); 93 83 84 std::string selecterTemplate_; 94 85 unsigned int width_; 95 86 unsigned int height_; 96 87 unsigned int tileScale_; 97 98 std::string towerTemplate_;99 88 }; 100 89 } -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseEnemy.cc
r10258 r10452 35 35 //add credit if enemy is destroyed 36 36 TowerDefenseEnemy::~TowerDefenseEnemy(){ 37 //this->td->addCredit(1); 37 38 if (this->isInitialized()) 39 { 40 getGame()->addCredit(1); 41 } 38 42 } 39 43 … … 64 68 if (getGame() && once_ == false && getHealth() <= 0) 65 69 { 70 orxout() << "damagefunctionIF" << endl; 66 71 getGame()->addCredit(1); 67 72 once_ = true; 68 73 } 74 orxout() << "damagefunction" << endl; 75 69 76 } 77 70 78 /* 71 79 void TowerDefenseEnemy::popWaypoint() -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseTower.cc
r10258 r10452 22 22 Constructor. Registers and initializes the object. 23 23 */ 24 TowerDefenseTower::TowerDefenseTower(Context* context) : Pawn(context)24 TowerDefenseTower::TowerDefenseTower(Context* context) : Turret(context) 25 25 { 26 26 RegisterObject(TowerDefenseTower); 27 game_ =NULL; 28 this->setCollisionType(WorldEntity::None); 29 upgrade = 0; 30 this->addTemplate("towerdefensetower"); 27 31 28 this->setCollisionType(WorldEntity::Dynamic);29 upgrade = 0; 32 upgradeMax = 5; 33 30 34 31 35 //this->removeAllEngines(); … … 38 42 } 39 43 44 /* 40 45 void TowerDefenseTower::setOrientation(const Quaternion& orientation) 41 46 { … … 53 58 { 54 59 } 60 */ 55 61 56 62 bool TowerDefenseTower::upgradeTower() 57 63 { 58 if(upgrade < 3)64 if(upgrade < upgradeMax) 59 65 { 60 66 upgrade++; 61 67 float reloadrate = getReloadRate(); 62 68 float reloadwaittime = getReloadWaitTime(); 63 this->setDamageMultiplier( 5000);64 65 reloadrate = 0. 5f*reloadrate;66 reloadwaittime = 0. 5f*reloadwaittime;69 this->setDamageMultiplier((upgrade+1)*1.5); 70 this->setRotationThrust(2*this->getRotationThrust()); 71 reloadrate = 0.7f*reloadrate; 72 reloadwaittime = 0.7f*reloadwaittime; 67 73 setReloadRate(reloadrate); 68 74 setReloadWaitTime(reloadwaittime); 69 this->addTemplate("towerturret1");75 //this->addTemplate("towerturret1"); 70 76 } 71 77 else -
code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseTower.h
r10258 r10452 20 20 #include "towerdefense/TowerDefensePrereqs.h" 21 21 #include "worldentities/pawns/SpaceShip.h" 22 #include "objects/Turret.h" 22 23 23 24 24 25 namespace orxonox 25 26 { 26 class _TowerDefenseExport TowerDefenseTower : public Pawn27 class _TowerDefenseExport TowerDefenseTower : public Turret 27 28 { 28 29 public: … … 37 38 38 39 // Overriding these to stop TowerDefenseTowers from spasing out 40 /* 39 41 void setOrientation(const Quaternion& orientation); 40 42 virtual void rotateYaw(const Vector2& value); 41 43 virtual void rotatePitch(const Vector2& value); 42 44 virtual void rotateRoll(const Vector2& value); 45 */ 43 46 virtual bool upgradeTower(); 44 47 … … 46 49 void setGame(TowerDefense* Towerdefense) 47 50 { assert(Towerdefense); game_ = Towerdefense; } 51 int upgrade; 52 int upgradeMax; 48 53 private: 49 54 TowerDefense* game_; 50 int upgrade; 55 51 56 }; 52 57 } -
code/branches/presentationFS15/src/orxonox/controllers/FormationController.cc
r10290 r10452 955 955 bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 956 956 { 957 958 957 959 if (entity1 == entity2) 958 960 return true; … … 984 986 } 985 987 986 Team Deathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);988 TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype); 987 989 if (tdm) 988 990 { … … 992 994 if (entity2->getPlayer()) 993 995 team2 = tdm->getTeam(entity2->getPlayer()); 994 }995 996 Mission* miss = orxonox_cast<Mission*>(gametype);997 if (miss)998 {999 if (entity1->getPlayer())1000 team1 = miss->getTeam(entity1->getPlayer());1001 1002 if (entity2->getPlayer())1003 team2 = miss->getTeam(entity2->getPlayer());1004 996 } 1005 997
Note: See TracChangeset
for help on using the changeset viewer.