[Orxonox-commit 4288] r8959 - in code/branches/spaceraceTwo: data/levels src/modules/gametypes
eceline at orxonox.net
eceline at orxonox.net
Wed Dec 7 14:38:32 CET 2011
Author: eceline
Date: 2011-12-07 14:38:31 +0100 (Wed, 07 Dec 2011)
New Revision: 8959
Modified:
code/branches/spaceraceTwo/data/levels/Spacerace2.oxw
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
Log:
RaceCheckPoint::fire doesn't work
Modified: code/branches/spaceraceTwo/data/levels/Spacerace2.oxw
===================================================================
--- code/branches/spaceraceTwo/data/levels/Spacerace2.oxw 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/data/levels/Spacerace2.oxw 2011-12-07 13:38:31 UTC (rev 8959)
@@ -38,7 +38,7 @@
<SpaceRaceManager>
<checkpoints>
- <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="true">
+ <RaceCheckPoint name="checkpoint1" position="0,-200,100" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="0" islast="false" nextcheckpoints=(1,2,0)>
<attached>
<Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
</attached>
@@ -49,21 +49,46 @@
<BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" />
</collisionShapes>
</RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint2" position="0,-200,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints=(3,0,0)>
+ <attached>
+ <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" />
+ <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" />
+ </collisionShapes>
+ </RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint3" position="0,-400,200" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints=(3,0,0)>
+ <attached>
+ <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" />
+ <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" />
+ </collisionShapes>
+ </RaceCheckPoint>
+
+<RaceCheckPoint name="checkpoint4" position="0,-400,300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="3" islast="true">
+ <attached>
+ <Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="0,0,-55" halfExtents="55, 10, 10" />
+ <BoxCollisionShape position="55,0,0" halfExtents="10, 10, 55" />
+ <BoxCollisionShape position="-55,0,0" halfExtents="10, 10, 55" />
+ </collisionShapes>
+ </RaceCheckPoint>
</checkpoints>
</SpaceRaceManager>
- <SpaceShip position="0,2000,2000" lookat="0,0,0" team=1 >
- <templates>
- <Template link=spaceshipassff />
- </templates>
- <controller>
- <WaypointPatrolController alertnessradius=1500 team=0 >
- <waypoints>
- <Model scale=0 position="0,2000,2000" />
- </waypoints>
- </WaypointPatrolController>
- </controller>
- </SpaceShip>
+
<SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff2 />
Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc 2011-12-07 13:38:31 UTC (rev 8959)
@@ -33,6 +33,8 @@
#include "core/XMLPort.h"
#include "chat/ChatManager.h"
+#include <infos/PlayerInfo.h>
+
#include "SpaceRace.h"
namespace orxonox
@@ -50,8 +52,8 @@
this->setSimultaneousTriggerers(100);
- this->bCheckpointIndex_ = 0;
- //this->bIsLast_ = false;
+
+
this->bTimeLimit_ = 0;
this->isVisible_=true;
@@ -59,6 +61,7 @@
this->setRadarObjectShape(RadarViewable::Triangle);
this->setRadarVisibility(true);
+ this->reached_=NULL;
//this->addTarget("WorldEntity");
@@ -70,8 +73,8 @@
if (this->isInitialized())
{
- //for (size_t i = 0; i < 3; ++i)
- // this->nextcheckpoints_[i]->destroy();
+ for (size_t i = 0; i < this->next_.size(); ++i)
+ this->next_[i]->destroy();
}
//nextcheckpoints_.destroy;
}
@@ -120,21 +123,51 @@
//PlayerInfo* pl= player;
DistanceMultiTrigger::fire((bool)bIsTriggered,player);
- //SUPER(RaceCheckPoint,fire,bIsTriggered,player);
-
-
- SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+ SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
assert(gametype);
- PlayerInfo* player2 = (PlayerInfo*)player;
- assert(player2);
- //DistanceMultiTrigger::fire(bIsTriggered,player);
+
+
+ // BaseObject b=*player;
+ // PlayerInfo* p = orxonox_cast<PlayerInfo*,Player>(player);
+ //assert(player);
+ //PlayerInfo* player3=((PlayerInfo*) player);
+ Player* player3=((Player*) player);
+
+ PlayerInfo* player2=( PlayerInfo*) player;
+
+ for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
+ {
+ unsigned int clientid1=0, clientid2=0,clientid3=0;
+ if(it->first !=NULL)clientid1 = it->first->getClientID();
+
+ if(player3 != NULL && player3->info_ != NULL)clientid2 = player3->info_->getClientID();
+ if(player2 != NULL )clientid3 = player2->getClientID();
+ orxout()<<clientid1<<endl;orxout()<<clientid2<<endl;orxout()<<clientid3<<endl;
+ orxout()<<"for"<<endl;if(clientid1==clientid2) {orxout()<<"player"<<endl; player2=it->first;}if((it->first)==player2) {orxout()<<"player2"<<endl; }}
+
+ // PlayerInfo* player2 = orxonox_cast<PlayerInfo*>(player);
+ // assert(player);
+ //gametype->newCheckpointReached(this,player);
+ //if(bIsTriggered)this->reached_=player2;
+
+ /* for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
+ {if(gametype->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;if(player2==it->first)orxout()<<"e"<<endl;}
+ if(gametype->getCheckpointReached(player2)==-1) orxout()<<"my index -1"<<endl;
+ orxout()<<gametype->getCheckpointReached(player2)<<endl;
+
+ RaceCheckPoint* check=gametype->getCheckpointReached(player2);
-
+ bool b =false;
+ for(int i=0;i<3;i++){
+
+ if (check->getNext[i]==this){
+ b=true;}
+ }
- if (gametype && this->getCheckpointIndex() == gametype->getCheckpointReached(player2) && bIsTriggered)
+ if (gametype && b && bIsTriggered)
{
gametype->clock_.capture();
float time = gametype->clock_.getSecondsPrecise();
@@ -146,11 +179,16 @@
else if (this->getLast())
gametype->end();
else
+ gametype->newCheckpointReached(this,player2)
{
- gametype->newCheckpointReached(this,player2);
+
this->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
}
- }
+ }*/
+
+
+
+
}
void RaceCheckPoint::setTimelimit(float timeLimit)
Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h 2011-12-07 13:38:31 UTC (rev 8959)
@@ -31,6 +31,8 @@
#include "gametypes/GametypesPrereqs.h"
+
+
#include "objects/triggers/DistanceMultiTrigger.h"
#include "interfaces/RadarViewable.h"
@@ -61,17 +63,22 @@
inline const Vector3& getNextcheckpoint() const
{return this->nextcheckpoints_;}
+ inline void setNext(int index,RaceCheckPoint* p)
+ {this->next_[index]=p;}
+ inline void setLast(bool isLast)
+ { this->bIsLast_ = isLast; }
+ inline bool getLast()
+ { return this->bIsLast_; }
+ 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.
+ 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.
+ PlayerInfo* reached_;
+
inline void setV(bool b)
{this->isVisible_ = b;}
protected:
virtual void fire(bool bIsTriggered,BaseObject* player);
- inline void setLast(bool isLast)
- { this->bIsLast_ = isLast; }
- inline bool getLast()
- { return this->bIsLast_; }
-
+
-
virtual void setTimelimit(float timeLimit);
inline float getTimeLimit()
@@ -81,14 +88,14 @@
private:
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.
- 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.
- 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.
-
+
Vector3 nextcheckpoints_; //the indexes of the next check points
bool isVisible_;
-
+
+
+ std::vector<RaceCheckPoint*> next_;
};
}
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc 2011-12-07 13:38:31 UTC (rev 8959)
@@ -28,6 +28,8 @@
#include "SpaceRace.h"
+//#include "SpaceRaceManager.h"
+
#include "items/Engine.h"
#include "core/CoreIncludes.h"
@@ -53,7 +55,7 @@
for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- {this->checkpointReached_[it->first]=0;}
+ {this->checkpointReached_[it->first]=-1;}
}
@@ -139,12 +141,13 @@
ChatManager::message(message);
}
-
-
+ // for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
+ // {if(this->getCheckpointReached(it->first)==-1) orxout()<<"index -1"<<endl;}
+
}
- void SpaceRace::setV(SpaceRaceManager* m){
- /*Vector3 v =Vector3(0,0,0);
+ void SpaceRace::setV(SpaceRaceManager* m){/*
+ Vector3 v =Vector3(0,0,0);
int j=0;
for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
{
@@ -160,7 +163,7 @@
}
void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
- {
+ {/*
this->checkpointReached_[pl]=index;
this->clock_.capture();
int s = this->clock_.getSeconds();
@@ -170,7 +173,7 @@
+ " seconds.";
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
ChatManager::message(message);
-
+ */
}
@@ -193,7 +196,8 @@
void SpaceRace::playerEntered(PlayerInfo* player){
Gametype::playerEntered(player);
- //this->checkpointReached_[player]=0;
+
+ this->checkpointReached_[player]=-1;
//this->playersAlive_++;
}
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-12-07 13:38:31 UTC (rev 8959)
@@ -72,6 +72,7 @@
inline void timeIsUp()
{ this->bTimeIsUp_ = true;}
void tick(float dt);
+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.
void setV(SpaceRaceManager* m);
@@ -84,8 +85,7 @@
std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
std::set<float> scores_; //The times of the players are saved in a set.
bool bTimeIsUp_; //True if one of the check points is reached too late.
- 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.
-
+
int playersAlive_;
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc 2011-12-07 13:38:31 UTC (rev 8959)
@@ -45,6 +45,8 @@
{
RegisterObject(SpaceRaceManager);
+ for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+ this->setNext(this->checkpoints_[i]);
}
@@ -70,6 +72,17 @@
return 0;
}
+ int SpaceRaceManager::getIndex(RaceCheckPoint* r)
+ {
+
+ for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+ if (this->checkpoints_[i]==r){return i;}
+
+
+
+ return -1;
+ }
+
void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
@@ -84,9 +97,73 @@
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
gametype->setV(this);
+
+ for (size_t i = 0; i < this->checkpoints_.size(); ++i){
+ if(this->checkpoints_[i]->reached_!=NULL)
+ this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_);
+
+ }
+ }
+
+
+ void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player){
+ SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+ assert(gametype);
+
+ //if(gametype->getCheckpointReached(player)==-1) {orxout()<<"index -1"<<endl;}
+
+ bool b =false;
+ //DistanceMultiTrigger::fire(bIsTriggered,player);
+ int index=gametype->getCheckpointReached(player);
+ if (index>-1){
+ RaceCheckPoint* tmp= this->getCheckpoint(index);
+ Vector3 v= tmp->getNextcheckpoint();
+
+ // orxout()<<"index not -1"<<endl;
+ if (this->getCheckpoint(v.x)==check){
+ b=true;
+ }
+
+ if (this->getCheckpoint(v.y)==check){
+ b=true;
+ }
+ if (this->getCheckpoint(v.z)==check){
+ b=true;
+ } }
+ else{b=(this->getIndex(check)==0);}
+
+ if (gametype && b)
+ {
+ gametype->clock_.capture();
+ float time = gametype->clock_.getSecondsPrecise();
+ if (check->bTimeLimit_!=0 && time > check->bTimeLimit_)
+ {
+ gametype->timeIsUp();
+ gametype->end();
+ }
+ else if (check->getLast())
+ gametype->end();
+ else
+ {
+ gametype->newCheckpointReached(check,player);
+ check->setRadarObjectColour(ColourValue::Green); //sets the radar colour of the checkpoint to green if it is reached, else it is red.
+ }
+ }
+ check->reached_=NULL;
+ }
+
+
+
+ void SpaceRaceManager::setNext(RaceCheckPoint* check){
-
+ Vector3 v=check->getNextcheckpoint();
+ check->setNext(0,this->getCheckpoint(v.x));
+ check->setNext(1,this->getCheckpoint(v.y));
+ check->setNext(2,this->getCheckpoint(v.z));
+ }
+
+
}
-}
+
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h 2011-12-07 13:21:24 UTC (rev 8958)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h 2011-12-07 13:38:31 UTC (rev 8959)
@@ -57,11 +57,13 @@
virtual ~SpaceRaceManager() ;
void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
+ int getIndex(RaceCheckPoint* r);
void addCheckpoint(RaceCheckPoint* checkpoint);
RaceCheckPoint* getCheckpoint(unsigned int index) const;
+ void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
+ void setNext(RaceCheckPoint* check);
void tick(float dt);
protected:
More information about the Orxonox-commit
mailing list