- Timestamp:
- Apr 21, 2011, 4:16:29 PM (13 years ago)
- File:
-
- 1 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);
Note: See TracChangeset
for help on using the changeset viewer.