Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 20, 2011, 11:27:45 PM (13 years ago)
Author:
dafrick
Message:

Some cleanup…

Location:
code/trunk/src/modules/gametypes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/gametypes/RaceCheckPoint.cc

    r8706 r8767  
    3131#include "core/CoreIncludes.h"
    3232#include "core/XMLPort.h"
     33#include "util/Convert.h"
     34
    3335#include "SpaceRace.h"
    34 #include "util/Convert.h"
    3536
    3637namespace orxonox
    3738{
    3839    CreateFactory(RaceCheckPoint);
    39    
     40
    4041    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
    4142    {
     
    5051        this->setRadarVisibility(false);
    5152    }
    52    
     53
    5354    RaceCheckPoint::~RaceCheckPoint()
    5455    {
    5556    }
    56    
     57
    5758    void RaceCheckPoint::tick(float dt)
    5859    {
     
    6061
    6162        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
     63        assert(gametype);
    6264        if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
    6365            this->setRadarVisibility(true);
     
    6668    }
    6769
    68    
    6970    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7071    {
     
    7576        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
    7677    }
    77    
     78
    7879    void RaceCheckPoint::triggered(bool bIsTriggered)
    7980    {
     
    99100        }
    100101    }
    101    
     102
    102103    void RaceCheckPoint::setTimelimit(float timeLimit)
    103104    {
     
    115116        }
    116117    }
    117    
     118
    118119}
  • code/trunk/src/modules/gametypes/RaceCheckPoint.h

    r8706 r8767  
    3434#include "objects/triggers/DistanceTrigger.h"
    3535#include "interfaces/RadarViewable.h"
    36 //#include <boost/concept_check.hpp>
    3736
    3837namespace orxonox
    3938{
    40   /**
    41   @brief
    42     The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
    43     !!! Don't forget to control the indexes of your check points and to set one last check point!!!
    44   */
     39    /**
     40    @brief
     41        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!!!
     43    */
    4544    class _GametypesExport RaceCheckPoint : public DistanceTrigger, public RadarViewable
    4645    {
  • code/trunk/src/modules/gametypes/SpaceRace.cc

    r8706 r8767  
    3131#include "core/CoreIncludes.h"
    3232#include "network/Host.h"
    33 #include <util/Clock.h>
    34 #include <util/Math.h>
    3533#include "util/Convert.h"
     34#include "util/Math.h"
    3635
    3736namespace orxonox
    3837{
    3938    CreateUnloadableFactory(SpaceRace);
    40    
     39
    4140    SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
    4241    {
    4342        RegisterObject(SpaceRace);
    44         this->bCheckpointsReached_ = 0;
     43        this->checkpointsReached_ = 0;
    4544        this->bTimeIsUp_ = false;
    4645        this->numberOfBots_ = 0;
    4746    }
    48    
     47
    4948    void SpaceRace::end()
    5049    {
    5150        this->Gametype::end();
    52          
     51
    5352        if (this->bTimeIsUp_)
    5453        {
     
    5756            int ms = this->clock_.getMilliseconds()-1000*s;
    5857            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
    59                         + "You didn't reach the check point " + multi_cast<std::string>(this->bCheckpointsReached_+1)
     58                        + "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
    6059                        + " before the time limit. You lose!";
    6160            COUT(3) << message;
    6261            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    63             Host::Broadcast(message);
    6462        }
    6563        else
     
    7270            COUT(3) << message << std::endl;
    7371            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    74             Host::Broadcast(message);
    7572            float time = this->clock_.getSecondsPrecise();
    7673            this->scores_.insert(time);
     
    8784        std::string message("The match has started! Reach the check points as quickly as possible!");
    8885        COUT(3) << message << std::endl;
    89         Host::Broadcast(message);
     86        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    9087    }
    91    
     88
    9289    void SpaceRace::newCheckpointReached()
    9390    {
    94         this->bCheckpointsReached_++;
     91        this->checkpointsReached_++;
    9592        this->clock_.capture();
    9693        int s = this->clock_.getSeconds();
     
    10198        COUT(3) << message;
    10299        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    103         Host::Broadcast(message);
    104100    }
    105101
  • code/trunk/src/modules/gametypes/SpaceRace.h

    r8706 r8767  
    3030#define _SpaceRace_H__
    3131
     32#include "gametypes/GametypesPrereqs.h"
     33
     34#include <set>
     35#include <string>
     36
     37#include <util/Clock.h>
     38
    3239#include "gametypes/Gametype.h"
    33 #include "gametypes/GametypesPrereqs.h"
     40
    3441#include "RaceCheckPoint.h"
    35 #include <boost/concept_check.hpp>
    36 #include <util/Clock.h>
    37 #include <string.h>
    38 #include <set>
    3942
    4043namespace orxonox
     
    4750    {
    4851        friend class RaceCheckPoint;
    49        
     52
    5053        public:
    5154            SpaceRace(BaseObject* creator);
     
    5356
    5457            virtual void start();
    55                 virtual void end();
     58            virtual void end();
    5659
    5760            virtual void newCheckpointReached();
    5861
    5962            inline void setCheckpointsReached(int n)
    60             { this->bCheckpointsReached_ = n;}
     63                { this->checkpointsReached_ = n;}
    6164            inline int getCheckpointsReached()
    62             { return this->bCheckpointsReached_; }
     65                { return this->checkpointsReached_; }
    6366            inline void timeIsUp()
    64             { this->bTimeIsUp_ = true;}
     67                { this->bTimeIsUp_ = true;}
    6568
    6669        protected:
    6770
    6871        private:
    69             int bCheckpointsReached_; //The current number of check points reached by the player.
     72            int checkpointsReached_; //The current number of check points reached by the player.
    7073            std::set<float> scores_; //The times of the players are saved in a set.
    7174            bool bTimeIsUp_; //True if one of the check points is reached too late.
Note: See TracChangeset for help on using the changeset viewer.