Changeset 8164 for code/branches/spaceboundaries/src
- Timestamp:
- Mar 31, 2011, 4:12:02 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
r8110 r8164 37 37 /* Eigene, spezifische include-Statements*/ 38 38 #include "worldentities/MobileEntity.h" 39 #include "worldentities/ControllableEntity.h" 39 40 #include "core/ObjectListIterator.h" 41 #include <worldentities/pawns/Pawn.h> 42 #include <infos/PlayerInfo.h> 43 44 #include <OgreTextAreaOverlayElement.h> 45 #include <OgreOverlayManager.h> 46 #include <overlays/OverlayText.h> 40 47 41 48 namespace orxonox … … 46 53 { 47 54 RegisterObject(SpaceBoundaries); 48 55 COUT(0) << "Test ob Konstruktor aufgerufen wird." << std::endl; //!< message for debugging 49 56 // Show Boundaries on the radar. 57 m_pColoredTextAreaOverlayElementFactory = new ColoredTextAreaOverlayElementFactory(); 50 58 } 51 59 SpaceBoundaries::~SpaceBoundaries() 52 60 { 53 61 delete pColoredTextAreaOverlayElementFactory; 54 62 } 55 63 … … 94 102 for(ObjectListIterator<MobileEntity> item = ObjectList<MobileEntity>::begin(); item != ObjectList<MobileEntity>::end(); ++item) 95 103 { 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) 104 MobileEntity* myMobileEntity = *item; 105 Pawn* myItem = dynamic_cast<Pawn*>(myMobileEntity); 106 //COUT(0) << "Die for-Schleife wird erreicht!!!" << std::endl; //!< message for debugging 107 if(myItem != NULL) 98 108 { 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 109 float distance = computeDistance((WorldEntity*) myItem); 110 bool humanItem = this->isHumanPlayer(myItem); 111 COUT(0) << "Pawn wird erkannt!!!" << std::endl; //!< message for debugging 112 COUT(0) << "Distanz:" << distance << std::endl; //!< message for debugging 113 if(distance > this->warnDistance /*&& distance < this->maxDistance*/) 114 { 115 COUT(0) << "You are leaving the area" << std::endl; //!< message for debugging 116 if(humanItem) 117 { 118 COUT(0) << "humanItem ist true" << std::endl; 119 this->displayWarning("Attention! You are leaving the area!"); 120 } else { 121 122 } 123 } else if(distance > maxDistance) 124 { 125 // Decrease Health 126 if(humanItem) 127 { 128 129 } else { 130 131 } 132 } 104 133 } 105 134 } … … 109 138 { 110 139 Vector3 itemPosition = item->getPosition(); 111 return (itemPosition.distance(center)); 112 } 113 114 140 return (itemPosition.distance(this->center)); 141 } 142 143 void SpaceBoundaries::displayWarning(const std::string warnText) 144 { /* 145 Ogre::TextAreaOverlayElement *pTextArea; 146 Ogre::OverlayManager manager = Ogre::OverlayManager(); 147 Ogre::OverlayElement temp = manager.createOverlayElement("TextArea", "MyTextArea"); 148 //pTextArea = (Ogre::TextAreaOverlayElement *) 149 // pTextArea->setCaption("Some plain text"); 150 151 Ogre::TextAreaOverlayElement warning(warnText); 152 warning.initialise(); 153 //warning.setPosition(0.2, 0.2); 154 155 156 COUT(0) << "Breite des Warntextes: " << warning.getWidth() << std::endl; 157 COUT(0) << "Hoehe des Warntextes: " << warning.getHeight() << std::endl; 158 159 warning.show();*/ 160 // Register the overlay element 161 OverlayManager::getSingleton().addOverlayElementFactory(pColoredTextAreaOverlayElementFactory); 162 163 Ogre::TextAreaOverlayElement *pTextArea = 164 (Ogre::TextAreaOverlayElement*)Ogre::OverlayManager.createOverlayElement("TextArea", "MyTextArea"); 165 pTextArea->setCaption("Some plain text"); 166 167 168 } 169 170 bool SpaceBoundaries::isHumanPlayer(Pawn *item) 171 { 172 if(item != NULL) 173 { 174 return item->getPlayer()->isHumanPlayer(); 175 } else { 176 return false; 177 } 178 } 115 179 116 180 -
code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h
r8110 r8164 32 32 /* Folgender Block ist Copy-Paste und somit teilweise wohl unnoetig */ 33 33 #include "OrxonoxPrereqs.h" 34 #include <string>35 34 #include "core/SubclassIdentifier.h" 36 35 … … 40 39 #include "worldentities/StaticEntity.h" 41 40 #include "worldentities/WorldEntity.h" 41 42 #include <ColoredTextAreaOverlayElementFactory.h> 43 44 #include <string> 42 45 43 46 … … 69 72 70 73 float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'center' bezogen. 74 void displayWarning(const std::string warnText); 75 bool isHumanPlayer(Pawn *item); 76 ColoredTextAreaOverlayElementFactory* pColoredTextAreaOverlayElementFactory; 71 77 }; 72 78 }
Note: See TracChangeset
for help on using the changeset viewer.