Changeset 11071 for code/trunk/src/modules/towerdefense
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/towerdefense/TowerDefense.cc
r10727 r11071 90 90 RegisterObject(TowerDefense); 91 91 92 selecter = NULL;93 this->player_ = NULL;92 selecter = nullptr; 93 this->player_ = nullptr; 94 94 this->setHUDTemplate("TowerDefenseHUD"); 95 95 this->waveNumber_ = 0; … … 117 117 void TowerDefense::start() 118 118 { 119 if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.120 { 121 if (selecter == NULL)119 if (center_ != nullptr) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place. 120 { 121 if (selecter == nullptr) 122 122 { 123 123 selecter = new TowerDefenseSelecter(this->center_->getContext()); … … 176 176 WaypointController* controller = (WaypointController*)(en1->getXMLController()); 177 177 178 if (controller != NULL&& waypoints_.size() > 1)178 if (controller != nullptr && waypoints_.size() > 1) 179 179 { 180 180 en1->setPosition(waypoints_.at(0)->getPosition() + offset_); … … 183 183 en1->lookAt(waypoints_.at(1)->getPosition() + offset_); 184 184 185 for ( unsigned int i = 0; i < waypoints_.size(); ++ i)185 for (TowerDefenseField* field : waypoints_) 186 186 { 187 187 orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext()); 188 waypoint->setPosition( waypoints_.at(i)->getPosition() + offset_);188 waypoint->setPosition(field->getPosition() + offset_); 189 189 controller->addWaypoint(waypoint); 190 190 } … … 208 208 player_ = player; 209 209 210 if (selecter->getPlayer() == NULL)210 if (selecter->getPlayer() == nullptr) 211 211 { 212 212 player_->startControl(selecter); … … 219 219 Get the player. 220 220 @return 221 Returns a pointer to the player. If there is no player, NULLis returned.221 Returns a pointer to the player. If there is no player, nullptr is returned. 222 222 */ 223 223 PlayerInfo* TowerDefense::getPlayer(void) const … … 265 265 SUPER(TowerDefense, tick, dt); 266 266 267 if (hasStarted() == false || player_ == NULL)267 if (hasStarted() == false || player_ == nullptr) 268 268 { 269 269 return; … … 273 273 274 274 //build/upgrade tower at selecter position 275 if (selecter != NULL&& selecter->buildTower_ == true)275 if (selecter != nullptr && selecter->buildTower_ == true) 276 276 { 277 277 selecter->buildTower_ = false; … … 287 287 } 288 288 289 for (std::list<WeakPtr<TowerDefenseEnemy> 290 { 291 if (*it == NULL)289 for (std::list<WeakPtr<TowerDefenseEnemy>>::iterator it = enemies_.begin(); it != enemies_.end(); ) 290 { 291 if (*it == nullptr) 292 292 { 293 293 // the enemy was destroyed by a tower - remove it from the list … … 355 355 fields_[i][j]->create(fields.at(pos), fields.at(pos+1)); 356 356 pos += 2; 357 if (fields_[i][j]->getType() == START)357 if (fields_[i][j]->getType() == TowerDefenseFieldType::START) 358 358 { 359 359 startCoord.Set(i,j); … … 365 365 TDCoordinate* thisCoord = &startCoord; 366 366 TDCoordinate* nextCoord; 367 while ((nextCoord = getNextStreetCoord(thisCoord)) != NULL)367 while ((nextCoord = getNextStreetCoord(thisCoord)) != nullptr) 368 368 { 369 369 waypoints_.push_back(fields_[nextCoord->GetX()][nextCoord->GetY()]); … … 379 379 TDCoordinate* nextCoord = new TDCoordinate(0,0); 380 380 381 if (thisField->getType() != STREET && thisField->getType() !=START)382 { 383 return NULL;381 if (thisField->getType() != TowerDefenseFieldType::STREET && thisField->getType() != TowerDefenseFieldType::START) 382 { 383 return nullptr; 384 384 } 385 385 … … 406 406 } 407 407 408 return NULL;408 return nullptr; 409 409 } 410 410 } -
code/trunk/src/modules/towerdefense/TowerDefense.h
r10629 r11071 53 53 virtual ~TowerDefense(); 54 54 void addTowerDefenseEnemy(int templatenr); 55 virtual void start() ; //<! The function is called when the gametype starts56 virtual void end() ;57 virtual void tick(float dt) ;58 virtual void spawnPlayer(PlayerInfo* player) ;55 virtual void start() override; //<! The function is called when the gametype starts 56 virtual void end() override; 57 virtual void tick(float dt) override; 58 virtual void spawnPlayer(PlayerInfo* player) override; 59 59 PlayerInfo* getPlayer(void) const; 60 60 int getCredit(){ return this->credit_; } … … 87 87 int waveNumber_; 88 88 int lifes_; 89 std::list<orxonox::WeakPtr<TowerDefenseEnemy> 89 std::list<orxonox::WeakPtr<TowerDefenseEnemy>> enemies_; 90 90 TowerDefenseField* fields_[16][16]; 91 std::vector<orxonox::WeakPtr<TowerDefenseField> 91 std::vector<orxonox::WeakPtr<TowerDefenseField>> waypoints_; 92 92 Vector3 endpoint_; 93 93 Vector3 offset_; -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r10629 r11071 92 92 void TowerDefenseCenterpoint::checkGametype() 93 93 { 94 if (this->getGametype() != NULL&& this->getGametype()->isA(Class(TowerDefense)))94 if (this->getGametype() != nullptr && this->getGametype()->isA(Class(TowerDefense))) 95 95 { 96 96 // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point -
code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
r10629 r11071 52 52 virtual ~TowerDefenseCenterpoint() {} 53 53 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 55 55 56 56 /** -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
r10629 r11071 27 27 RegisterObject(TowerDefenseEnemy); 28 28 29 this->setCollisionType(WorldEntity:: Dynamic);29 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 30 30 //needed to keep track of the PlayerStats coded in TowerDefense.h 31 31 this->td = orxonox_cast<TowerDefense*>(this->getGametype()); … … 38 38 } 39 39 40 void TowerDefenseEnemy::tick(float dt)41 {42 //orxout() << "TDE tick1" << endl;43 SUPER(TowerDefenseEnemy, tick, dt);44 //orxout() << "TDE tick2" << endl;45 }46 47 40 WeakPtr<TowerDefense> TowerDefenseEnemy::getGame() 48 41 { 49 if (game == NULL)42 if (game == nullptr) 50 43 { 51 for ( ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)52 game = *it;44 for (TowerDefense* towerDefense : ObjectList<TowerDefense>()) 45 game = towerDefense; 53 46 } 54 47 return game; 55 48 } 56 49 57 void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator )50 void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 58 51 { 59 52 Pawn::damage(damage, healthdamage, shielddamage, originator); -
code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
r10629 r11071 37 37 //health gibt es unter: health_ 38 38 39 virtual void tick(float dt); 40 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator); 39 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override; 41 40 42 41 private: -
code/trunk/src/modules/towerdefense/TowerDefenseField.cc
r11052 r11071 49 49 RegisterObject(TowerDefenseField); 50 50 51 tower_ = NULL;52 type_ = FREE;53 center_ = NULL;51 tower_ = nullptr; 52 type_ = TowerDefenseFieldType::FREE; 53 center_ = nullptr; 54 54 upgrade_ = 0; 55 55 setPosition(0,0,0); … … 119 119 bool TowerDefenseField::canUpgrade() 120 120 { 121 if (tower_ != NULL&& upgrade_ < 5)121 if (tower_ != nullptr && upgrade_ < 5) 122 122 { 123 123 return true; … … 129 129 void TowerDefenseField::setAngle(int newAngle) 130 130 { 131 if (modelGround_ != NULL)131 if (modelGround_ != nullptr) 132 132 { 133 133 switch (newAngle) … … 152 152 } 153 153 154 if (modelObject_ != NULL)154 if (modelObject_ != nullptr) 155 155 { 156 156 switch (newAngle) … … 185 185 { 186 186 modelGround_->setMeshSource("TD_F1.mesh"); 187 tower_ = NULL;188 type_ = FREE;187 tower_ = nullptr; 188 type_ = TowerDefenseFieldType::FREE; 189 189 setUpgrade(0); 190 190 setAngle(orientation); … … 194 194 { 195 195 modelGround_->setMeshSource("TD_S5.mesh"); 196 tower_ = NULL;197 type_ = START;196 tower_ = nullptr; 197 type_ = TowerDefenseFieldType::START; 198 198 setUpgrade(0); 199 199 setAngle(orientation); … … 204 204 { 205 205 modelGround_->setMeshSource("TD_S4.mesh"); 206 tower_ = NULL;207 type_ = END;206 tower_ = nullptr; 207 type_ = TowerDefenseFieldType::END; 208 208 setUpgrade(0); 209 209 setAngle(orientation); … … 213 213 { 214 214 modelGround_->setMeshSource("TD_S1.mesh"); 215 tower_ = NULL;216 type_ = STREET;215 tower_ = nullptr; 216 type_ = TowerDefenseFieldType::STREET; 217 217 setUpgrade(0); 218 218 setAngle(orientation); … … 222 222 { 223 223 modelGround_->setMeshSource("TD_S2.mesh"); 224 tower_ = NULL;225 type_ = STREET;224 tower_ = nullptr; 225 type_ = TowerDefenseFieldType::STREET; 226 226 setUpgrade(0); 227 227 setAngle(orientation); … … 231 231 { 232 232 modelGround_->setMeshSource("TD_S3.mesh"); 233 tower_ = NULL;234 type_ = STREET;233 tower_ = nullptr; 234 type_ = TowerDefenseFieldType::STREET; 235 235 setUpgrade(0); 236 236 setAngle(orientation); … … 241 241 modelGround_->setMeshSource("TD_F1.mesh"); 242 242 modelObject_->setMeshSource("TD_O1.mesh"); 243 tower_ = NULL;244 type_ = OBSTACLE;243 tower_ = nullptr; 244 type_ = TowerDefenseFieldType::OBSTACLE; 245 245 setUpgrade(0); 246 246 setAngle(orientation); … … 249 249 void TowerDefenseField::createTower(int upgrade) 250 250 { 251 if (tower_ == NULL)251 if (tower_ == nullptr) 252 252 { 253 253 modelGround_->setMeshSource("TD_F1.mesh"); 254 254 tower_ = new TowerDefenseTower(center_->getContext()); 255 255 attach(tower_); 256 type_ = T OWER;256 type_ = TowerDefenseFieldType::TOWER; 257 257 setUpgrade(upgrade); 258 if (upgrade_ > 0 && modelObject_ != NULL)258 if (upgrade_ > 0 && modelObject_ != nullptr) 259 259 { 260 260 switch (upgrade_) … … 287 287 void TowerDefenseField::destroyTower() 288 288 { 289 if (tower_ != NULL)289 if (tower_ != nullptr) 290 290 { 291 291 tower_->destroy(); 292 tower_ = NULL;292 tower_ = nullptr; 293 293 } 294 294 } -
code/trunk/src/modules/towerdefense/TowerDefenseField.h
r11052 r11071 46 46 namespace orxonox 47 47 { 48 enum TowerDefenseFieldType48 enum class TowerDefenseFieldType 49 49 { 50 50 FREE, … … 62 62 TowerDefenseField(Context* context); 63 63 virtual ~TowerDefenseField() {} 64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;64 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 65 65 const bool isFree() const 66 { return type_== FREE; }66 { return type_==TowerDefenseFieldType::FREE; } 67 67 virtual void create(char object, char param); 68 68 virtual void setCenterpoint(TowerDefenseCenterpoint* center); -
code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
r10629 r11071 39 39 { 40 40 RegisterObject(TowerDefenseHUDController); 41 this->td = 0;41 this->td = nullptr; 42 42 } 43 43 … … 89 89 else 90 90 { 91 this->td = 0;91 this->td = nullptr; 92 92 } 93 93 } -
code/trunk/src/modules/towerdefense/TowerDefenseHUDController.h
r10258 r11071 53 53 54 54 55 virtual void tick(float dt) ;56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;57 virtual void changedOwner() ;55 virtual void tick(float dt) override; 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 57 virtual void changedOwner() override; 58 58 void setShowlives(bool temp) 59 59 { this->showlives = temp; } -
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.cc
r11052 r11071 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h"38 37 #include "graphics/Model.h" 39 38 … … 59 58 { 60 59 61 }62 63 void TowerDefenseSelecter::XMLPort(Element& xmlelement, XMLPort::Mode mode)64 {65 SUPER(TowerDefenseSelecter, XMLPort, xmlelement, mode);66 60 } 67 61 -
code/trunk/src/modules/towerdefense/TowerDefenseSelecter.h
r10629 r11071 41 41 TowerDefenseSelecter(Context* context); //!< Constructor. Registers and initializes the object. 42 42 virtual ~TowerDefenseSelecter(); 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 44 virtual void tick(float dt); 45 virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down. 46 virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down. 47 virtual void rotateYaw(const Vector2& value); 48 virtual void rotatePitch(const Vector2& value); 49 virtual void rotateRoll(const Vector2& value); 43 virtual void tick(float dt) override; 44 virtual void moveFrontBack(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down. 45 virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the bat up and down. 46 virtual void rotateYaw(const Vector2& value) override; 47 virtual void rotatePitch(const Vector2& value) override; 48 virtual void rotateRoll(const Vector2& value) override; 50 49 void fire(unsigned int firemode); 51 virtual void fired(unsigned int firemode) ;52 virtual void boost(bool bBoost) ;50 virtual void fired(unsigned int firemode) override; 51 virtual void boost(bool bBoost) override; 53 52 virtual void setSelectedPosition(TDCoordinate* newPos); 54 53 virtual void setSelectedPosition(int x, int y); -
code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
r11052 r11071 25 25 { 26 26 RegisterObject(TowerDefenseTower); 27 game_ = NULL;28 this->setCollisionType(WorldEntity:: None);27 game_ =nullptr; 28 this->setCollisionType(WorldEntity::CollisionType::None); 29 29 upgrade = 1; 30 30
Note: See TracChangeset
for help on using the changeset viewer.