Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2012, 11:51:58 PM (12 years ago)
Author:
jo
Message:

Merging presentation2011 branch to trunk. Please check for possible bugs.

Location:
code/trunk
Files:
21 edited
8 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/gametypes/CMakeLists.txt

    r8706 r9016  
    22  SpaceRace.cc
    33  RaceCheckPoint.cc
     4  SpaceRaceManager.cc
     5  OldSpaceRace.cc
     6  OldRaceCheckPoint.cc
    47)
    58
  • code/trunk/src/modules/gametypes/GametypesPrereqs.h

    r8706 r9016  
    6666{
    6767    class SpaceRace;
     68    class OldSpaceRace;
    6869}
    6970
  • code/trunk/src/modules/gametypes/RaceCheckPoint.cc

    r8858 r9016  
    3434#include "chat/ChatManager.h"
    3535
     36#include <infos/PlayerInfo.h>
     37#include <worldentities/ControllableEntity.h>
     38
    3639#include "SpaceRace.h"
    3740
     
    3942{
    4043    CreateFactory(RaceCheckPoint);
     44   
     45     
    4146
    42     RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
     47    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
    4348    {
    4449        RegisterObject(RaceCheckPoint);
    45 
    46         this->bCheckpointIndex_ = 0;
    47         this->bIsLast_ = false;
     50        this->setDistance(100);
     51        this->setBeaconMode("off");
     52        this->setBroadcast(false);
     53        this->setSimultaneousTriggerers(100);
    4854        this->bTimeLimit_ = 0;
    4955
     
    5157        this->setRadarObjectShape(RadarViewable::Triangle);
    5258        this->setRadarVisibility(false);
     59        this->settingsChanged();
     60        this->reached_=NULL;
     61     
    5362    }
     63   
    5464
    55     RaceCheckPoint::~RaceCheckPoint()
    56     {
    57     }
     65   RaceCheckPoint::~RaceCheckPoint()
     66   {
     67   
     68   }
    5869
    5970    void RaceCheckPoint::tick(float dt)
     
    6374        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    6475        assert(gametype);
    65         if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
    66             this->setRadarVisibility(true);
    67         else
    68             this->setRadarVisibility(false);
    6976    }
    7077
     
    7279    {
    7380        SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
    74 
     81        Vector3 v= Vector3(0,0,0);
    7582        XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
    7683        XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
    7784        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
     85    XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
    7886    }
    7987
    80     void RaceCheckPoint::triggered(bool bIsTriggered)
     88    void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
    8189    {
    82         DistanceTrigger::triggered(bIsTriggered);
    83 
     90        DistanceMultiTrigger::fire((bool)bIsTriggered,player);
     91       
    8492        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    85         if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
    86         {
    87             gametype->clock_.capture();
    88             float time = gametype->clock_.getSecondsPrecise();
    89             if (this->bTimeLimit_!=0 && time > this->bTimeLimit_)
    90             {
    91                 gametype->timeIsUp();
    92                 gametype->end();
    93             }
    94             else if (this->getLast())
    95                 gametype->end();
    96             else
    97             {
    98                 gametype->newCheckpointReached();
    99                 this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
    100             }
    101         }
     93        assert(gametype);
     94        ControllableEntity* entity = (ControllableEntity*) player;
     95     
     96        PlayerInfo* player2 = entity->getPlayer();
     97     
     98        if(bIsTriggered)
     99            this->reached_=player2;
    102100    }
    103101
     
    108106        {
    109107            SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     108            assert(gametype);
    110109            if (gametype)
    111110            {
  • code/trunk/src/modules/gametypes/RaceCheckPoint.h

    r8767 r9016  
    3232#include "gametypes/GametypesPrereqs.h"
    3333
    34 #include "objects/triggers/DistanceTrigger.h"
     34
     35
     36#include "objects/triggers/DistanceMultiTrigger.h"
    3537#include "interfaces/RadarViewable.h"
    3638
     
    4042    @brief
    4143        The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
    42         !!! Don't forget to control the indexes of your check points and to set one last check point!!!
     44         Don't forget to control the indexes of your check points and to set one last check point
    4345    */
    44     class _GametypesExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
     46    class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
    4547    {
    4648        public:
     
    5052            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5153            virtual void tick(float dt);
     54            inline void setCheckpointIndex(int checkpointIndex)
     55                { this->bCheckpointIndex_ = checkpointIndex; }
     56            inline int getCheckpointIndex()
     57                { return this->bCheckpointIndex_; }
    5258
    53             protected:
    54             virtual void triggered(bool bIsTriggered);
     59            inline void setNextcheckpoint(const Vector3& checkpoints)
     60                { this->nextcheckpoints_=checkpoints; }
     61            inline void setNextcheckpoint(float x, float y, float z)
     62                { this->setNextcheckpoint(Vector3(x, y, z)); }
     63            inline const Vector3& getNextcheckpoint() const
     64                { return this->nextcheckpoints_; }
    5565            inline void setLast(bool isLast)
    5666                { this->bIsLast_ = isLast; }
    5767            inline bool getLast()
    5868                { return this->bIsLast_; }
    59             inline void setCheckpointIndex(int checkpointIndex)
    60                 { this->bCheckpointIndex_ = checkpointIndex; }
    61             inline int getCheckpointIndex()
    62                 { return this->bCheckpointIndex_; }
     69
     70            bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
     71            float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
     72            PlayerInfo* reached_;
     73               
     74            inline float getTimeLimit()
     75                { return this->bTimeLimit_; }
     76   
     77        protected:
     78            virtual void fire(bool bIsTriggered,BaseObject* player);
    6379            virtual void setTimelimit(float timeLimit);
    64             inline float getTimeLimit()
    65                 { return this->bTimeLimit_;}
     80           
    6681            inline const WorldEntity* getWorldEntity() const
    6782                { return this; }
    6883
    6984        private:
    70             int bCheckpointIndex_; //The index of this check point. This value will be compared with the number of check points reached in the level. The check points must be indexed in ascending order beginning from zero and without any jumps between the indexes.
    71             bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
    72             float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
    73      
     85            int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0
     86            Vector3 nextcheckpoints_; //the indexes of the next check points
     87           
    7488    };
    7589}
  • code/trunk/src/modules/gametypes/SpaceRace.cc

    r8858 r9016  
    2929#include "SpaceRace.h"
    3030
     31
     32#include "items/Engine.h"
     33
    3134#include "core/CoreIncludes.h"
    3235#include "chat/ChatManager.h"
    3336#include "util/Convert.h"
    3437#include "util/Math.h"
     38
     39#include "items/Engine.h"
    3540
    3641namespace orxonox
     
    4146    {
    4247        RegisterObject(SpaceRace);
    43         this->checkpointsReached_ = 0;
     48       
    4449        this->bTimeIsUp_ = false;
    4550        this->numberOfBots_ = 0;
     51        this->cantMove_=false;
     52       
    4653    }
     54       
     55   
     56  // void SpaceRace::SetConfigValues(){
     57    //SUPER(Gametype,setConfigValues);
     58    //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}
    4759
    4860    void SpaceRace::end()
     
    5668            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    5769            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
    58                         + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
    59                         + " before the time limit. You lose!";
     70                        + "You didn't reach the check point  before the time limit. You lose!";
    6071            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    6172            ChatManager::message(message);
     
    7081            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    7182            ChatManager::message(message);
    72 /*
     83
    7384            float time = this->clock_.getSecondsPrecise();
    7485            this->scores_.insert(time);
    7586            std::set<float>::iterator it;
    76             for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
    77                 orxout(level::message) << multi_cast<std::string>(*it) << endl;
    78 */
     87           
     88
    7989        }
    8090    }
     
    8292    void SpaceRace::start()
    8393    {
    84         Gametype::start();
    8594
    86         std::string message("The match has started! Reach the check points as quickly as possible!");
     95        this->spawnPlayersIfRequested();
     96        Gametype::checkStart();
     97        this->cantMove_=true;
     98       
     99        for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
     100        {
     101            it->setActive(false);
     102           
     103        }
     104        this->addBots(this->numberOfBots_);
     105    }
     106   
     107    void SpaceRace::tick(float dt)
     108    {
     109        SUPER(SpaceRace,tick,dt);
     110   
     111        if(!this->isStartCountdownRunning() && this->cantMove_)
     112        {
     113            for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
     114            {
     115                it->setActive(true);
     116               
     117            }
     118            this->cantMove_= false;
     119           
     120            std::string message("The match has started! Reach the check points as quickly as possible!");
     121            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     122            ChatManager::message(message);           
     123        }
     124   
     125    }
     126
     127   
     128   
     129    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
     130    {
     131        this->checkpointReached_[pl]=index;
     132        this->clock_.capture();
     133        int s = this->clock_.getSeconds();
     134        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
     135        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
     136            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
     137            + " seconds.";// Message is too long for a normal screen.
    87138        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    88139        ChatManager::message(message);
    89140    }
    90 
    91     void SpaceRace::newCheckpointReached()
    92     {
    93         this->checkpointsReached_++;
     141   
     142    void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
     143    {   
     144        int index = p->getCheckpointIndex();
     145        this->checkpointReached_[pl]=index;
    94146        this->clock_.capture();
    95147        int s = this->clock_.getSeconds();
    96148        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    97         const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
    98                         + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    99                         + " seconds.";
     149        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
     150            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
     151            + " seconds.";
    100152        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    101153        ChatManager::message(message);
    102154    }
     155       
     156   
     157    void SpaceRace::playerEntered(PlayerInfo* player)
     158    {
     159        Gametype::playerEntered(player);
     160   
     161        this->checkpointReached_[player]=-1;
     162        //this->playersAlive_++;
     163    }
     164   
     165    bool SpaceRace::playerLeft(PlayerInfo* player)
     166    {
     167        return Gametype::playerLeft(player);
     168        // bool valid_player = true;
     169        //if (valid_player)
     170       // {
     171        //    this->playersAlive_--;
     172        //}
    103173
     174       // return valid_player;
     175    }
     176   
     177    bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
     178    {
     179        return false;
     180    }
     181
     182    bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator)
     183    {
     184        return false;
     185    }
     186
     187    bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)
     188    {
     189        return false;
     190    }
    104191}
  • code/trunk/src/modules/gametypes/SpaceRace.h

    r8767 r9016  
    3434#include <set>
    3535#include <string>
     36# include <vector>
    3637
    3738#include <util/Clock.h>
     
    3940#include "gametypes/Gametype.h"
    4041
    41 #include "RaceCheckPoint.h"
     42#include "SpaceRaceManager.h"
    4243
    4344namespace orxonox
     
    5051    {
    5152        friend class RaceCheckPoint;
     53       
    5254
    5355        public:
     
    5860            virtual void end();
    5961
    60             virtual void newCheckpointReached();
     62            virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
     63            virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
    6164
    62             inline void setCheckpointsReached(int n)
    63                 { this->checkpointsReached_ = n;}
    64             inline int getCheckpointsReached()
    65                 { return this->checkpointsReached_; }
     65            inline void setCheckpointReached(int n, PlayerInfo* p)
     66                { this->checkpointReached_[p] = n;}
     67            inline int getCheckpointReached(PlayerInfo* p)
     68                { return this->checkpointReached_[p]; }
     69
    6670            inline void timeIsUp()
    6771                { this->bTimeIsUp_ = true;}
     72            void tick(float dt);
     73            Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
    6874
     75
     76            bool allowPawnHit(Pawn* victim, Pawn* originator);
     77
     78            bool allowPawnDamage(Pawn* victim, Pawn* originator);
     79
     80            bool allowPawnDeath(Pawn* victim, Pawn* originator);
    6981        protected:
    70 
     82            virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
     83            virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
    7184        private:
    72             int checkpointsReached_; //The current number of check points reached by the player.
     85            bool cantMove_;
     86            std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
    7387            std::set<float> scores_; //The times of the players are saved in a set.
    7488            bool bTimeIsUp_; //True if one of the check points is reached too late.
    75             Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
     89           
     90            int playersAlive_;
    7691    };
    7792}
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r8706 r9016  
    9191    @ingroup MultiTrigger
    9292    */
    93     class _ObjectsExport DistanceMultiTrigger : public MultiTrigger
     93    class _ObjectsExport DistanceMultiTrigger : public MultiTrigger 
    9494    {
    9595
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    r8457 r9016  
    157157            bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
    158158
    159             void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
     159            virtual void fire(bool status, BaseObject* originator = NULL);  //!< Helper method. Creates an Event for the given status and originator and fires it.
    160160            void broadcast(bool status); //!< Helper method. Broadcasts an Event for every object that is a target.
    161161
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r8706 r9016  
    77  HUDHealthBar.cc
    88  HUDTimer.cc
     9  HUDEnemyHealthBar.cc
    910  ChatOverlay.cc
    1011  AnnounceMessage.cc
  • code/trunk/src/modules/overlays/hud/HUDHealthBar.h

    r7401 r9016  
    110110                { return this->textoverlay_->getSpaceWidth(); }
    111111
     112            inline void setOverlayText(SmartPtr<OverlayText> textoverlay)
     113                { this->textoverlay_ = textoverlay; }
     114            inline SmartPtr<OverlayText> getOverlayText() const
     115                {return this->textoverlay_; }
     116
    112117        private:
    113118            WeakPtr<Pawn> owner_;
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r8891 r9016  
    2525 *      Reto Grieder
    2626 *      Oliver Scheuss
     27 *      Matthias Spalinger
    2728 *
    2829 */
     
    6364{
    6465  SetConfigValue(markerLimit_, 3);
    65 
     66  SetConfigValue(showDistance, false);
    6667}
    6768
     
    7576
    7677    // Set default values
    77     setFont ( "Monofur" );
    78     setTextSize ( 0.05f );
    79     setNavMarkerSize ( 0.05f );
    80     setDetectionLimit( 10000.0f );
     78    this->setFont ( "Monofur" );
     79    this->setTextSize ( 0.05f );
     80    this->setNavMarkerSize ( 0.05f );
     81    this->setDetectionLimit( 10000.0f );
    8182}
    8283
     
    9798    SUPER ( HUDNavigation, XMLPort, xmlelement, mode );
    9899
    99     XMLPortParam ( HUDNavigation, "font",           setFont,           getFont,           xmlelement, mode );
    100     XMLPortParam ( HUDNavigation, "textSize",       setTextSize,       getTextSize,       xmlelement, mode );
    101     XMLPortParam ( HUDNavigation, "navMarkerSize",  setNavMarkerSize,  getNavMarkerSize, xmlelement, mode );
    102     XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode );
     100    XMLPortParam ( HUDNavigation, "font",          setFont,          getFont,          xmlelement, mode );
     101    XMLPortParam ( HUDNavigation, "textSize",      setTextSize,      getTextSize,      xmlelement, mode );
     102    XMLPortParam ( HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode );
     103    XMLPortParam ( HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode ); 
    103104}
    104105
     
    144145}
    145146
    146 
     147float HUDNavigation::getArrowSizeX(int dist)
     148{   
     149    if (dist < 600)
     150        dist = 600;
     151    return this->getActualSize().x * 900 * navMarkerSize_ / dist;
     152}
     153
     154float HUDNavigation::getArrowSizeY(int dist)
     155{   
     156    if (dist < 600)
     157        dist = 600;   
     158    return this->getActualSize().y * 900 * navMarkerSize_ / dist;
     159}
    147160
    148161void HUDNavigation::tick ( float dt )
     
    165178    unsigned int markerCount_ = 0;
    166179    bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player
     180
    167181//         for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
    168182    for ( sortedList::iterator listIt = sortedObjectList_.begin(); listIt != sortedObjectList_.end(); ++markerCount_, ++listIt )
     
    170184        ObjectMap::iterator it = activeObjectList_.find ( listIt->first );
    171185        closeEnough_ = listIt->second < detectionLimit_ ;
    172         if ( markerCount_ < markerLimit_ && (closeEnough_ ||  detectionLimit_ < 0) ) // display on HUD if the statement is true
     186        // display radarviewables on HUD if the marker limit and max-distance is not exceeded
     187        if ( markerCount_ < markerLimit_ && (closeEnough_ ||  detectionLimit_ < 0) )
    173188        {
    174189
     
    176191            // Get Distance to HumanController and save it in the TextAreaOverlayElement.
    177192            int dist = listIt->second;
     193            float textLength = 0.0f;
     194
     195            //display distance next to cursor
     196            if (showDistance){
    178197            it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
    179             float textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
     198            textLength = multi_cast<std::string> ( dist ).size() * it->second.text_->getCharHeight() * 0.3f;
     199            }
     200
     201            //display name next to cursor
     202            else{
     203            it->second.text_->setCaption(it->first->getRVName());
     204            textLength = it->first->getRVName().size() * it->second.text_->getCharHeight() * 0.3f;
     205            }
    180206
    181207            // Transform to screen coordinates
     
    194220            else
    195221                outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
    196             // Get Distance to HumanController and save it in the TextAreaOverlayElement.
    197             it->second.text_->setCaption ( multi_cast<std::string> ( dist ) );
    198222
    199223            if ( outOfView )
     
    207231                    it->second.wasOutOfView_ = true;
    208232                }
     233
     234                //float xDistScale = this->getActualSize().x * 1000.0f * navMarkerSize_ / dist;
     235                //float yDistScale = this->getActualSize().y * 1000.0f * navMarkerSize_ / dist;
     236
     237                // Adjust Arrowsize according to distance
     238                it->second.panel_->setDimensions(getArrowSizeX(dist),getArrowSizeY(dist));
    209239
    210240                // Switch between top, bottom, left and right position of the arrow at the screen border
     
    263293                  //it->second.panel_->setMaterialName ( "Orxonox/NavTDC" );
    264294                    it->second.panel_->setMaterialName( TextureGenerator::getMaterialName( "tdc.png", it->first->getRadarObjectColour()) );
     295                    it->second.panel_->setDimensions ( navMarkerSize_ * this->getActualSize().x, navMarkerSize_ * this->getActualSize().y );
    265296                    it->second.wasOutOfView_ = false;
    266297                }
     
    280311            it->second.text_->show();
    281312        }
    282         else // do not display on HUD
     313        else // do not display on HUD 
    283314        {
    284315            it->second.panel_->hide();
     
    312343void HUDNavigation::addObject ( RadarViewable* object )
    313344{
    314     if( showObject(object) == false )
     345    if( showObject(object)==false )
    315346        return;
    316347
     
    399430        return false;
    400431    assert( rv->getWorldEntity() );
    401     if ( rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false )
     432    if ( rv->getWorldEntity()->isVisible()==false || rv->getRadarVisibility()==false )
    402433        return false;
    403434    return true;
  • code/trunk/src/modules/overlays/hud/HUDNavigation.h

    r8891 r9016  
    2424 *   Co-authors:
    2525 *      Reto Grieder
     26 *      Matthias Spalinger
    2627 *
    2728 */
     
    5455    virtual void tick ( float dt );
    5556
     57    // RadarListener interface
    5658    virtual void addObject ( RadarViewable* object );
    5759    virtual void removeObject ( RadarViewable* viewable );
     
    6668    inline float getRadarSensitivity() const
    6769    { return 1.0f; }
     70
     71    unsigned int getMarkerLimit() { return this->markerLimit_; }
    6872
    6973private:
     
    8185    // XMLPort accessors
    8286    void setNavMarkerSize ( float size )
    83     { navMarkerSize_ = size; this->sizeChanged(); }
     87        { navMarkerSize_ = size; this->sizeChanged(); }
    8488    float getNavMarkerSize() const
    85     { return navMarkerSize_; }
    86 
    87     void setDetectionLimit( float limit )
    88     { this->detectionLimit_ = limit; }
    89     float getDetectionLimit() const
    90     { return this->detectionLimit_; }
     89        { return navMarkerSize_; }
     90    void setDetectionLimit( float limit )
     91        { this->detectionLimit_ = limit; }
     92    float getDetectionLimit() const
     93        { return this->detectionLimit_; }
    9194
    9295    void setTextSize ( float size );
     
    102105    sortedList sortedObjectList_;
    103106
     107    float getArrowSizeX(int dist);   
     108    float getArrowSizeY(int dist);
    104109
    105110    float navMarkerSize_;
    106111    std::string fontName_;
    107112    float textSize_;
     113    bool showDistance;
    108114
    109     unsigned int markerLimit_; //TODO: is it possible to set this over the console and/or the IG-Setting
    110     float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value.
    111                            //!< In order to bypass this behaviour, set a negative detectionLimit_. Then the detection range is "infinite".
     115    unsigned int markerLimit_;
     116    float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value. 
     117
    112118};
    113119}
  • code/trunk/src/modules/pong/Pong.cc

    r8858 r9016  
    3737#include "core/EventIncludes.h"
    3838#include "core/command/Executor.h"
     39#include "core/ConfigValueIncludes.h"
    3940
    4041#include "gamestates/GSLevel.h"
     42#include "chat/ChatManager.h"
    4143
    4244#include "PongCenterpoint.h"
     
    4547#include "PongBot.h"
    4648#include "PongAI.h"
    47 
    4849namespace orxonox
    4950{
     
    7576        // Set the type of Bots for this particular Gametype.
    7677        this->botclass_ = Class(PongBot);
     78        this->scoreLimit_ = 10;
     79        this->setConfigValues();
    7780    }
    7881
     
    280283        }
    281284
     285        // If a palyer gets 21 points, he won the game -> end of game
     286       
     287        PlayerInfo* player1 = this->getLeftPlayer();
     288        PlayerInfo* player2 = this->getRightPlayer();
     289        if(player1==NULL||player2==NULL) return; //safety
     290        if(this->getScore(player1) >= scoreLimit_)
     291        {
     292            std::string name1=player1->getName();
     293            std::string message(name1 + " has won!");
     294            ChatManager::message(message);
     295            this->end();
     296        }
     297        else if(this->getScore(player2) >= scoreLimit_)
     298        {
     299             std::string name2=player2->getName();
     300             std::string message2(name2 + " has won!");
     301             ChatManager::message(message2);
     302             this->end();
     303        }
    282304        // Restart the timer to start the ball.
    283305        this->starttimer_.startTimer();
     306
    284307    }
    285308
     
    321344            return 0;
    322345    }
     346
     347    /**
     348     @brief
     349         Make scoreLimit_ configurable e.g. in the menu.
     350     */
     351    void Pong::setConfigValues()
     352    {
     353        SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");
     354    }
    323355}
  • code/trunk/src/modules/pong/Pong.h

    r8351 r9016  
    8181            void setCenterpoint(PongCenterpoint* center)
    8282                { this->center_ = center; }
    83 
    84             PlayerInfo* getLeftPlayer() const; //!< Get the left player.
     83            void setConfigValues(); //!< Makes scoreLimit configurable.
     84           
     85            PlayerInfo* getLeftPlayer() const; //!< Get the left player.
    8586            PlayerInfo* getRightPlayer() const; //!< Get the right player.
    8687
     
    9495            WeakPtr<PongBall> ball_; //!< The Pong ball.
    9596            WeakPtr<PongBat> bat_[2]; //!< The two bats.
    96             Timer starttimer_; //!< A timer to delay the start of the game.
     97            Timer starttimer_; //!< A timer to delay the start of the game.
     98            int scoreLimit_; //!< If a player scored that much points, the game is ended.
    9799    };
    98100}
  • code/trunk/src/modules/pong/PongAI.h

    r8108 r9016  
    8080            void delayedMove(); //!< Is called, when a delayed move takes effect.
    8181
    82             PongBall* ball_; //!< A pointer to the ball.
     82            WeakPtr<PongBall> ball_; //!< A weak pointer to the ball.
    8383            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
    8484            float ballEndPosition_; //!< The calculated end position of the ball.
  • code/trunk/src/modules/pong/PongScore.cc

    r8108 r9016  
    6060        this->bShowLeftPlayer_ = false;
    6161        this->bShowRightPlayer_ = false;
     62        this->player1_ = NULL;
     63        this->player2_ = NULL;
    6264    }
    6365
     
    98100        if (this->owner_ != NULL)
    99101        {
    100             // Get the two players.
    101             PlayerInfo* player1 = this->owner_->getLeftPlayer();
    102             PlayerInfo* player2 = this->owner_->getRightPlayer();
    103 
    104             std::string name1;
    105             std::string name2;
    106 
    107             std::string score1("0");
    108             std::string score2("0");
    109 
    110             // Save the name and score of each player as a string.
    111             if (player1 != NULL)
     102            if(!this->owner_->hasEnded())
    112103            {
    113                 name1 = player1->getName();
    114                 score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    115             }
    116             if (player2 != NULL)
    117             {
    118                 name2 = player2->getName();
    119                 score2 = multi_cast<std::string>(this->owner_->getScore(player2));
     104                //get the two players
     105                player1_ = this->owner_->getLeftPlayer();
     106                player2_ = this->owner_->getRightPlayer();
    120107            }
    121108
    122             // Assemble the strings, depending on what should all be displayed.
    123             std::string output1;
    124             if (this->bShowLeftPlayer_)
     109            if(this->owner_->hasStarted())
    125110            {
    126                 if (this->bShowName_ && this->bShowScore_ && player1 != NULL)
    127                     output1 = name1 + " - " + score1;
    128                 else if (this->bShowScore_)
    129                     output1 = score1;
    130                 else if (this->bShowName_)
    131                     output1 = name1;
    132             }
     111                // Get the two players.
    133112
    134             std::string output2;
    135             if (this->bShowRightPlayer_)
    136             {
    137                 if (this->bShowName_ && this->bShowScore_ && player2 != NULL)
     113                std::string name1;
     114                std::string name2;
     115
     116                std::string score1("0");
     117                std::string score2("0");
     118
     119                // Save the name and score of each player as a string.
     120                if (player1_ != NULL)
     121                {
     122                    name1 = player1_->getName();
     123                    score1 = multi_cast<std::string>(this->owner_->getScore(player1_));
     124                }
     125                if (player2_ != NULL)
     126                {
     127                    name2 = player2_->getName();
     128                    score2 = multi_cast<std::string>(this->owner_->getScore(player2_));
     129                }
     130
     131                // Assemble the strings, depending on what should all be displayed.
     132                std::string output1;
     133                if (this->bShowLeftPlayer_)
     134                {
     135                    if (this->bShowName_ && this->bShowScore_ && player1_ != NULL)
     136                         output1 = name1 + " - " + score1;
     137                    else if (this->bShowScore_)
     138                         output1 = score1;
     139                    else if (this->bShowName_)
     140                         output1 = name1;
     141                }
     142
     143                std::string output2;
     144                if (this->bShowRightPlayer_)
     145                {
     146                if (this->bShowName_ && this->bShowScore_ && player2_ != NULL)
    138147                    output2 = score2 + " - " + name2;
    139148                else if (this->bShowScore_)
     
    143152            }
    144153
    145             std::string output("PONG");
    146             if (this->bShowName_ || this->bShowScore_)
    147             {
    148                 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
    149                     output = output1 + ':' + output2;
    150                 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
    151                     output = output1 + output2;
     154                std::string output("PONG");
     155                if (this->bShowName_ || this->bShowScore_)
     156                {
     157                    if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
     158                        output = output1 + ':' + output2;
     159                    else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
     160                        output = output1 + output2;
     161                }
     162                this->setCaption(output);
    152163            }
    153 
    154             this->setCaption(output);
    155164        }
    156165    }
  • code/trunk/src/modules/pong/PongScore.h

    r8108 r9016  
    122122            bool bShowLeftPlayer_; //!< Whether the left player is shown.
    123123            bool bShowRightPlayer_; //!< Whether the right player is shown.
     124            PlayerInfo* player1_; //!< Store information about left player permanently.
     125            PlayerInfo* player2_; //!< Same for the right player. To end the game properly.
    124126    };
    125127}
  • code/trunk/src/modules/weapons/projectiles/Rocket.cc

    r8891 r9016  
    6666        this->localAngularVelocity_ = 0;
    6767        this->lifetime_ = 100.0f;
    68         this->bIsRocket_= true;
    6968
    7069        if (GameMode::isMaster())
     
    135134        if(this->isInitialized())
    136135        {
    137             this->bIsRocket_= false;
    138136            if (GameMode::isMaster())
    139137            {
     
    163161       
    164162        this->player_ = this->getShooter()->getPlayer();
    165         this->getShooter()->getPlayer()->startTemporaryControl(this);
     163        if(this->player_)
     164            this->player_->startTemporaryControl(this);
    166165
    167166        if( GameMode::isMaster() )
  • code/trunk/src/modules/weapons/projectiles/Rocket.h

    r8855 r9016  
    122122
    123123            WeakPtr<PlayerInfo> player_; //!< The player that controls the Rocket.
     124            //WeakPtr<Pawn> pawn_; //!< The pawn that controls the Rocket. TODO
    124125            Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
    125126            float lifetime_; //!< The time the projectile exists.
  • code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc

    r8855 r9016  
    5252        this->reloadTime_ = 1.0f;
    5353        this->damage_ = 0.0f;
    54         this->speed_ = 250.0f;
     54        this->speed_ = 700.0f;
    5555
    5656        this->setMunitionName("LaserMunition");
Note: See TracChangeset for help on using the changeset viewer.