Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8164


Ignore:
Timestamp:
Mar 31, 2011, 4:12:02 PM (13 years ago)
Author:
kmaurus
Message:

Es wird nun erkannt, wenn das Spaceship sich zu weit entfernt. Meldung wird noch nicht angezeigt.

Location:
code/branches/spaceboundaries/src/orxonox/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.cc

    r8110 r8164  
    3737/* Eigene, spezifische include-Statements*/
    3838#include "worldentities/MobileEntity.h"
     39#include "worldentities/ControllableEntity.h"
    3940#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>
    4047
    4148namespace orxonox
     
    4653    {
    4754        RegisterObject(SpaceBoundaries);
    48        
     55        COUT(0) << "Test ob Konstruktor aufgerufen wird." << std::endl; //!< message for debugging
    4956        // Show Boundaries on the radar.
     57         m_pColoredTextAreaOverlayElementFactory = new ColoredTextAreaOverlayElementFactory();
    5058    }
    5159    SpaceBoundaries::~SpaceBoundaries()
    5260    {
    53    
     61        delete pColoredTextAreaOverlayElementFactory;
    5462    }
    5563   
     
    94102        for(ObjectListIterator<MobileEntity> item = ObjectList<MobileEntity>::begin(); item != ObjectList<MobileEntity>::end(); ++item)
    95103        {
    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)
    98108            {
    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                }
    104133            }
    105134        }
     
    109138    {
    110139        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    }
    115179   
    116180   
  • code/branches/spaceboundaries/src/orxonox/worldentities/SpaceBoundaries.h

    r8110 r8164  
    3232/* Folgender Block ist Copy-Paste und somit teilweise wohl unnoetig */
    3333#include "OrxonoxPrereqs.h"
    34 #include <string>
    3534#include "core/SubclassIdentifier.h"
    3635
     
    4039#include "worldentities/StaticEntity.h"
    4140#include "worldentities/WorldEntity.h"
     41
     42#include <ColoredTextAreaOverlayElementFactory.h>
     43
     44#include <string>
    4245
    4346
     
    6972       
    7073            float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'center' bezogen.
     74            void displayWarning(const std::string warnText);
     75            bool isHumanPlayer(Pawn *item);
     76            ColoredTextAreaOverlayElementFactory* pColoredTextAreaOverlayElementFactory;
    7177    };
    7278}
Note: See TracChangeset for help on using the changeset viewer.