- Timestamp:
- Nov 26, 2014, 5:14:33 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.