Changeset 8468 for code/branches/spaceboundaries2/src
- Timestamp:
- May 12, 2011, 4:36:30 PM (14 years ago)
- Location:
- code/branches/spaceboundaries2/src/orxonox/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.cc
r8458 r8468 47 47 * falls im XML-File keine Werte spezifiziert wurden. */ 48 48 this->setMaxDistance(3000); 49 this->setWarnDistance(2000); 50 this->setShowDistance(2500); 51 this->setHealthDecrease(1); 49 this->setWarnDistance(this->getMaxDistance()); 50 this->setShowDistance(this->getMaxDistance()); 52 51 this->setReaction(0); 53 52 … … 81 80 { 82 81 Pawn* currentPawn = *current; 83 float distance = this->computeDistance(currentPawn); 84 if(distance <= this->maxDistance_) 85 { 82 if( this->reaction_ == 0 ) 83 { 84 float distance = this->computeDistance(currentPawn); 85 if(distance <= this->maxDistance_) 86 { 87 pawnsIn_.push_back(currentPawn); 88 } 89 } else { 86 90 pawnsIn_.push_back(currentPawn); 87 91 } … … 183 187 XMLPortParam(SpaceBoundaries, "maxDistance", setMaxDistance, getMaxDistance, xmlelement, mode); 184 188 XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode); 189 XMLPortParam(SpaceBoundaries, "showDistance", setShowDistance, getShowDistance, xmlelement, mode); 185 190 XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode); 186 191 XMLPortParam(SpaceBoundaries, "reactionMode", setReaction, getReaction, xmlelement, mode); … … 191 196 this->checkWhoIsIn(); 192 197 this->removeAllBillboards(); 193 COUT( 0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl;198 COUT(4) << "Groesse der Pawn-Liste 'SpaceBoundaries::pawnsIn_': " << (int) pawnsIn_.size() << std::endl; 194 199 195 200 float distance; … … 202 207 distance = this->computeDistance(currentPawn); 203 208 humanItem = this->isHumanPlayer(currentPawn); 204 COUT( 0) << "Distanz:" << distance << std::endl; // message for debugging209 COUT(5) << "Distanz:" << distance << std::endl; // message for debugging 205 210 if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an! 206 211 { 207 COUT(0) << "You are near by the boundaries!" << std::endl; // message for debugging208 212 if(humanItem) 209 213 { 210 COUT( 0) << "humanItem ist true" << std::endl;211 this->displayWarning("Attention! You are near by the boundaries!");214 COUT(5) << "humanItem ist true" << std::endl; 215 this->displayWarning("Attention! You are close to the boundary!"); 212 216 } 213 217 } 214 if( (this->maxDistance_ - distance) < this->showDistance_ )218 if( humanItem && (this->maxDistance_ - distance) < this->showDistance_ ) 215 219 { 216 220 this->displayBoundaries(currentPawn); // Zeige Grenze an! … … 220 224 if( humanItem ) 221 225 { 222 COUT( 0) << "Health should be decreasing!" << std::endl;226 COUT(5) << "Health should be decreasing!" << std::endl; 223 227 this->displayWarning("You are out of the area now!"); 224 228 } … … 269 273 /* Checke, ob das Pawn innerhalb des nächsten Ticks, das erlaubte Gebiet verlassen würde. 270 274 Falls ja: Spicke es zurück. */ 271 if( currentDistance + normalSpeed * dt > this->maxDistance_ )275 if( currentDistance + normalSpeed * dt > this->maxDistance_ - 10 ) // -10: "security measure" 272 276 { 273 277 float dampingFactor = 0.5; -
code/branches/spaceboundaries2/src/orxonox/worldentities/SpaceBoundaries.h
r8458 r8468 31 31 (file:///home/kmaurus/orxonox/spaceBoundaries/build/doc/api/html/classorxonox_1_1_host.html#9c1e3b39e3b42e467dfbf42902911ce2) 32 32 33 - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h') 34 35 - Wiki-SpaceBoundaries-Eintrag aktualisieren 33 Mich finde ich unter humanPlayer ... 34 35 - Kommentieren (Betrachte als Beispiel/Vorbild 'libraries/core/WeakPtr.h') 36 oder brauche groups-file. 36 37 */ 37 38 … … 58 59 @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area (until now this area is a ball). 59 60 60 Five attributes can/should be defined in the XML-File: 61 Some attributes can/should be defined in the XML-File: 62 - 'position' : absolute position of the object of SpaceBoundaries in the level (usually 0,0,0) 63 - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball). 61 64 - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to 62 65 inform the player that he'll soon be leaving the allowed area. 63 - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball).64 66 - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. 65 - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0).66 Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease)67 67 - 'reactionMode' : Integer-Value. Defines what effect appears if a space ship has crossed the boundaries. 68 68 0: Reflect the space ship (default). 69 69 1: Decrease Health of the space ship after having left the allowed area. 70 - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area (unnecessary if 'reactionMode' == 0). 71 Recommended values: 0.1 (slow health decrease) to 5 (very fast health decrease) 72 73 Follow http://www.orxonox.net/wiki/SpaceBoundaries to get some further information. 74 75 Examples: 76 Two examples how one could include SpaceBoundaries in the XML-File. The first one uses reflection, the second one health decrease. 77 @code 78 <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="0" /> 79 @endcode 80 81 @code 82 <SpaceBoundaries position="0,0,0" maxDistance="1000" warnDistance="800" showDistance="100" reactionMode="1" healthDecrease="0.2" /> 83 @endcode 70 84 */ 71 85
Note: See TracChangeset
for help on using the changeset viewer.