[Orxonox-commit 3878] r8552 - in code/branches/spacerace: data/levels src/modules/gametypes
msalomon at orxonox.net
msalomon at orxonox.net
Mon May 23 18:35:35 CEST 2011
Author: msalomon
Date: 2011-05-23 18:35:35 +0200 (Mon, 23 May 2011)
New Revision: 8552
Modified:
code/branches/spacerace/data/levels/spaceRace.oxw
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
code/branches/spacerace/src/modules/gametypes/SpaceRace.h
Log:
Modified: code/branches/spacerace/data/levels/spaceRace.oxw
===================================================================
--- code/branches/spacerace/data/levels/spaceRace.oxw 2011-05-23 16:19:59 UTC (rev 8551)
+++ code/branches/spacerace/data/levels/spaceRace.oxw 2011-05-23 16:35:35 UTC (rev 8552)
@@ -50,7 +50,7 @@
</SpawnPoint>
<!-- ------------------CheckPoints----------------- -->
- <RaceCheckPoint name=checkpoint1 position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale=1 distance=40 checkpointindex=0 islast=false>
+ <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
</attached>
@@ -62,7 +62,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint2 position="0,-900,2300" collisionType="static" scale=1 distance=40 checkpointindex=1 islast=false>
+ <RaceCheckPoint name="checkpoint2" position="0,-900,2300" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger1" position="0,0,0" distance=40 stayActive="true" />
@@ -83,7 +83,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint3 position="0,700,2700" direction="0,0,1" collisionType="static" scale=1 distance=40 checkpointindex=2 islast=false>
+ <RaceCheckPoint name="checkpoint3" position="0,700,2700" direction="0,0,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger2" position="0,0,0" distance=40 stayActive="true" />
@@ -104,7 +104,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint4 position="0,2100,2300" direction="0,1,1" collisionType="static" scale=1 distance=40 checkpointindex=3 islast=false>
+ <RaceCheckPoint name="checkpoint4" position="0,2100,2300" direction="0,1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger3" position="0,0,0" distance=40 stayActive="true" />
@@ -125,7 +125,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint5 position="0,2200,500" direction="0,1,0" collisionType="static" scale=1 distance=40 checkpointindex=4 islast=false>
+ <RaceCheckPoint name="checkpoint5" position="0,2200,500" direction="0,1,0" collisionType="static" scale="1" distance="40" checkpointindex="4" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger4" position="0,0,0" distance=40 stayActive="true" />
@@ -146,7 +146,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint6 position="0,1500,-800" direction="0,1,-1" collisionType="static" scale=1 distance=40 checkpointindex=5 islast=false>
+ <RaceCheckPoint name="checkpoint6" position="0,1500,-800" direction="0,1,-1" collisionType="static" scale="1" distance="40" checkpointindex="5" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger5" position="0,0,0" distance=40 stayActive="true" />
@@ -167,7 +167,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint7 position="0,200,-1900" collisionType="static" scale=1 distance=40 checkpointindex=6 islast=false>
+ <RaceCheckPoint name="checkpoint7" position="0,200,-1900" collisionType="static" scale="1" distance="40" checkpointindex="6" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger6" position="0,0,0" distance=40 stayActive="true" />
@@ -188,7 +188,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint8 position="0,-700,-1400" direction="0,-1,-1" collisionType="static" scale=1 distance=40 checkpointindex=7 islast=false>
+ <RaceCheckPoint name="checkpoint8" position="0,-700,-1400" direction="0,-1,-1" collisionType="static" scale="1" distance="40" checkpointindex="7" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger7" position="0,0,0" distance=40 stayActive="true" />
@@ -209,7 +209,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint9 position="0,-1300,-800" collisionType="static" scale=1 distance=40 checkpointindex=8 islast=false>
+ <RaceCheckPoint name="checkpoint9" position="0,-1300,-800" collisionType="static" scale="1" distance="40" checkpointindex="8" islast="false">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
<DistanceTrigger name="trigger8" position="0,0,0" distance=40 stayActive="true" />
@@ -229,7 +229,7 @@
</collisionShapes>
</RaceCheckPoint>
- <RaceCheckPoint name=checkpoint10 position="0,-2100,0" collisionType="static" scale=1 distance=40 checkpointindex=9 islast=true>
+ <RaceCheckPoint name="checkpoint10" position="0,-2100,0" collisionType="static" scale="1" distance="40" checkpointindex="9" islast="true" timelimit="150">
<attached>
<Model mass="50" scale="50" mesh="checkPoint.mesh" />
</attached>
Modified: code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc 2011-05-23 16:19:59 UTC (rev 8551)
+++ code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc 2011-05-23 16:35:35 UTC (rev 8552)
@@ -44,7 +44,7 @@
this->bCheckpointIndex_ = 0;
this->bIsLast_ = false;
- this->bTimeLimit_=0;
+ this->bTimeLimit_ = 0;
this->setRadarObjectColour(ColourValue::Red);
this->setRadarObjectShape(RadarViewable::Dot);
@@ -62,6 +62,14 @@
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true);
else this->setRadarVisibility(false);
+
+ if (this->bTimeLimit_ != 0 && gametype->getTimerIsActive()) {
+ float time = gametype->getTime() - this->bTimeLimit_;
+ if (time > 0) {
+ gametype->timeIsUp();
+ gametype->end();
+ }
+ }
}
Modified: code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spacerace/src/modules/gametypes/SpaceRace.cc 2011-05-23 16:19:59 UTC (rev 8551)
+++ code/branches/spacerace/src/modules/gametypes/SpaceRace.cc 2011-05-23 16:35:35 UTC (rev 8552)
@@ -42,6 +42,7 @@
{
RegisterObject(SpaceRace);
this->checkpointsReached_ = 0;
+ this->bTimeIsUp_ = false;
this->numberOfBots_ = 0;
}
@@ -52,26 +53,34 @@
void SpaceRace::end()
{
- Gametype::end();
- this->clock_->capture();
- int s = this->clock_->getSeconds();
- int ms = this->clock_->getMilliseconds()-1000*s;
- const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +
- "." + multi_cast<std::string>(ms) + " seconds.";
- COUT(0) << message << std::endl;
- const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- Host::Broadcast(message);
- float time = this->clock_->getSecondsPrecise();
- this->scores_.insert(time);
- std::set<float>::iterator it;
- for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
+ Gametype::end();
+ this->stopTimer();
+ if (this->bTimeIsUp_) {
+ COUT(0) << "Time is up" << std::endl;
+ const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up");
+ }
+ else {
+ this->clock_->capture();
+ int s = this->clock_->getSeconds();
+ int ms = this->clock_->getMilliseconds()-1000*s;
+ const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +
+ "." + multi_cast<std::string>(ms) + " seconds.";
+ COUT(0) << message << std::endl;
+ const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ Host::Broadcast(message);
+ float time = this->clock_->getSecondsPrecise();
+ this->scores_.insert(time);
+ std::set<float>::iterator it;
+ for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
COUT(0) << multi_cast<std::string>(*it) << std::endl;
+ }
}
void SpaceRace::start()
{
Gametype::start();
+ this->startTimer();
clock_= new Clock();
std::string message("The match has started! Reach the check points as quick as possible!");
COUT(0) << message << std::endl;
Modified: code/branches/spacerace/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spacerace/src/modules/gametypes/SpaceRace.h 2011-05-23 16:19:59 UTC (rev 8551)
+++ code/branches/spacerace/src/modules/gametypes/SpaceRace.h 2011-05-23 16:35:35 UTC (rev 8552)
@@ -76,14 +76,16 @@
{ this->checkpointsReached_ = n;}
inline int getCheckpointsReached()
{ return this->checkpointsReached_; }
+ inline void timeIsUp()
+ { this->bTimeIsUp_ = true;}
protected:
private:
int checkpointsReached_;
+ std::set<float> scores_;
Clock *clock_;
- std::set<float> scores_;
-
+ bool bTimeIsUp_;
};
}
More information about the Orxonox-commit
mailing list