- Timestamp:
- Mar 24, 2011, 4:16:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc
r8087 r8110 30 30 31 31 /* Folgender Block ist Copy-Paste und somit teilweise wohl unnoetig */ 32 #include "core/CoreIncludes.h"33 32 #include "core/Template.h" 34 33 #include "core/XMLPort.h" … … 37 36 38 37 /* Eigene, spezifische include-Statements*/ 38 #include "worldentities/MobileEntity.h" 39 #include "core/ObjectListIterator.h" 39 40 40 41 namespace orxonox … … 45 46 { 46 47 RegisterObject(SpaceBoundaries); 48 49 // Show Boundaries on the radar. 47 50 } 48 49 51 SpaceBoundaries::~SpaceBoundaries() 50 52 { 51 53 52 54 } 55 56 void SpaceBoundaries::setCenter(Vector3 r) 57 { 58 this->center = r; 59 } 60 Vector3 SpaceBoundaries::getCenter() 61 { 62 return this->center; 63 } 64 65 void SpaceBoundaries::setMaxDistance(float r) 66 { 67 this->maxDistance = r; 68 } 69 float SpaceBoundaries::getMaxDistance() 70 { 71 return this->maxDistance; 72 } 73 74 void SpaceBoundaries::setWarnDistance(float r) 75 { 76 this->warnDistance = r; 77 } 78 float SpaceBoundaries::getWarnDistance() 79 { 80 return this->warnDistance; 81 } 53 82 54 83 void SpaceBoundaries::XMLPort(Element& xmlelement, XMLPort::Mode mode) 55 84 { 56 //SUPER(SpaceBoundaries, XMLPort, xmlelement, mode);85 SUPER(SpaceBoundaries, XMLPort, xmlelement, mode); 57 86 58 // XMLPortParam(SpaceBoundaries, "spawnclass", setSpawnClassName, getSpawnClassName, xmlelement, mode); 59 // XMLPortParam(SpaceBoundaries, "pawndesign", setTemplateName, getTemplateName, xmlelement, mode); 87 XMLPortParam(SpaceBoundaries, "center", setCenter, getCenter, xmlelement, mode); 88 XMLPortParam(SpaceBoundaries, "maxDistance", setMaxDistance, getMaxDistance, xmlelement, mode); 89 XMLPortParam(SpaceBoundaries, "warnDistance", setWarnDistance, getWarnDistance, xmlelement, mode); 60 90 } 91 92 void SpaceBoundaries::tick(float dt) 93 { 94 for(ObjectListIterator<MobileEntity> item = ObjectList<MobileEntity>::begin(); item != ObjectList<MobileEntity>::end(); ++item) 95 { 96 float distance = computeDistance((WorldEntity *)&item); // fuer casts gibt's scheinbar andere, neuere Variante --> vgl. Coding-Guide und andere Files 97 if(distance > this->warnDistance && distance < this->maxDistance) 98 { 99 COUT(0) << "You are leaving the area" << std::endl; //!< message for debugging 100 // Display Warning on Screen if the humanPlayer (infos/PlayerInfo.h) is leaving the area 101 } else if(distance > maxDistance) 102 { 103 // Decrease Health 104 } 105 } 106 } 107 108 float SpaceBoundaries::computeDistance(WorldEntity *item) 109 { 110 Vector3 itemPosition = item->getPosition(); 111 return (itemPosition.distance(center)); 112 } 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 61 138 }
Note: See TracChangeset
for help on using the changeset viewer.