Changeset 10142 for code/branches/towerdefenseHS14/src/modules
- Timestamp:
- Nov 26, 2014, 5:14:33 PM (10 years ago)
- Location:
- code/branches/towerdefenseHS14/src/modules/towerdefense
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseHS14/src/modules/towerdefense/CMakeLists.txt
r10109 r10142 1 1 SET_SOURCE_FILES(TOWERDEFENSE_SRC_FILES 2 2 TowerDefense.cc 3 Tower .cc3 TowerDefenseTower.cc 4 4 TowerTurret.cc 5 5 TowerDefenseCenterpoint.cc -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
r10141 r10142 75 75 76 76 #include "TowerDefense.h" 77 //#include "Tower.h"77 #include "TowerDefenseTower.h" 78 78 #include "TowerTurret.h" 79 79 #include "TowerDefenseCenterpoint.h" … … 130 130 131 131 Deathmatch::start(); 132 133 // Waypoints: [1,3] [10,3] [10,11] [13,11] 134 for (int i=0; i < 16 ; i++){ 135 for (int j = 0; j< 16 ; j++){ 136 towermatrix[i][j] = false; 137 } 138 } 139 for (int k=0; k<3; k++) 140 towermatrix[1][k]=true; 141 for (int l=1; l<11; l++) 142 towermatrix[l][3]=true; 143 for (int m=3; m<12; m++) 144 towermatrix[10][m]=true; 145 for (int n=10; n<14; n++) 146 towermatrix[n][11]=true; 147 for (int o=13; o<16; o++) 148 towermatrix[13][o]=true; 149 150 132 151 credits = 5000; 133 152 life = 20; … … 135 154 time=0.0; 136 155 137 /* 138 const int kInitialTowerCount = 3; 156 const int kInitialTowerCount = 3; 139 157 140 158 for (int i = 0; i < kInitialTowerCount; i++) 141 159 { 142 //{{3,2}, {8,5}, {12,10}}; old coordinates 143 TDCoordinate* coordinate = new TDCoordinate(i,(i*2)); 144 addTower(coordinate->x, coordinate->y); 145 } 146 */ 160 addTower(i+4,(i+5)); 161 } 162 147 163 148 164 … … 221 237 222 238 void TowerDefense::addTower(int x, int y) 223 { /*239 { 224 240 const TowerCost towerCost = TDDefaultTowerCost; 225 241 … … 230 246 } 231 247 232 if (t his->towerExists(x,y))233 { 234 orxout() << " tower exists!!" << endl;248 if (towermatrix [x][y]==true) 249 { 250 orxout() << "not possible to put tower here!!" << endl; 235 251 return; 236 252 } … … 252 268 orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 253 269 254 // Add tower to coordinatesStack 255 TDCoordinate newTowerCoordinates; 256 newTowerCoordinates.x=x; 257 newTowerCoordinates.y=y; 258 259 260 addedTowersCoordinates_.push_back(newTowerCoordinates); 261 262 // Reduce credit 270 271 272 //Reduce credit 263 273 this->stats_->buyTower(towerCost); 264 274 265 // Create tower 266 TowerTurret* newTower = new TowerTurret(this->center_->getContext()); 267 newTower->addTemplate(this->center_->getTowerTemplate()); 268 269 newTower->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75); 270 newTower->setGame(this);*/ 275 orxout() << "Credit: " << this->stats_->getCredit() << endl; 276 277 // Create tower 278 TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext()); 279 towernew->addTemplate("tower"); 280 towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75); 281 towernew->setGame(this); 282 283 towermatrix[x][y]=true; 271 284 } 272 285 … … 276 289 } 277 290 278 bool TowerDefense::towerExists(int x, int y) 279 { 280 for(std::vector<TDCoordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it) 281 { 282 TDCoordinate currentCoordinates = (TDCoordinate) (*it); 283 if (currentCoordinates.x == x && currentCoordinates.y == y) 284 return true; 285 } 286 287 return false; 288 } 289 290 291 291 292 void TowerDefense::tick(float dt) 292 293 { -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
r10141 r10142 55 55 56 56 std::vector<TowerDefenseEnemy*> TowerDefenseEnemyvector; 57 57 bool towermatrix[16][16]; 58 58 void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); 59 59 virtual void start(); //<! The function is called when the gametype starts … … 94 94 bool hasEnoughCreditForTower(TowerCost towerCost); 95 95 96 bool towerExists(int x, int y);97 98 99 std::vector<TDCoordinate> addedTowersCoordinates_;100 96 std::vector<TowerTurret*> towers_; 101 97 }; -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc
r10140 r10142 48 48 float distance = ship.distance(*endpoint); 49 49 50 orxout() << "distance" << distance << endl;50 //orxout() << "distance" << distance << endl; 51 51 if(distance <50){ 52 orxout() << "ENEMY KILLED!!!!" << endl;52 // orxout() << "ENEMY KILLED!!!!" << endl; 53 53 this->destroy(); } 54 54 } -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h
r9272 r10142 44 44 typedef enum _TowerCosts { 45 45 // Set to 0 for debug... 46 TDDefaultTowerCost = 046 TDDefaultTowerCost = 20 47 47 } TowerCost; 48 48 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePrereqs.h
r10109 r10142 66 66 { 67 67 class TowerDefense; 68 //classTower;68 class TowerDefenseTower; 69 69 class TowerDefenseCenterpoint; 70 70 class TowerDefenseHUDController;
Note: See TracChangeset
for help on using the changeset viewer.