Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 18, 2011, 2:35:02 PM (12 years ago)
Author:
jo
Message:

Merged SpaceraceTwo. Old racelevel does not work anymore.

Location:
code/branches/presentation2011
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/modules/gametypes/SpaceRace.cc

    r8858 r8998  
    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}
Note: See TracChangeset for help on using the changeset viewer.