- Timestamp:
- Apr 7, 2011, 4:11:20 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc
r8166 r8201 29 29 #include "SpaceBoundaries.h" 30 30 31 /* Folgender Block ist Copy-Paste und somit teilweise wohl unnoetig */32 #include "core/Template.h"33 #include "core/XMLPort.h"34 #include "gametypes/Gametype.h"35 #include "worldentities/pawns/Pawn.h"36 37 /* Eigene, spezifische include-Statements*/38 31 #include "worldentities/MobileEntity.h" 39 32 #include "worldentities/ControllableEntity.h" 40 33 #include "core/ObjectListIterator.h" 41 #include <worldentities/pawns/Pawn.h> 42 #include <infos/PlayerInfo.h> 34 #include "core/XMLPort.h" 35 #include "worldentities/pawns/Pawn.h" 36 #include "infos/PlayerInfo.h" 37 #include "interfaces/RadarViewable.h" 38 43 39 44 40 //#include <OgreTextAreaOverlayElement.h> … … 52 48 SpaceBoundaries::SpaceBoundaries(BaseObject* creator) : StaticEntity(creator) 53 49 { 50 /* Standardwerte, die zum Tragen kommen, 51 * falls im XML-File keine Werte spezifiziert wurden. */ 52 this->setMaxDistance(3000); 53 this->setWarnDistance(2000); 54 this->setHealthDecrease(1); 55 54 56 RegisterObject(SpaceBoundaries); 55 COUT(0) << "Test ob Konstruktor aufgerufen wird." << std::endl; //!< message for debugging57 56 58 // Show Boundaries on the radar. 59 this->centerRadar_ = new RadarViewable(this, this); 60 this->centerRadar_->setRadarObjectShape(RadarViewable::Dot); 61 this->centerRadar_->setRadarVisibility(false); 62 57 63 // m_pColoredTextAreaOverlayElementFactory = new ColoredTextAreaOverlayElementFactory(); 58 64 } 59 65 SpaceBoundaries::~SpaceBoundaries() 60 66 { 67 delete this->centerRadar_; 61 68 // delete pColoredTextAreaOverlayElementFactory; 62 }63 64 void SpaceBoundaries::setCenter(Vector3 r)65 {66 this->center_ = r;67 }68 Vector3 SpaceBoundaries::getCenter()69 {70 return this->center_;71 69 } 72 70 … … 88 86 return this->warnDistance_; 89 87 } 88 89 void SpaceBoundaries::setHealthDecrease(float amount) 90 { 91 this->healthDecrease_ = amount/1000; 92 } 93 float SpaceBoundaries::getHealthDecrease() 94 { 95 return this->healthDecrease_; 96 } 90 97 91 98 void SpaceBoundaries::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 93 100 SUPER(SpaceBoundaries, XMLPort, xmlelement, mode); 94 101 95 XMLPortParam(SpaceBoundaries, "center", setCenter, getCenter, xmlelement, mode);96 102 XMLPortParam(SpaceBoundaries, "maxDistance", setMaxDistance, getMaxDistance, xmlelement, mode); 97 103 XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode); 104 XMLPortParam(SpaceBoundaries, "healthDecrease", setHealthDecrease, getHealthDecrease, xmlelement, mode); 98 105 } 99 106 … … 104 111 MobileEntity* myMobileEntity = *item; 105 112 Pawn* myItem = dynamic_cast<Pawn*>(myMobileEntity); 106 //COUT(0) << "Die for-Schleife wird erreicht!!!" << std::endl; //!< message for debugging107 113 if(myItem != NULL) 108 114 { 109 115 float distance = computeDistance((WorldEntity*) myItem); 110 116 bool humanItem = this->isHumanPlayer(myItem); 111 COUT(0) << "Pawn wird erkannt!!!" << std::endl; //!< message for debugging112 117 COUT(0) << "Distanz:" << distance << std::endl; //!< message for debugging 113 if(distance > this->warnDistance_ /*&& distance < this->maxDistance*/)118 if(distance > this->warnDistance_ && distance < this->maxDistance_) 114 119 { 115 120 COUT(0) << "You are leaving the area" << std::endl; //!< message for debugging … … 119 124 this->displayWarning("Attention! You are leaving the area!"); 120 125 } else { 121 126 122 127 } 123 } else if(distance > maxDistance_) 128 } 129 if(distance > maxDistance_) 124 130 { 125 // Decrease Health126 131 if(humanItem) 127 132 { 133 COUT(0) << "Health should be decreasing!" << std::endl; 134 this->displayWarning("You are out of the area now!"); 135 myItem->removeHealth( (distance - maxDistance_) * this->healthDecrease_); 136 } else { 128 137 129 } else {130 131 138 } 132 139 } … … 138 145 { 139 146 Vector3 itemPosition = item->getPosition(); 140 return (itemPosition.distance(this-> center_));147 return (itemPosition.distance(this->getPosition())); 141 148 } 142 149 … … 172 179 if(item != NULL) 173 180 { 174 return item->getPlayer()->isHumanPlayer(); 175 } else { 176 return false; 181 if(item->getPlayer()) 182 { 183 return item->getPlayer()->isHumanPlayer(); 184 } 177 185 } 186 return false; 178 187 } 179 188 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 189 }
Note: See TracChangeset
for help on using the changeset viewer.