Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 4, 2018, 4:58:37 PM (7 years ago)
Author:
landauf
Message:

[SpaceRace_HS16] reverted some unwanted changes and fixed formatting a little bit

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

Legend:

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

    r11358 r11720  
    8080        RegisterObject(SpaceRace);
    8181
    82         this->botclass_ = Class(SpaceRaceBot); //ClassByString("")
     82        this->botclass_ = Class(SpaceRaceBot);
    8383        this->cantMove_ = false;
    8484        this->bTimeIsUp_ = false;
    85         this->setConfigValues();
    8685
    8786        this->numberOfBots_ = 5; // quick fix: don't allow default-bots to enter the race
     
    8988    }
    9089
    91   void SpaceRace::setConfigValues()
    92     {
    93        
    94    
    95     }
    96 
    9790    void SpaceRace::start()
    9891    {
    99     // define spawn positions of the 5 bots
     92        // define spawn positions of the 5 bots
    10093
    10194        int startpos[15];
     
    120113        startpos[13] =-40;
    121114        startpos[14] =80;
    122        
    123 
    124 
    125115
    126116        Gametype::start();
    127    if (true)
    128         {
    129             this->spawnPlayersIfRequested();
    130             this->cantMove_ = true;
    131             //players are unable to move while countdown is running
    132             for (Engine* engine : ObjectList<Engine>()){
    133                 engine->setActive(false);
    134                
    135 
    136             }
    137            //append spawn positions to bots
    138            int a,b,c;
    139             a=0;
    140             b=1;
    141             c=2;
    142               for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>()){
    143                 bot->getControllableEntity()->setPosition(startpos[a],startpos[b],startpos[c]);
    144                a= a+3;
    145                b = b+3;
    146                c+= 3;
    147             }
    148 
    149 
    150         }
    151 
    152                                                
     117
     118        this->spawnPlayersIfRequested();
     119        this->cantMove_ = true;
     120        //players are unable to move while countdown is running
     121        for (Engine* engine : ObjectList<Engine>())
     122        {
     123            engine->setActive(false);
     124        }
     125
     126        //append spawn positions to bots
     127        int a,b,c;
     128        a=0;
     129        b=1;
     130        c=2;
     131
     132        for (SpaceRaceBot* bot : ObjectList<SpaceRaceBot>())
     133        {
     134            bot->getControllableEntity()->setPosition(startpos[a], startpos[b], startpos[c]);
     135            a += 3;
     136            b += 3;
     137            c += 3;
     138        }
    153139
    154140        std::string message("Use headphones to hear the countdown!");
     
    156142        ChatManager::message(message);
    157143
    158 //after 11 seconds , countdownFinished function is called to activate bots` engines
    159 Timer* countdownTimer = new Timer();
     144        //after 11 seconds , countdownFinished function is called to activate bots` engines
     145        Timer* countdownTimer = new Timer();
    160146        countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this)));
    161147    }
     
    189175    }
    190176
    191 
    192 void SpaceRace::tick(float dt)
    193     {
    194         SUPER(SpaceRace,tick,dt);
    195 }
    196 
    197177    void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player)
    198178    {
     
    207187        const std::string& message = player->getName() + " reached the checkpoint " + multi_cast<std::string>(checkpoint->getCheckpointIndex() + 1)
    208188        + "after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.";
    209  this->getGametypeInfo()->sendAnnounceMessage(message);
    210         ChatManager::message(message);
    211 
    212     }
    213 
    214  void SpaceRace::countdownFinished()//activates the engines of all players
     189        this->getGametypeInfo()->sendAnnounceMessage(message);
     190        ChatManager::message(message);
     191
     192    }
     193
     194    void SpaceRace::countdownFinished()//activates the engines of all players
    215195    {
    216196
     
    220200
    221201
    222     for (Engine* engine : ObjectList<Engine>())
    223                 engine->setActive(true);
    224 
    225 
    226    
    227 }
    228 
    229  void SpaceRace::playerEntered(PlayerInfo* player)
     202        for (Engine* engine : ObjectList<Engine>())
     203            engine->setActive(true);
     204    }
     205
     206    void SpaceRace::playerEntered(PlayerInfo* player)
    230207    {
    231208        Gametype::playerEntered(player);
     
    236213
    237214
    238  void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game
     215    void SpaceRace::addBots(unsigned int amount) //function that add the bots to the game
    239216    {
    240217        for (unsigned int i = 1; i <= amount; ++i){
     
    244221
    245222
    246 //set bot configurations
     223    //set bot configurations
    247224    bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
    248225    {
     
    255232    }
    256233
    257     bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to early
    258                                                                     //if they can
     234    bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)// false because the bots can not recognize the objects and die to earlyif they can
    259235    {
    260236        return false;
  • code/trunk/src/modules/gametypes/SpaceRace.h

    r11358 r11720  
    5757            virtual ~SpaceRace() {}
    5858
    59              void setConfigValues();
    60 
    61             virtual void tick(float dt) override;
    6259            virtual void start() override;
    6360            virtual void end() override;
    64  virtual void countdownFinished();
    65              virtual void addBots(unsigned int amount) override; //<! overwrite function in order to bypass the addbots command.
     61            virtual void countdownFinished();
     62            virtual void addBots(unsigned int amount) override; //<! overwrite function in order to bypass the addbots command.
    6663
    6764
    6865
    69              virtual void playerEntered(PlayerInfo* player) override;
     66            virtual void playerEntered(PlayerInfo* player) override;
    7067
    7168            //virtual void newCheckpointReached();
  • code/trunk/src/modules/gametypes/SpaceRaceBot.cc

    r11358 r11720  
    2323 *      Author: purgham
    2424 */
    25 #include <vector>
    2625
    2726#include "SpaceRaceBot.h"
    28 #include "core/GameMode.h"
    2927#include "core/CoreIncludes.h"
    30 #include "core/config/ConfigValueIncludes.h"
    31 #include "gametypes/Gametype.h"
    32 #include "controllers/AIController.h"
    33 #include "gametypes/SpaceRaceController.h"
    34 
    35 
    36 
    3728
    3829namespace orxonox
     
    4233    SpaceRaceBot::SpaceRaceBot(Context* context) : Bot(context){
    4334        RegisterObject(SpaceRaceBot);
    44         this->defaultController_ = Class(SpaceRaceController);// ClassByString("")
     35        this->defaultController_ = Class(SpaceRaceController);
    4536        this->createController();
    46 
    47     }
    48 
    49 SpaceRaceBot::~SpaceRaceBot(){
    50 
    51 }
    52 
    53 void SpaceRaceBot::setConfigValues()
    54     {
    55         static const std::string names[] =
    56         {
    57             "Dr. Julius No",
    58             "Berkay Berabi",
    59             "Louis Meile"         
    60             "Yo mama"
    61         };
    62         static std::vector<std::string> defaultnames(names, names + sizeof(names) / sizeof(std::string));
    63 
    64         SetConfigValue(names_, defaultnames);
    6537    }
    6638}
  • code/trunk/src/modules/gametypes/SpaceRaceBot.h

    r11718 r11720  
    3030#include "gametypes/GametypesPrereqs.h"
    3131#include "gametypes/SpaceRaceController.h"
    32 #include <vector>
    3332
    3433
     
    4039        public:
    4140            SpaceRaceBot(Context* context);
    42             virtual ~SpaceRaceBot();
    43    
    44             void setConfigValues();
    45 
    46 
    47 
    48  virtual inline bool isInitialized() const override
    49                 { return true; }
    50             virtual inline float getPing() const override
    51                 { return 0; }
    52             virtual inline float getPacketLossRatio() const override
    53                 { return 0; }
    54 
    55 
    56   private:
    57             std::vector<std::string> names_;
    58 
    59 
     41            virtual ~SpaceRaceBot() {}
    6042    };
    6143}
  • code/trunk/src/modules/gametypes/SpaceRaceController.cc

    r11358 r11720  
    1616 *   GNU General Public License for more details.
    1717 *
    18  *   You should have     a copy of the GNU General Public License
     18 *   You should have received a copy of the GNU General Public License
    1919 *   along with this program; if not, write to the Free Software
    2020 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     
    327327        lastPositionSpaceship = this->getControllableEntity()->getPosition();
    328328       
    329 this->boostControl();
     329        this->boostControl();
    330330        this->moveToPosition(nextRaceCheckpoint_->getPosition());
    331331        this->boostControl();
Note: See TracChangeset for help on using the changeset viewer.