Changeset 8281 for code/branches/spaceboundaries
- Timestamp:
- Apr 21, 2011, 4:16:29 PM (14 years ago)
- Location:
- code/branches/spaceboundaries/src/orxonox/worldentities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc
r8279 r8281 74 74 } 75 75 76 this->pawnsIn_.clear(); 77 76 78 // delete pColoredTextAreaOverlayElementFactory; 79 } 80 81 void SpaceBoundaries::checkWhoIsIn() 82 { 83 pawnsIn_.clear(); 84 for(ObjectListIterator<Pawn> current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current) 85 { 86 Pawn* currentPawn = *current; 87 float distance = this->computeDistance(currentPawn); 88 if(distance <= this->maxDistance_) 89 { 90 pawnsIn_.push_back(currentPawn); 91 } 92 } 77 93 } 78 94 … … 124 140 void SpaceBoundaries::tick(float dt) 125 141 { 126 for(ObjectListIterator<MobileEntity> item = ObjectList<MobileEntity>::begin(); item != ObjectList<MobileEntity>::end(); ++item) 127 { 128 MobileEntity* myMobileEntity = *item; 129 Pawn* currentPawn = dynamic_cast<Pawn*>(myMobileEntity); 130 if(currentPawn != NULL) 131 { 132 float distance = this->computeDistance(currentPawn); 133 bool humanItem = this->isHumanPlayer(currentPawn); 134 COUT(0) << "Distanz:" << distance << std::endl; //!< message for debugging 135 if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an! 142 143 COUT(0) << "Groesse der Liste: " << (int) pawnsIn_.size() << std::endl; 144 145 //for(ObjectListIterator<Pawn> current = ObjectList<Pawn>::begin(); current != ObjectList<Pawn>::end(); ++current) 146 for( std::list<Pawn*>::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ ) 147 { 148 Pawn* currentPawn = *current; 149 float distance = this->computeDistance(currentPawn); 150 bool humanItem = this->isHumanPlayer(currentPawn); 151 COUT(0) << "Distanz:" << distance << std::endl; //!< message for debugging 152 if(distance > this->warnDistance_ && distance < this->maxDistance_) // Zeige Warnung an! 153 { 154 COUT(0) << "You are leaving the area" << std::endl; //!< message for debugging 155 if(humanItem) 136 156 { 137 COUT(0) << "You are leaving the area" << std::endl; //!< message for debugging 138 if(humanItem) 139 { 140 COUT(0) << "humanItem ist true" << std::endl; 141 this->displayWarning("Attention! You are leaving the area!"); 142 } else { 143 144 } 157 COUT(0) << "humanItem ist true" << std::endl; 158 this->displayWarning("Attention! You are leaving the area!"); 159 } else { 160 145 161 } 146 if( (this->maxDistance_ - distance) < this->showDistance_) 162 } 163 if( (this->maxDistance_ - distance) < this->showDistance_) 164 { 165 // Zeige Grenze an! 166 this->displayBoundaries(currentPawn); 167 } 168 if(distance > this->maxDistance_) 169 { 170 if(humanItem) 147 171 { 148 // Zeige Grenze an! 149 this->displayBoundaries(currentPawn); 172 COUT(0) << "Health should be decreasing!" << std::endl; 173 this->displayWarning("You are out of the area now!"); 174 currentPawn->removeHealth( (distance - maxDistance_) * this->healthDecrease_); 175 } else { 176 150 177 } 151 if(distance > this->maxDistance_) 152 { 153 if(humanItem) 154 { 155 COUT(0) << "Health should be decreasing!" << std::endl; 156 this->displayWarning("You are out of the area now!"); 157 currentPawn->removeHealth( (distance - maxDistance_) * this->healthDecrease_); 158 } else { 159 160 } 161 162 this->bounceBack(currentPawn); 163 } 164 } 165 } 178 179 this->bounceBack(currentPawn); 180 } 181 } 182 this->checkWhoIsIn(); 166 183 } 167 184 … … 242 259 243 260 item->lookAt( velocity + this->getPosition() ); 244 261 245 262 item->setAcceleration(acceleration * dampingFactor); 246 263 item->setVelocity(velocity * dampingFactor); -
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h
r8244 r8281 27 27 */ 28 28 29 /* TODO: - Markiere SpaceBoundaries-Position mit einem schoenen Objekt 30 - Reflexion an Grenze mit Quaternionen machen (--> vgl. Funktion bounceBack() ) 29 /* TODO: - Mehrere SpaceBoundaries-Instanzen pro Level ermoeglichen 30 - Pro Pawn ein Billboard verwenden 31 */ 32 33 34 /* REALISIERUNGSIDEEN: 35 36 Mehrere Instanzen: 37 Im Konstruktor schauen, wer innerhalb der eigenen Grenzen ist und diese in eine Liste geben, die in jeder tick-Funktion 38 durchgearbeitet wird. 39 Moeglichkeit bereitstellen, ein Pawn durch ein Portal einer anderen Instanz von SpaceBoundaries zuzuweisen. 40 Schauen, wie es zu handhaben ist, wenn ein neuer Spieler oder Bot nachtraeglich ins Spiel kommt. 41 31 42 */ 32 43 … … 44 55 45 56 #include <string> 57 #include <list> 46 58 47 59 /** … … 66 78 ~SpaceBoundaries(); 67 79 80 void checkWhoIsIn(); 81 68 82 void setMaxDistance(float r); 69 83 float getMaxDistance(); … … 83 97 84 98 private: 99 std::list<Pawn*> pawnsIn_; 100 85 101 float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'. 86 102 float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst.
Note: See TracChangeset
for help on using the changeset viewer.