Changeset 9016 for code/trunk/src/modules
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 21 edited
- 8 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/gametypes/CMakeLists.txt
r8706 r9016 2 2 SpaceRace.cc 3 3 RaceCheckPoint.cc 4 SpaceRaceManager.cc 5 OldSpaceRace.cc 6 OldRaceCheckPoint.cc 4 7 ) 5 8 -
code/trunk/src/modules/gametypes/GametypesPrereqs.h
r8706 r9016 66 66 { 67 67 class SpaceRace; 68 class OldSpaceRace; 68 69 } 69 70 -
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
r8858 r9016 34 34 #include "chat/ChatManager.h" 35 35 36 #include <infos/PlayerInfo.h> 37 #include <worldentities/ControllableEntity.h> 38 36 39 #include "SpaceRace.h" 37 40 … … 39 42 { 40 43 CreateFactory(RaceCheckPoint); 44 45 41 46 42 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): Distance Trigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))47 RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)) 43 48 { 44 49 RegisterObject(RaceCheckPoint); 45 46 this->bCheckpointIndex_ = 0; 47 this->bIsLast_ = false; 50 this->setDistance(100); 51 this->setBeaconMode("off"); 52 this->setBroadcast(false); 53 this->setSimultaneousTriggerers(100); 48 54 this->bTimeLimit_ = 0; 49 55 … … 51 57 this->setRadarObjectShape(RadarViewable::Triangle); 52 58 this->setRadarVisibility(false); 59 this->settingsChanged(); 60 this->reached_=NULL; 61 53 62 } 63 54 64 55 RaceCheckPoint::~RaceCheckPoint() 56 { 57 } 65 RaceCheckPoint::~RaceCheckPoint() 66 { 67 68 } 58 69 59 70 void RaceCheckPoint::tick(float dt) … … 63 74 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 64 75 assert(gametype); 65 if (this->getCheckpointIndex() == gametype->getCheckpointsReached())66 this->setRadarVisibility(true);67 else68 this->setRadarVisibility(false);69 76 } 70 77 … … 72 79 { 73 80 SUPER(RaceCheckPoint, XMLPort, xmlelement, mode); 74 81 Vector3 v= Vector3(0,0,0); 75 82 XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0); 76 83 XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false); 77 84 XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0); 85 XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v); 78 86 } 79 87 80 void RaceCheckPoint:: triggered(bool bIsTriggered)88 void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player) 81 89 { 82 Distance Trigger::triggered(bIsTriggered);83 90 DistanceMultiTrigger::fire((bool)bIsTriggered,player); 91 84 92 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 85 if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered) 86 { 87 gametype->clock_.capture(); 88 float time = gametype->clock_.getSecondsPrecise(); 89 if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) 90 { 91 gametype->timeIsUp(); 92 gametype->end(); 93 } 94 else if (this->getLast()) 95 gametype->end(); 96 else 97 { 98 gametype->newCheckpointReached(); 99 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red. 100 } 101 } 93 assert(gametype); 94 ControllableEntity* entity = (ControllableEntity*) player; 95 96 PlayerInfo* player2 = entity->getPlayer(); 97 98 if(bIsTriggered) 99 this->reached_=player2; 102 100 } 103 101 … … 108 106 { 109 107 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 108 assert(gametype); 110 109 if (gametype) 111 110 { -
code/trunk/src/modules/gametypes/RaceCheckPoint.h
r8767 r9016 32 32 #include "gametypes/GametypesPrereqs.h" 33 33 34 #include "objects/triggers/DistanceTrigger.h" 34 35 36 #include "objects/triggers/DistanceMultiTrigger.h" 35 37 #include "interfaces/RadarViewable.h" 36 38 … … 40 42 @brief 41 43 The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level. 42 !!! Don't forget to control the indexes of your check points and to set one last check point!!!44 Don't forget to control the indexes of your check points and to set one last check point 43 45 */ 44 class _GametypesExport RaceCheckPoint : public Distance Trigger, public RadarViewable46 class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable 45 47 { 46 48 public: … … 50 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 51 53 virtual void tick(float dt); 54 inline void setCheckpointIndex(int checkpointIndex) 55 { this->bCheckpointIndex_ = checkpointIndex; } 56 inline int getCheckpointIndex() 57 { return this->bCheckpointIndex_; } 52 58 53 protected: 54 virtual void triggered(bool bIsTriggered); 59 inline void setNextcheckpoint(const Vector3& checkpoints) 60 { this->nextcheckpoints_=checkpoints; } 61 inline void setNextcheckpoint(float x, float y, float z) 62 { this->setNextcheckpoint(Vector3(x, y, z)); } 63 inline const Vector3& getNextcheckpoint() const 64 { return this->nextcheckpoints_; } 55 65 inline void setLast(bool isLast) 56 66 { this->bIsLast_ = isLast; } 57 67 inline bool getLast() 58 68 { return this->bIsLast_; } 59 inline void setCheckpointIndex(int checkpointIndex) 60 { this->bCheckpointIndex_ = checkpointIndex; } 61 inline int getCheckpointIndex() 62 { return this->bCheckpointIndex_; } 69 70 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 71 float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses. 72 PlayerInfo* reached_; 73 74 inline float getTimeLimit() 75 { return this->bTimeLimit_; } 76 77 protected: 78 virtual void fire(bool bIsTriggered,BaseObject* player); 63 79 virtual void setTimelimit(float timeLimit); 64 inline float getTimeLimit() 65 { return this->bTimeLimit_;} 80 66 81 inline const WorldEntity* getWorldEntity() const 67 82 { return this; } 68 83 69 84 private: 70 int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes. 71 bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level. 72 float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses. 73 85 int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0 86 Vector3 nextcheckpoints_; //the indexes of the next check points 87 74 88 }; 75 89 } -
code/trunk/src/modules/gametypes/SpaceRace.cc
r8858 r9016 29 29 #include "SpaceRace.h" 30 30 31 32 #include "items/Engine.h" 33 31 34 #include "core/CoreIncludes.h" 32 35 #include "chat/ChatManager.h" 33 36 #include "util/Convert.h" 34 37 #include "util/Math.h" 38 39 #include "items/Engine.h" 35 40 36 41 namespace orxonox … … 41 46 { 42 47 RegisterObject(SpaceRace); 43 this->checkpointsReached_ = 0;48 44 49 this->bTimeIsUp_ = false; 45 50 this->numberOfBots_ = 0; 51 this->cantMove_=false; 52 46 53 } 54 55 56 // void SpaceRace::SetConfigValues(){ 57 //SUPER(Gametype,setConfigValues); 58 //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);} 47 59 48 60 void SpaceRace::end() … … 56 68 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 57 69 const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 58 + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1) 59 + " before the time limit. You lose!"; 70 + "You didn't reach the check point before the time limit. You lose!"; 60 71 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 61 72 ChatManager::message(message); … … 70 81 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 71 82 ChatManager::message(message); 72 /* 83 73 84 float time = this->clock_.getSecondsPrecise(); 74 85 this->scores_.insert(time); 75 86 std::set<float>::iterator it; 76 for (it=this->scores_.begin(); it!=this->scores_.end(); it++) 77 orxout(level::message) << multi_cast<std::string>(*it) << endl; 78 */ 87 88 79 89 } 80 90 } … … 82 92 void SpaceRace::start() 83 93 { 84 Gametype::start();85 94 86 std::string message("The match has started! Reach the check points as quickly as possible!"); 95 this->spawnPlayersIfRequested(); 96 Gametype::checkStart(); 97 this->cantMove_=true; 98 99 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 100 { 101 it->setActive(false); 102 103 } 104 this->addBots(this->numberOfBots_); 105 } 106 107 void SpaceRace::tick(float dt) 108 { 109 SUPER(SpaceRace,tick,dt); 110 111 if(!this->isStartCountdownRunning() && this->cantMove_) 112 { 113 for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 114 { 115 it->setActive(true); 116 117 } 118 this->cantMove_= false; 119 120 std::string message("The match has started! Reach the check points as quickly as possible!"); 121 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 122 ChatManager::message(message); 123 } 124 125 } 126 127 128 129 void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl) 130 { 131 this->checkpointReached_[pl]=index; 132 this->clock_.capture(); 133 int s = this->clock_.getSeconds(); 134 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 135 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 136 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 137 + " seconds.";// Message is too long for a normal screen. 87 138 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 88 139 ChatManager::message(message); 89 140 } 90 91 void SpaceRace::newCheckpointReached() 92 { 93 this->checkpointsReached_++; 141 142 void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl) 143 { 144 int index = p->getCheckpointIndex(); 145 this->checkpointReached_[pl]=index; 94 146 this->clock_.capture(); 95 147 int s = this->clock_.getSeconds(); 96 148 int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s); 97 const std::string& message = "Checkpoint " + multi_cast<std::string>( this->getCheckpointsReached())98 99 149 const std::string& message = "Checkpoint " + multi_cast<std::string>(index) 150 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 151 + " seconds."; 100 152 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 101 153 ChatManager::message(message); 102 154 } 155 156 157 void SpaceRace::playerEntered(PlayerInfo* player) 158 { 159 Gametype::playerEntered(player); 160 161 this->checkpointReached_[player]=-1; 162 //this->playersAlive_++; 163 } 164 165 bool SpaceRace::playerLeft(PlayerInfo* player) 166 { 167 return Gametype::playerLeft(player); 168 // bool valid_player = true; 169 //if (valid_player) 170 // { 171 // this->playersAlive_--; 172 //} 103 173 174 // return valid_player; 175 } 176 177 bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator) 178 { 179 return false; 180 } 181 182 bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator) 183 { 184 return false; 185 } 186 187 bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator) 188 { 189 return false; 190 } 104 191 } -
code/trunk/src/modules/gametypes/SpaceRace.h
r8767 r9016 34 34 #include <set> 35 35 #include <string> 36 # include <vector> 36 37 37 38 #include <util/Clock.h> … … 39 40 #include "gametypes/Gametype.h" 40 41 41 #include " RaceCheckPoint.h"42 #include "SpaceRaceManager.h" 42 43 43 44 namespace orxonox … … 50 51 { 51 52 friend class RaceCheckPoint; 53 52 54 53 55 public: … … 58 60 virtual void end(); 59 61 60 virtual void newCheckpointReached(); 62 virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl); 63 virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl); 61 64 62 inline void setCheckpointsReached(int n) 63 { this->checkpointsReached_ = n;} 64 inline int getCheckpointsReached() 65 { return this->checkpointsReached_; } 65 inline void setCheckpointReached(int n, PlayerInfo* p) 66 { this->checkpointReached_[p] = n;} 67 inline int getCheckpointReached(PlayerInfo* p) 68 { return this->checkpointReached_[p]; } 69 66 70 inline void timeIsUp() 67 71 { this->bTimeIsUp_ = true;} 72 void tick(float dt); 73 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 68 74 75 76 bool allowPawnHit(Pawn* victim, Pawn* originator); 77 78 bool allowPawnDamage(Pawn* victim, Pawn* originator); 79 80 bool allowPawnDeath(Pawn* victim, Pawn* originator); 69 81 protected: 70 82 virtual void playerEntered(PlayerInfo* player); //!< Initializes values. 83 virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables. 71 84 private: 72 int checkpointsReached_; //The current number of check points reached by the player. 85 bool cantMove_; 86 std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player. 73 87 std::set<float> scores_; //The times of the players are saved in a set. 74 88 bool bTimeIsUp_; //True if one of the check points is reached too late. 75 Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late. 89 90 int playersAlive_; 76 91 }; 77 92 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r8706 r9016 91 91 @ingroup MultiTrigger 92 92 */ 93 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 93 class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 94 94 { 95 95 -
code/trunk/src/modules/objects/triggers/MultiTrigger.h
r8457 r9016 157 157 bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object. 158 158 159 v oid fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it.159 virtual void fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an Event for the given status and originator and fires it. 160 160 void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target. 161 161 -
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r8706 r9016 7 7 HUDHealthBar.cc 8 8 HUDTimer.cc 9 HUDEnemyHealthBar.cc 9 10 ChatOverlay.cc 10 11 AnnounceMessage.cc -
code/trunk/src/modules/overlays/hud/HUDHealthBar.h
r7401 r9016 110 110 { return this->textoverlay_->getSpaceWidth(); } 111 111 112 inline void setOverlayText(SmartPtr<OverlayText> textoverlay) 113 { this->textoverlay_ = textoverlay; } 114 inline SmartPtr<OverlayText> getOverlayText() const 115 {return this->textoverlay_; } 116 112 117 private: 113 118 WeakPtr<Pawn> owner_; -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r8891 r9016 25 25 * Reto Grieder 26 26 * Oliver Scheuss 27 * Matthias Spalinger 27 28 * 28 29 */ … … 63 64 { 64 65 SetConfigValue(markerLimit_, 3); 65 66 SetConfigValue(showDistance, false); 66 67 } 67 68 … … 75 76 76 77 // Set default values 77 setFont ( "Monofur" );78 setTextSize ( 0.05f );79 setNavMarkerSize ( 0.05f );80 setDetectionLimit( 10000.0f );78 this->setFont ( "Monofur" ); 79 this->setTextSize ( 0.05f ); 80 this->setNavMarkerSize ( 0.05f ); 81 this->setDetectionLimit( 10000.0f ); 81 82 } 82 83 … … 97 98 SUPER ( HUDNavigation, XMLPort, xmlelement, mode ); 98 99 99 XMLPortParam ( HUDNavigation, "font", setFont, getFont,xmlelement, mode );100 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize,xmlelement, mode );101 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize,xmlelement, mode );102 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 100 XMLPortParam ( HUDNavigation, "font", setFont, getFont, xmlelement, mode ); 101 XMLPortParam ( HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode ); 102 XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode ); 103 XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 103 104 } 104 105 … … 144 145 } 145 146 146 147 float HUDNavigation::getArrowSizeX(int dist) 148 { 149 if (dist < 600) 150 dist = 600; 151 return this->getActualSize().x * 900 * navMarkerSize_ / dist; 152 } 153 154 float HUDNavigation::getArrowSizeY(int dist) 155 { 156 if (dist < 600) 157 dist = 600; 158 return this->getActualSize().y * 900 * navMarkerSize_ / dist; 159 } 147 160 148 161 void HUDNavigation::tick ( float dt ) … … 165 178 unsigned int markerCount_ = 0; 166 179 bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player 180 167 181 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) 168 182 for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt ) … … 170 184 ObjectMap::iterator it = activeObjectList_.find ( listIt->first ); 171 185 closeEnough_ = listIt->second < detectionLimit_ ; 172 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) // display on HUD if the statement is true 186 // display radarviewables on HUD if the marker limit and max-distance is not exceeded 187 if ( markerCount_ < markerLimit_ && (closeEnough_ || detectionLimit_ < 0) ) 173 188 { 174 189 … … 176 191 // Get Distance to HumanController and save it in the TextAreaOverlayElement. 177 192 int dist = listIt->second; 193 float textLength = 0.0f; 194 195 //display distance next to cursor 196 if (showDistance){ 178 197 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) ); 179 float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 198 textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f; 199 } 200 201 //display name next to cursor 202 else{ 203 it->second.text_->setCaption(it->first->getRVName()); 204 textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f; 205 } 180 206 181 207 // Transform to screen coordinates … … 194 220 else 195 221 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 196 // Get Distance to HumanController and save it in the TextAreaOverlayElement.197 it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );198 222 199 223 if ( outOfView ) … … 207 231 it->second.wasOutOfView_ = true; 208 232 } 233 234 //float xDistScale = this->getActualSize().x * 1000.0f * navMarkerSize_ / dist; 235 //float yDistScale = this->getActualSize().y * 1000.0f * navMarkerSize_ / dist; 236 237 // Adjust Arrowsize according to distance 238 it->second.panel_->setDimensions(getArrowSizeX(dist),getArrowSizeY(dist)); 209 239 210 240 // Switch between top, bottom, left and right position of the arrow at the screen border … … 263 293 //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" ); 264 294 it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) ); 295 it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y ); 265 296 it->second.wasOutOfView_ = false; 266 297 } … … 280 311 it->second.text_->show(); 281 312 } 282 else // do not display on HUD 313 else // do not display on HUD 283 314 { 284 315 it->second.panel_->hide(); … … 312 343 void HUDNavigation::addObject ( RadarViewable* object ) 313 344 { 314 if( showObject(object) ==false )345 if( showObject(object)==false ) 315 346 return; 316 347 … … 399 430 return false; 400 431 assert( rv->getWorldEntity() ); 401 if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() ==false )432 if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false ) 402 433 return false; 403 434 return true; -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r8891 r9016 24 24 * Co-authors: 25 25 * Reto Grieder 26 * Matthias Spalinger 26 27 * 27 28 */ … … 54 55 virtual void tick ( float dt ); 55 56 57 // RadarListener interface 56 58 virtual void addObject ( RadarViewable* object ); 57 59 virtual void removeObject ( RadarViewable* viewable ); … … 66 68 inline float getRadarSensitivity() const 67 69 { return 1.0f; } 70 71 unsigned int getMarkerLimit() { return this->markerLimit_; } 68 72 69 73 private: … … 81 85 // XMLPort accessors 82 86 void setNavMarkerSize ( float size ) 83 { navMarkerSize_ = size; this->sizeChanged(); }87 { navMarkerSize_ = size; this->sizeChanged(); } 84 88 float getNavMarkerSize() const 85 { return navMarkerSize_; } 86 87 void setDetectionLimit( float limit ) 88 { this->detectionLimit_ = limit; } 89 float getDetectionLimit() const 90 { return this->detectionLimit_; } 89 { return navMarkerSize_; } 90 void setDetectionLimit( float limit ) 91 { this->detectionLimit_ = limit; } 92 float getDetectionLimit() const 93 { return this->detectionLimit_; } 91 94 92 95 void setTextSize ( float size ); … … 102 105 sortedList sortedObjectList_; 103 106 107 float getArrowSizeX(int dist); 108 float getArrowSizeY(int dist); 104 109 105 110 float navMarkerSize_; 106 111 std::string fontName_; 107 112 float textSize_; 113 bool showDistance; 108 114 109 unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting110 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 111 //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite". 115 unsigned int markerLimit_; 116 float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 117 112 118 }; 113 119 } -
code/trunk/src/modules/pong/Pong.cc
r8858 r9016 37 37 #include "core/EventIncludes.h" 38 38 #include "core/command/Executor.h" 39 #include "core/ConfigValueIncludes.h" 39 40 40 41 #include "gamestates/GSLevel.h" 42 #include "chat/ChatManager.h" 41 43 42 44 #include "PongCenterpoint.h" … … 45 47 #include "PongBot.h" 46 48 #include "PongAI.h" 47 48 49 namespace orxonox 49 50 { … … 75 76 // Set the type of Bots for this particular Gametype. 76 77 this->botclass_ = Class(PongBot); 78 this->scoreLimit_ = 10; 79 this->setConfigValues(); 77 80 } 78 81 … … 280 283 } 281 284 285 // If a palyer gets 21 points, he won the game -> end of game 286 287 PlayerInfo* player1 = this->getLeftPlayer(); 288 PlayerInfo* player2 = this->getRightPlayer(); 289 if(player1==NULL||player2==NULL) return; //safety 290 if(this->getScore(player1) >= scoreLimit_) 291 { 292 std::string name1=player1->getName(); 293 std::string message(name1 + " has won!"); 294 ChatManager::message(message); 295 this->end(); 296 } 297 else if(this->getScore(player2) >= scoreLimit_) 298 { 299 std::string name2=player2->getName(); 300 std::string message2(name2 + " has won!"); 301 ChatManager::message(message2); 302 this->end(); 303 } 282 304 // Restart the timer to start the ball. 283 305 this->starttimer_.startTimer(); 306 284 307 } 285 308 … … 321 344 return 0; 322 345 } 346 347 /** 348 @brief 349 Make scoreLimit_ configurable e.g. in the menu. 350 */ 351 void Pong::setConfigValues() 352 { 353 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins."); 354 } 323 355 } -
code/trunk/src/modules/pong/Pong.h
r8351 r9016 81 81 void setCenterpoint(PongCenterpoint* center) 82 82 { this->center_ = center; } 83 84 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 83 void setConfigValues(); //!< Makes scoreLimit configurable. 84 85 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 85 86 PlayerInfo* getRightPlayer() const; //!< Get the right player. 86 87 … … 94 95 WeakPtr<PongBall> ball_; //!< The Pong ball. 95 96 WeakPtr<PongBat> bat_[2]; //!< The two bats. 96 Timer starttimer_; //!< A timer to delay the start of the game. 97 Timer starttimer_; //!< A timer to delay the start of the game. 98 int scoreLimit_; //!< If a player scored that much points, the game is ended. 97 99 }; 98 100 } -
code/trunk/src/modules/pong/PongAI.h
r8108 r9016 80 80 void delayedMove(); //!< Is called, when a delayed move takes effect. 81 81 82 PongBall* ball_; //!< Apointer to the ball.82 WeakPtr<PongBall> ball_; //!< A weak pointer to the ball. 83 83 Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying. 84 84 float ballEndPosition_; //!< The calculated end position of the ball. -
code/trunk/src/modules/pong/PongScore.cc
r8108 r9016 60 60 this->bShowLeftPlayer_ = false; 61 61 this->bShowRightPlayer_ = false; 62 this->player1_ = NULL; 63 this->player2_ = NULL; 62 64 } 63 65 … … 98 100 if (this->owner_ != NULL) 99 101 { 100 // Get the two players. 101 PlayerInfo* player1 = this->owner_->getLeftPlayer(); 102 PlayerInfo* player2 = this->owner_->getRightPlayer(); 103 104 std::string name1; 105 std::string name2; 106 107 std::string score1("0"); 108 std::string score2("0"); 109 110 // Save the name and score of each player as a string. 111 if (player1 != NULL) 102 if(!this->owner_->hasEnded()) 112 103 { 113 name1 = player1->getName(); 114 score1 = multi_cast<std::string>(this->owner_->getScore(player1)); 115 } 116 if (player2 != NULL) 117 { 118 name2 = player2->getName(); 119 score2 = multi_cast<std::string>(this->owner_->getScore(player2)); 104 //get the two players 105 player1_ = this->owner_->getLeftPlayer(); 106 player2_ = this->owner_->getRightPlayer(); 120 107 } 121 108 122 // Assemble the strings, depending on what should all be displayed. 123 std::string output1; 124 if (this->bShowLeftPlayer_) 109 if(this->owner_->hasStarted()) 125 110 { 126 if (this->bShowName_ && this->bShowScore_ && player1 != NULL) 127 output1 = name1 + " - " + score1; 128 else if (this->bShowScore_) 129 output1 = score1; 130 else if (this->bShowName_) 131 output1 = name1; 132 } 111 // Get the two players. 133 112 134 std::string output2; 135 if (this->bShowRightPlayer_) 136 { 137 if (this->bShowName_ && this->bShowScore_ && player2 != NULL) 113 std::string name1; 114 std::string name2; 115 116 std::string score1("0"); 117 std::string score2("0"); 118 119 // Save the name and score of each player as a string. 120 if (player1_ != NULL) 121 { 122 name1 = player1_->getName(); 123 score1 = multi_cast<std::string>(this->owner_->getScore(player1_)); 124 } 125 if (player2_ != NULL) 126 { 127 name2 = player2_->getName(); 128 score2 = multi_cast<std::string>(this->owner_->getScore(player2_)); 129 } 130 131 // Assemble the strings, depending on what should all be displayed. 132 std::string output1; 133 if (this->bShowLeftPlayer_) 134 { 135 if (this->bShowName_ && this->bShowScore_ && player1_ != NULL) 136 output1 = name1 + " - " + score1; 137 else if (this->bShowScore_) 138 output1 = score1; 139 else if (this->bShowName_) 140 output1 = name1; 141 } 142 143 std::string output2; 144 if (this->bShowRightPlayer_) 145 { 146 if (this->bShowName_ && this->bShowScore_ && player2_ != NULL) 138 147 output2 = score2 + " - " + name2; 139 148 else if (this->bShowScore_) … … 143 152 } 144 153 145 std::string output("PONG"); 146 if (this->bShowName_ || this->bShowScore_) 147 { 148 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_) 149 output = output1 + ':' + output2; 150 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_) 151 output = output1 + output2; 154 std::string output("PONG"); 155 if (this->bShowName_ || this->bShowScore_) 156 { 157 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_) 158 output = output1 + ':' + output2; 159 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_) 160 output = output1 + output2; 161 } 162 this->setCaption(output); 152 163 } 153 154 this->setCaption(output);155 164 } 156 165 } -
code/trunk/src/modules/pong/PongScore.h
r8108 r9016 122 122 bool bShowLeftPlayer_; //!< Whether the left player is shown. 123 123 bool bShowRightPlayer_; //!< Whether the right player is shown. 124 PlayerInfo* player1_; //!< Store information about left player permanently. 125 PlayerInfo* player2_; //!< Same for the right player. To end the game properly. 124 126 }; 125 127 } -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r8891 r9016 66 66 this->localAngularVelocity_ = 0; 67 67 this->lifetime_ = 100.0f; 68 this->bIsRocket_= true;69 68 70 69 if (GameMode::isMaster()) … … 135 134 if(this->isInitialized()) 136 135 { 137 this->bIsRocket_= false;138 136 if (GameMode::isMaster()) 139 137 { … … 163 161 164 162 this->player_ = this->getShooter()->getPlayer(); 165 this->getShooter()->getPlayer()->startTemporaryControl(this); 163 if(this->player_) 164 this->player_->startTemporaryControl(this); 166 165 167 166 if( GameMode::isMaster() ) -
code/trunk/src/modules/weapons/projectiles/Rocket.h
r8855 r9016 122 122 123 123 WeakPtr<PlayerInfo> player_; //!< The player that controls the Rocket. 124 //WeakPtr<Pawn> pawn_; //!< The pawn that controls the Rocket. TODO 124 125 Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out. 125 126 float lifetime_; //!< The time the projectile exists. -
code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
r8855 r9016 52 52 this->reloadTime_ = 1.0f; 53 53 this->damage_ = 0.0f; 54 this->speed_ = 250.0f;54 this->speed_ = 700.0f; 55 55 56 56 this->setMunitionName("LaserMunition");
Note: See TracChangeset
for help on using the changeset viewer.