- Timestamp:
- May 26, 2011, 10:03:32 PM (13 years ago)
- Location:
- code/branches/spacerace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spacerace/data/levels/spaceRace.oxw
r8573 r8616 40 40 41 41 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> 42 43 <SimpleNotification message="Reach the last check point within 150 seconds!!" /> 42 44 43 45 <!-- ------------------SpawnPoint----------------- --> … … 72 74 <attached> 73 75 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 74 <SpawnPoint position="0,0,0" lookat="0, 700,2700" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >76 <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 75 77 <events> 76 78 <activity> … … 106 108 <attached> 107 109 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 108 <SpawnPoint position="0,0,0" lookat="0, 2100,2300" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >110 <SpawnPoint position="0,0,0" lookat="0,1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 109 111 <events> 110 112 <activity> … … 141 143 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 142 144 <DistanceTrigger name="trigger3" position="0,0,0" distance=40 stayActive="true" /> 143 <SpawnPoint position="0,0,0" lookat="0, 2200,500" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >145 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 144 146 <events> 145 147 <activity> … … 176 178 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 177 179 <DistanceTrigger name="trigger4" position="0,0,0" distance=40 stayActive="true" /> 178 <SpawnPoint position="0,0,0" lookat="0, 1500,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >180 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 179 181 <events> 180 182 <activity> … … 211 213 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 212 214 <DistanceTrigger name="trigger5" position="0,0,0" distance=40 stayActive="true" /> 213 <SpawnPoint position="0,0,0" lookat="0, 200,-1900" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >215 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 214 216 <events> 215 217 <activity> … … 246 248 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 247 249 <DistanceTrigger name="trigger6" position="0,0,0" distance=40 stayActive="true" /> 248 <SpawnPoint position="0,0,0" lookat="0,- 700,-1400" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >250 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 249 251 <events> 250 252 <activity> … … 281 283 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 282 284 <DistanceTrigger name="trigger7" position="0,0,0" distance=40 stayActive="true" /> 283 <SpawnPoint position="0,0,0" lookat="0,-1 300,-800" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >285 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 284 286 <events> 285 287 <activity> … … 316 318 <Model mass="50" scale="50" mesh="checkPoint.mesh" /> 317 319 <DistanceTrigger name="trigger8" position="0,0,0" distance=40 stayActive="true" /> 318 <SpawnPoint position="0,0,0" lookat="0,- 2400,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" >320 <SpawnPoint position="0,0,0" lookat="0,-1000,0" spawnclass=SpaceShip pawndesign=spaceshipassff active="false" > 319 321 <events> 320 322 <activity> … … 443 445 444 446 <!-- ---------------SpaceShips----------------- --> 445 <SpaceShip position="0,2000,2000" lookat="0,0,0" >447 <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 > 446 448 <templates> 447 449 <Template link=spaceshipassff /> 448 450 </templates> 449 451 <controller> 450 <AIController /> 452 <WaypointPatrolController alertnessradius=1500 team=0 > 453 <waypoints> 454 <Model scale=0 position="0,2000,2000" /> 455 </waypoints> 456 </WaypointPatrolController> 451 457 </controller> 452 458 </SpaceShip> 453 459 460 <SpaceShip position="0,2000,-2000" lookat="0,0,0" team=1 > 461 <templates> 462 <Template link=spaceshipassff /> 463 </templates> 464 <controller> 465 <WaypointPatrolController alertnessradius=1500 team=0 > 466 <waypoints> 467 <Model scale=0 position="0,2000,-2000" /> 468 </waypoints> 469 </WaypointPatrolController> 470 </controller> 471 </SpaceShip> 472 454 473 </Scene> 455 474 </Level> -
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.cc
r8552 r8616 32 32 #include "core/XMLPort.h" 33 33 #include "SpaceRace.h" 34 #include "util/Convert.h" 34 35 35 36 namespace orxonox … … 47 48 this->bTimeLimit_ = 0; 48 49 49 this->setRadarObjectColour(ColourValue:: Red);50 this->setRadarObjectShape(RadarViewable:: Dot);50 this->setRadarObjectColour(ColourValue::Blue); 51 this->setRadarObjectShape(RadarViewable::Triangle); 51 52 this->setRadarVisibility(false); 52 53 } … … 63 64 if (this->getCheckpointIndex() == gametype->getCheckpointsReached()) this->setRadarVisibility(true); 64 65 else this->setRadarVisibility(false); 65 66 if (this->bTimeLimit_ != 0 && gametype->getTimerIsActive()) {67 float time = gametype->getTime() - this->bTimeLimit_;68 if (time > 0) {69 gametype->timeIsUp();70 gametype->end();71 }72 }73 66 } 74 67 … … 92 85 if (this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered) 93 86 { 94 if (this->getLast()) 87 gametype->clock_->capture(); 88 float time = gametype->clock_->getSecondsPrecise(); 89 if (this->bTimeLimit_!=0 && time > this->bTimeLimit_) { 90 gametype->timeIsUp(); 91 gametype->end(); 92 } 93 else if (this->getLast()) 95 94 { 96 95 gametype->end(); … … 105 104 } 106 105 106 void RaceCheckPoint::setTimelimit(float timeLimit) 107 { 108 this->bTimeLimit_ = timeLimit; 109 if (this->bTimeLimit_ != 0) 110 { 111 SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get()); 112 if (gametype) 113 { 114 const std::string& message = "You have " + multi_cast<std::string>(this->bTimeLimit_) 115 + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1) + "\n"; 116 COUT(0) << message; 117 const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message); 118 } 119 } 120 } 121 107 122 } -
code/branches/spacerace/src/modules/gametypes/RaceCheckPoint.h
r8548 r8616 38 38 namespace orxonox 39 39 { 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 controll the indexes of your check points and to set one last check point!!! 44 */ 40 45 class _ObjectsExport RaceCheckPoint : public DistanceTrigger, public RadarViewable 41 46 { … … 57 62 inline int getCheckpointIndex() 58 63 { return this->bCheckpointIndex_; } 59 inline void setTimelimit(int timeLimit) 60 { this->bTimeLimit_ = timeLimit;} 61 inline int getTimeLimit() 64 virtual void setTimelimit(float timeLimit); 65 inline float getTimeLimit() 62 66 { return this->bTimeLimit_;} 63 67 inline const WorldEntity* getWorldEntity() const … … 65 69 66 70 private: 67 int bCheckpointIndex_; 68 bool bIsLast_; 69 int bTimeLimit_;71 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. 72 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. 73 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. 70 74 71 75 }; -
code/branches/spacerace/src/modules/gametypes/SpaceRace.cc
r8573 r8616 42 42 { 43 43 RegisterObject(SpaceRace); 44 this-> checkpointsReached_ = 0;44 this->bCheckpointsReached_ = 0; 45 45 this->bTimeIsUp_ = false; 46 46 this->numberOfBots_ = 0; … … 55 55 { 56 56 Gametype::end(); 57 this->stopTimer();58 57 if (this->bTimeIsUp_) { 59 COUT(0) << "Time is up" << std::endl; 60 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage("Time is up"); 58 this->clock_->capture(); 59 int s = this->clock_->getSeconds(); 60 int ms = this->clock_->getMilliseconds()-1000*s; 61 const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n" 62 + "You didn't reach the check point" + multi_cast<std::string>(this->bCheckpointsReached_+1) 63 + " before the time limit. You loose!\n"; 64 COUT(0) << message; 65 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); 66 Host::Broadcast(message); 61 67 } 62 68 else { … … 64 70 int s = this->clock_->getSeconds(); 65 71 int ms = this->clock_->getMilliseconds()-1000*s; 66 const std::string& message = "You have reached the last check point after "+ multi_cast<std::string>(s) +67 "." + multi_cast<std::string>(ms) + " seconds.";72 const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s) 73 + "." + multi_cast<std::string>(ms) + " seconds.\n"; 68 74 COUT(0) << message << std::endl; 69 75 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); … … 81 87 Gametype::start(); 82 88 83 this->startTimer();84 89 clock_= new Clock(); 85 90 std::string message("The match has started! Reach the check points as quickly as possible!"); … … 90 95 void SpaceRace::newCheckpointReached() 91 96 { 92 this-> checkpointsReached_++;97 this->bCheckpointsReached_++; 93 98 this->clock_->capture(); 94 99 int s = this->clock_->getSeconds(); … … 96 101 const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached()) 97 102 + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) 98 + " seconds. ";103 + " seconds.\n"; 99 104 COUT(0) << message << std::endl; 100 105 const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message); -
code/branches/spacerace/src/modules/gametypes/SpaceRace.h
r8552 r8616 40 40 namespace orxonox 41 41 { 42 /* class PlayerScore { 43 public: 44 PlayerScore() { 45 this->name = ""; 46 this->time =0; 47 } 48 PlayerScore(std::string name, float time) { 49 this->name_ = name; 50 this->time_ = time; 51 } 52 PlayerScore(float time) { 53 this->name_ = "Player"; 54 this->time_ = time; 55 } 56 57 private: 58 std::string name_; 59 float time_; 60 };*/ 61 42 /** 43 @brief 44 The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order. 45 */ 62 46 class _OrxonoxExport SpaceRace : public Gametype 63 47 { … … 74 58 75 59 inline void setCheckpointsReached(int n) 76 { this-> checkpointsReached_ = n;}60 { this->bCheckpointsReached_ = n;} 77 61 inline int getCheckpointsReached() 78 { return this-> checkpointsReached_; }62 { return this->bCheckpointsReached_; } 79 63 inline void timeIsUp() 80 64 { this->bTimeIsUp_ = true;} 81 65 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. 82 66 protected: 83 67 84 68 private: 85 int checkpointsReached_; 86 std::set<float> scores_; 87 Clock *clock_; 88 bool bTimeIsUp_; 69 int bCheckpointsReached_; //The current number of check points reached by the player. 70 std::set<float> scores_; //The times of the players are saved in a set. 71 bool bTimeIsUp_; //True if one of the check points is reached too late. 89 72 }; 90 73 }
Note: See TracChangeset
for help on using the changeset viewer.