Changeset 8942 for code/branches/gamecontent/src
- Timestamp:
- Nov 18, 2011, 6:52:21 PM (13 years ago)
- Location:
- code/branches/gamecontent/src/orxonox
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamecontent/src/orxonox/controllers/ArtificialController.cc
r8923 r8942 42 42 #include "gametypes/TeamDeathmatch.h" 43 43 #include "gametypes/Dynamicmatch.h" 44 #include "gametypes/Mission.h" 44 45 #include "controllers/WaypointPatrolController.h" 45 46 #include "controllers/NewHumanController.h" … … 996 997 if (entity2->getPlayer()) 997 998 team2 = tdm->getTeam(entity2->getPlayer()); 999 } 1000 1001 Mission* miss = orxonox_cast<Mission*>(gametype); 1002 if (miss) 1003 { 1004 if (entity1->getPlayer()) 1005 team1 = miss->getTeam(entity1->getPlayer()); 1006 1007 if (entity2->getPlayer()) 1008 team2 = miss->getTeam(entity2->getPlayer()); 998 1009 } 999 1010 -
code/branches/gamecontent/src/orxonox/controllers/HumanController.cc
r8858 r8942 195 195 this->boosting_ = true; 196 196 this->boostingTimeout_.startTimer(); 197 198 this->controllableEntity_->boost(this->boosting_);197 if(this->controllableEntity_) 198 this->controllableEntity_->boost(this->boosting_); 199 199 // orxout() << "Start boosting" << endl; 200 200 } … … 209 209 this->boosting_ = false; 210 210 this->boostingTimeout_.stopTimer(); 211 212 this->controllableEntity_->boost(this->boosting_);211 if(this->controllableEntity_) 212 this->controllableEntity_->boost(this->boosting_); 213 213 // orxout() << "Stop boosting" << endl; 214 214 } -
code/branches/gamecontent/src/orxonox/gametypes/Mission.cc
r8941 r8942 90 90 91 91 void Mission::setTeams() 92 { 92 {//Set pawn-colours 93 93 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 94 this->setObjectColour(*it); 94 { 95 Pawn* pawn = static_cast<Pawn*>(*it); 96 if(!pawn) continue; 97 this->setDefaultObjectColour(pawn); 98 } 95 99 } 96 100 -
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
r8941 r8942 35 35 #include "worldentities/TeamSpawnPoint.h" 36 36 #include "worldentities/pawns/Pawn.h" 37 #include "worldentities/ControllableEntity.h" 37 38 #include "controllers/ArtificialController.h" 38 39 … … 117 118 { 118 119 if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow 119 continue;120 //continue; 120 121 if (it->second.state_ == PlayerState::Dead) 121 122 { … … 249 250 if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < static_cast<int>(this->teamcolours_.size())) 250 251 { 251 if (pawn) 252 { 253 pawn->setRadarObjectColour(this->teamcolours_[it_player->second]); 254 255 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 256 for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it) 257 { 258 if ((*it)->isA(Class(TeamColourable))) 259 { 260 TeamColourable* tc = orxonox_cast<TeamColourable*>(*it); 261 tc->setTeamColour(this->teamcolours_[it_player->second]); 262 } 263 } 264 } 265 } 266 } 267 268 void TeamGametype::setObjectColour(Pawn* pawn) 252 this->colourPawn(pawn, it_player->second); 253 } 254 } 255 256 void TeamGametype::setDefaultObjectColour(Pawn* pawn) 269 257 { 270 258 if(pawn == NULL) 271 259 return; 260 261 int teamnumber = pawn->getTeam(); 262 263 if(teamnumber >= 0) 264 { 265 this->colourPawn(pawn, teamnumber); return; 266 } 272 267 //get Pawn's controller 273 ArtificialController* controller = orxonox_cast<ArtificialController*>(pawn); 274 if(controller == NULL) 268 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(pawn); 269 270 Controller* controller = 0; 271 if (entity->getController()) 272 controller = entity->getController(); 273 else if (entity->getXMLController()) 274 controller = entity->getXMLController(); 275 else 275 276 return; 277 278 ArtificialController* artificial = orxonox_cast<ArtificialController*>(controller); 276 279 //get Teamnumber - get the data 277 int teamnumber= controller->getTeam(); 278 if(teamnumber < 0) 280 if(artificial == NULL) 279 281 return; 282 teamnumber= artificial->getTeam(); 283 280 284 //set ObjectColour 281 pawn->setRadarObjectColour(this->teamcolours_[teamnumber]); 285 this->colourPawn(pawn, teamnumber); 286 } 287 288 void TeamGametype::colourPawn(Pawn* pawn, int teamNr) 289 {// catch no-colouring-case and wrong input 290 if(teamNr < 0 || pawn == NULL) return; 291 pawn->setRadarObjectColour(this->teamcolours_[teamNr]); 282 292 283 293 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); … … 287 297 { 288 298 TeamColourable* tc = orxonox_cast<TeamColourable*>(*it); 289 tc->setTeamColour(this->teamcolours_[team number]);299 tc->setTeamColour(this->teamcolours_[teamNr]); 290 300 } 291 301 } 292 302 } 293 303 294 295 304 } -
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
r8941 r8942 75 75 std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'. 76 76 void setTeamColour(PlayerInfo* player, Pawn* pawn); 77 void setObjectColour(Pawn* pawn); 77 void setDefaultObjectColour(Pawn* pawn); 78 void colourPawn(Pawn* pawn, int teamNr); 78 79 }; 79 80 } -
code/branches/gamecontent/src/orxonox/interfaces/CMakeLists.txt
r8706 r8942 6 6 PickupListener.cc 7 7 RadarViewable.cc 8 PartyMember.cc 8 9 ) -
code/branches/gamecontent/src/orxonox/interfaces/PartyMember.h
r8907 r8942 52 52 public: 53 53 PartyMember(); 54 virtual ~PartyMember() {}54 virtual ~PartyMember(); 55 55 56 56 /** -
code/branches/gamecontent/src/orxonox/worldentities/pawns/Pawn.cc
r8904 r8942 60 60 this->bReload_ = false; 61 61 62 this->team_ = -1; 62 63 this->health_ = 0; 63 64 this->maxHealth_ = 0; … … 110 111 SUPER(Pawn, XMLPort, xmlelement, mode); 111 112 113 XMLPortParam(Pawn, "team", setTeam, getTeam, xmlelement, mode).defaultValues(-1); 114 112 115 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 113 116 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); … … 129 132 XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0); 130 133 XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 134 135 131 136 } 132 137 -
code/branches/gamecontent/src/orxonox/worldentities/pawns/Pawn.h
r8891 r8942 35 35 #include "interfaces/PickupCarrier.h" 36 36 #include "interfaces/RadarViewable.h" 37 #include "interfaces/PartyMember.h" 37 38 #include "worldentities/ControllableEntity.h" 38 39 … … 40 41 { // tolua_export 41 42 class _OrxonoxExport Pawn // tolua_export 42 : public ControllableEntity, public RadarViewable, public PickupCarrier 43 : public ControllableEntity, public RadarViewable, public PickupCarrier//, public PartyMember 43 44 { // tolua_export 44 45 friend class WeaponSystem; … … 53 54 inline bool isAlive() const 54 55 { return this->bAlive_; } 56 57 inline void setTeam(int team) 58 { this->team_ = team; } 59 inline float getTeam() const 60 { return this->team_; } 55 61 56 62 virtual void setHealth(float health); … … 194 200 { return NULL; } 195 201 202 int team_; 203 196 204 float health_; 197 205 float maxHealth_;
Note: See TracChangeset
for help on using the changeset viewer.