Changeset 8110 for code/branches/spaceboundaries
- Timestamp:
- Mar 24, 2011, 4:16:54 PM (14 years ago)
- Location:
- code/branches/spaceboundaries/src/orxonox/worldentities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceboundaries/src/orxonox/worldentities/CMakeLists.txt
r7163 r8110 12 12 SpawnPoint.cc 13 13 TeamSpawnPoint.cc 14 SpaceBoundaries.cc 14 15 ) 15 16 -
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 } -
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h
r8087 r8110 34 34 #include <string> 35 35 #include "core/SubclassIdentifier.h" 36 #include "worldentities/StaticEntity.h"37 36 38 37 /* Einige, spezifische include-Statements */ 39 38 #include "core/CoreIncludes.h" 39 #include "tools/interfaces/Tickable.h" 40 #include "worldentities/StaticEntity.h" 41 #include "worldentities/WorldEntity.h" 40 42 41 43 … … 46 48 public: 47 49 SpaceBoundaries(BaseObject* creator); 48 virtual ~SpaceBoundaries() {} 50 ~SpaceBoundaries(); 51 52 void setCenter(Vector3 r); 53 Vector3 getCenter(); 54 55 void setMaxDistance(float r); 56 float getMaxDistance(); 57 58 void setWarnDistance(float r); 59 float getWarnDistance(); 49 60 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 61 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 62 63 void tick(float dt); 51 64 52 65 private: 66 Vector3 center; 67 float maxDistance; 68 float warnDistance; 53 69 70 float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'center' bezogen. 54 71 }; 55 72 }
Note: See TracChangeset
for help on using the changeset viewer.