Changeset 10159 for code/branches/towerdefenseHS14/src/modules/towerdefense
- Timestamp:
- Dec 5, 2014, 4:27:06 PM (10 years ago)
- Location:
- code/branches/towerdefenseHS14/src/modules/towerdefense
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
r10158 r10159 102 102 this->setHUDTemplate("TowerDefenseHUD"); 103 103 104 this->stats_ = new TowerDefensePlayerStats();104 //this->stats_ = new TowerDefensePlayerStats(); 105 105 106 106 /* Temporary hack to allow the player to add towers */ … … 131 131 132 132 Deathmatch::start(); 133 credits = 5000;133 /*credits = 5000; 134 134 life = 20; 135 135 waves = 0; 136 time=0.0; 136 time=0.0;*/ 137 137 138 138 // Waypoints: [1,3] [10,3] [10,11] [13,11] … … 154 154 155 155 156 credits = 5000;157 life = 20;158 waves = 0;156 this->setCredit(200); 157 this->setLifes(10); 158 this->setWaveNumber(0); 159 159 time=0.0; 160 160 … … 236 236 Deathmatch::end(); 237 237 238 ChatManager::message("Match is over ");238 ChatManager::message("Match is over! Gameover!"); 239 239 } 240 240 241 241 void TowerDefense::upgradeTower(int x,int y) 242 { 243 const TowerCost upgra eCost = TDDefaultUpgradeCost;244 245 if (!this->hasEnoughCreditForTower(upgra eCost))246 { 247 orxout() << "not enough credit: " << (this-> stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";242 {/* 243 const TowerCost upgradeCost = TDDefaultUpgradeCost; 244 245 if (!this->hasEnoughCreditForTower(upgradeCost)) 246 { 247 orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed."; 248 248 return; 249 249 } … … 258 258 { 259 259 (towermatrix [x][y])->upgradeTower(); 260 } 260 }*/ 261 261 } 262 262 … … 264 264 void TowerDefense::addTower(int x, int y) 265 265 { 266 const TowerCost towerCost = TDDefaultTowerCost;266 const int towerCost = 20; 267 267 268 268 if (!this->hasEnoughCreditForTower(towerCost)) 269 269 { 270 orxout() << "not enough credit: " << (this-> stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";270 orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed."; 271 271 return; 272 272 } … … 278 278 } 279 279 280 280 /* 281 281 unsigned int width = this->center_->getWidth(); 282 282 unsigned int height = this->center_->getHeight(); 283 283 */ 284 284 285 285 int tileScale = (int) this->center_->getTileScale(); … … 297 297 298 298 //Reduce credit 299 this->stats_->buyTower(towerCost); 300 301 orxout() << "Credit: " << this->stats_->getCredit() << endl; 299 this->buyTower(towerCost); 300 301 towermatrix [x][y]=true; 302 302 303 303 304 // Create tower … … 307 308 towernew->setGame(this); 308 309 309 towermatrix[x][y]=true; 310 } 311 312 bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost) 313 { 314 return ((this->stats_->getCredit()) >= towerCost); 310 } 311 312 bool TowerDefense::hasEnoughCreditForTower(int towerCost) 313 { 314 return ((this->getCredit()) >= towerCost); 315 315 } 316 316 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
r10158 r10159 62 62 //virtual void playerEntered(PlayerInfo* player); 63 63 //virtual bool playerLeft(PlayerInfo* player); 64 //Player Stats (set,get, reduce) 65 int getCredit(){ return this->credit_; } 66 int getLifes(){ return this->lifes_; } 67 int getWaveNumber(){ return this->waves_; } 68 void setCredit(int credit){ credit_ = credit; } 69 void setLifes(int lifes){ lifes_ = lifes; } 70 void setWaveNumber(int wavenumber){waves_=wavenumber; } 71 void buyTower(int cost){ credit_ -= cost;} 72 void addCredit(int credit) { credit_+=credit; } 73 void nextwave(){ waves_++;} 74 int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; } 64 75 65 int credits;66 int life;67 int waves;68 76 //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); 69 77 //virtual void playerScored(PlayerInfo* player, int score); … … 92 100 float time; 93 101 float time2; 102 int credit_; 103 int waves_; 104 int lifes_; 94 105 95 106 /* handles stats */ 96 TowerDefensePlayerStats *stats_; 97 bool hasEnoughCreditForTower(TowerCost towerCost); 107 bool hasEnoughCreditForTower(int towerCost); 98 108 bool hasEnoughCreditForUpgrade(); 99 109 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc
r10158 r10159 29 29 30 30 this->setCollisionType(WorldEntity::Dynamic); 31 this->td = orxonox_cast<TowerDefense*>(this->getGametype().get()); 32 once_ = false; 31 33 32 34 } 35 36 TowerDefenseEnemy::~TowerDefenseEnemy(){this->td->addCredit(20);} 33 37 34 38 void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord) … … 49 53 50 54 //orxout() << "distance" << distance << endl; 51 if(distance <50){ 55 if(distance < 50 && once_ == false){ 56 this->td->reduceLifes(1); 57 once_=true; 52 58 orxout() << "ENEMY KILLED!!!!" << endl; 53 this->destroy(); } 59 this->td->buyTower(20); 60 if (this->td->getLifes()==0) 61 { 62 this->td->end(); 63 } 64 65 } 54 66 } 55 67 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.h
r10132 r10159 23 23 #include "util/Output.h" 24 24 #include "controllers/ArtificialController.h" 25 #include "TowerDefense.h" 25 26 26 27 namespace orxonox … … 35 36 36 37 TowerDefenseEnemy(Context* context); 37 virtual ~TowerDefenseEnemy() {};38 virtual ~TowerDefenseEnemy(); 38 39 39 40 //health gibt es unter: health_ … … 47 48 private: 48 49 50 TowerDefense* td; 51 bool once_; 49 52 std::vector<TDCoordinate*> Waypointsvector_; 50 53 -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc
r10140 r10159 39 39 { 40 40 RegisterObject(TowerDefenseHUDController); 41 this->td = 0; 41 42 } 42 43 … … 49 50 { 50 51 SUPER(TowerDefenseHUDController, tick, dt); 52 const std::string& lifes = multi_cast<std::string>(this->td->getLifes()); 53 const std::string& credits = multi_cast<std::string>(this->td->getCredit()); 54 const std::string& waves = multi_cast<std::string>(this->td->getWaveNumber()); 51 55 52 56 if(showlives == true) 53 this->setCaption(multi_cast<std::string>( this->td->life));57 this->setCaption(multi_cast<std::string>(lifes)); 54 58 else if(showcredits == true) 55 this->setCaption(multi_cast<std::string>( this->td->credits));59 this->setCaption(multi_cast<std::string>(credits)); 56 60 else if(showwaves == true) 57 this->setCaption(multi_cast<std::string>( this->td->waves));61 this->setCaption(multi_cast<std::string>(waves)); 58 62 59 63 … … 74 78 SUPER(TowerDefenseHUDController, changedOwner); 75 79 76 td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get()); 77 80 if (this->getOwner() && this->getOwner()->getGametype()) 81 { 82 this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get()); 83 } 84 else 85 { 86 this->td = 0; 87 } 88 } 78 89 /*if (this->getOwner() != NULL && this->getOwner()->getGametype()) 79 90 { … … 86 97 } 87 98 88 } -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.h
r10140 r10159 39 39 40 40 #include "towerdefense/TowerDefensePrereqs.h" 41 41 #include "TowerDefensePlayerStats.h" 42 42 #include "tools/interfaces/Tickable.h" 43 43 #include "overlays/OverlayText.h" … … 73 73 private: 74 74 TowerDefense* td; 75 76 75 bool showcredits; 77 76 bool showlives; -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.cc
r9272 r10159 25 25 * ... 26 26 */ 27 27 /* 28 28 #include "TowerDefensePlayerStats.h" 29 29 … … 31 31 { 32 32 const int kDefaultCredit = 200; 33 33 const int kDefaultLifes=20; 34 34 TowerDefensePlayerStats::TowerDefensePlayerStats() 35 35 { 36 36 this->credit_ = kDefaultCredit; 37 37 this->waveNumber_ = 0; 38 this->lifes_=kDefaultLifes; 38 39 } 39 /* 40 40 41 TowerDefensePlayerStats::~TowerDefensePlayerStats() 41 42 { 42 43 } 43 */ 44 44 45 } 46 */ -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h
r10158 r10159 68 68 { waveNumber_++; } 69 69 70 inline int getLifes() 71 {return lifes_; } 72 73 inline void reduceLifes(int NumberofLifes) 74 {lifes_-=NumberofLifes; } 75 70 76 inline void upgradeTower(int upgradecost) 71 77 { credit_ -= upgradecost;} … … 77 83 int waveNumber_; 78 84 int upgradecost; 85 int lifes_; 79 86 //int baseHealth_; 80 87 }; -
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePrereqs.h
r10142 r10159 66 66 { 67 67 class TowerDefense; 68 68 69 class TowerDefenseTower; 70 69 71 class TowerDefenseCenterpoint; 70 72 class TowerDefenseHUDController; … … 73 75 class TDCoordinate; 74 76 class TowerTurret; 77 class TowerDefenseTower; 75 78 } 76 79
Note: See TracChangeset
for help on using the changeset viewer.