[Orxonox-commit 4297] r8968 - in code/branches/spaceraceTwo: data/levels src/modules/gametypes src/orxonox/controllers src/orxonox/infos
eceline at orxonox.net
eceline at orxonox.net
Thu Dec 8 18:07:32 CET 2011
Author: eceline
Date: 2011-12-08 18:07:32 +0100 (Thu, 08 Dec 2011)
New Revision: 8968
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
code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc
code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc
Log:
added waypoint patrol controller to level, RaceCheckPoint::fire works now
Modified: code/branches/spaceraceTwo/data/levels/Spacerace2.oxw
===================================================================
--- code/branches/spaceraceTwo/data/levels/Spacerace2.oxw 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/data/levels/Spacerace2.oxw 2011-12-08 17:07:32 UTC (rev 8968)
@@ -38,7 +38,7 @@
<SpaceRaceManager>
<checkpoints>
- <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)>
+ <RaceCheckPoint name="checkpoint1" position="0,-2000,1000" 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>
@@ -50,7 +50,7 @@
</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)>
+<RaceCheckPoint name="checkpoint2" position="0,2100,2300" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="1" islast="false" nextcheckpoints="3,-1,-1">
<attached>
<Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
</attached>
@@ -62,7 +62,7 @@
</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)>
+<RaceCheckPoint name="checkpoint3" position="0,700,2700" direction="0,-1,1" collisionType="static" scale="1" distance="40" checkpointindex="2" islast="false" nextcheckpoints="3,-1,-1">
<attached>
<Model mass="50" scale="50" mesh="raceCheckPoint.mesh" />
</attached>
@@ -89,8 +89,21 @@
</SpaceRaceManager>
+<SpaceShip position="0,0,200" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WaypointPatrolController alertnessradius=1000 team=10>
+ <waypoints>
+ <Model mesh="cube.mesh" scale=8 position="0,-2000,1000" />
+ <Model mesh="cube.mesh" scale=8 position="0,2100,2300" />
+ <Model mesh="cube.mesh" scale=8 position="0,-400,300" />
+ </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-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.cc 2011-12-08 17:07:32 UTC (rev 8968)
@@ -34,6 +34,7 @@
#include "chat/ChatManager.h"
#include <infos/PlayerInfo.h>
+#include <worldentities/ControllableEntity.h>
#include "SpaceRace.h"
@@ -55,12 +56,13 @@
this->bTimeLimit_ = 0;
- this->isVisible_=true;
+
this->setRadarObjectColour(ColourValue::Blue);
this->setRadarObjectShape(RadarViewable::Triangle);
- this->setRadarVisibility(true);
-
+
+ this->setRadarVisibility(false);
+ this->settingsChanged();
this->reached_=NULL;
//this->addTarget("WorldEntity");
@@ -71,12 +73,9 @@
RaceCheckPoint::~RaceCheckPoint()
{
- if (this->isInitialized())
- {
- for (size_t i = 0; i < this->next_.size(); ++i)
- this->next_[i]->destroy();
- }
- //nextcheckpoints_.destroy;
+
+
+
}
void RaceCheckPoint::tick(float dt)
@@ -85,25 +84,7 @@
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
assert(gametype);
- if(this->isVisible_){this->setRadarVisibility(true);}
- else{this->setRadarVisibility(false);}
-
-
-
- /*this->setRadarVisibility(false);
- Vector3 v =Vector3(0,0,0);
- int j=0;
- for (std::map<PlayerInfo*, Player>::iterator it = gametype->players_.begin(); it != gametype->players_.end(); ++it)
- {
- j=gametype->getCheckpointReached(it->first);
- RaceCheckPoint* r=SpaceRaceManager::getCheckpoint(j);
- v=r->getNextcheckpoint();
- for(int i=1;i<4;i++){
- if (this->getCheckpointIndex() == v[i])
- this->setRadarVisibility(true);
- }*/
- //}
}
void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -118,78 +99,15 @@
void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
{
-
- //bool b= bIsTriggered;
- //PlayerInfo* pl= player;
DistanceMultiTrigger::fire((bool)bIsTriggered,player);
SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
assert(gametype);
-
-
-
- // 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->second.info_ !=NULL)clientid1 = it->second.info_->getClientID();else orxout()<<"second NULL"<<endl;
- if(it->first !=NULL)clientid1 = it->first->getClientID();else orxout()<<"first NULL"<<endl;
- 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 && b && bIsTriggered)
- {
- gametype->clock_.capture();
- float time = gametype->clock_.getSecondsPrecise();
- if (this->bTimeLimit_!=0 && time > this->bTimeLimit_)
- {
- gametype->timeIsUp();
- gametype->end();
- }
- else if (this->getLast())
- gametype->end();
- else
- 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.
- }
- }*/
-
-
-
-
+ ControllableEntity* entity=(ControllableEntity*) player;
+
+ PlayerInfo* player2=entity->getPlayer();
+
+ if(bIsTriggered)this->reached_=player2;
}
void RaceCheckPoint::setTimelimit(float timeLimit)
Modified: code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/RaceCheckPoint.h 2011-12-08 17:07:32 UTC (rev 8968)
@@ -63,8 +63,7 @@
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()
@@ -73,16 +72,15 @@
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;}
+ inline float getTimeLimit()
+ { return this->bTimeLimit_;}
protected:
virtual void fire(bool bIsTriggered,BaseObject* player);
virtual void setTimelimit(float timeLimit);
- inline float getTimeLimit()
- { return this->bTimeLimit_;}
+
inline const WorldEntity* getWorldEntity() const
{ return this; }
@@ -92,9 +90,8 @@
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-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.cc 2011-12-08 17:07:32 UTC (rev 8968)
@@ -28,7 +28,6 @@
#include "SpaceRace.h"
-//#include "SpaceRaceManager.h"
#include "items/Engine.h"
@@ -99,8 +98,10 @@
void SpaceRace::start()
{
- //Gametype::start();
- this->spawnPlayersIfRequested(); Gametype::checkStart();
+
+ this->spawnPlayersIfRequested();
+
+ Gametype::checkStart();
this->cantMove_=true;
for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
@@ -141,56 +142,41 @@
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);
- int j=0;
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
- {
- j=this->getCheckpointReached(it->first);
- RaceCheckPoint* r=m->getCheckpoint(j);
- v=r->getNextcheckpoint();
- for(int i=1;i<4;i++){
- if(v[i]==0){
- RaceCheckPoint* n=m->getCheckpoint(v[i]);
- n->setV(true);
- }}
- }*/
- }
-
+
+
void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
- {/*
- this->checkpointReached_[pl]=index;
+ {
+ this->checkpointReached_[pl]=index;
this->clock_.capture();
- int s = this->clock_.getSeconds();
+ int s = this->clock_.getSeconds();
int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
- const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
+ const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
+ " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
- + " seconds.";
+ + " seconds.";
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
ChatManager::message(message);
- */
-
- }
-
+
+ }
+
void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
- { int index = p->getCheckpointIndex();
- this->checkpointReached_[pl]=index;
- this->clock_.capture();
- int s = this->clock_.getSeconds();
- int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
+ { int index = p->getCheckpointIndex();
+ this->checkpointReached_[pl]=index;
+ this->clock_.capture();
+ int s = this->clock_.getSeconds();
+ int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
- + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
+ + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
+ " seconds.";
- const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
- ChatManager::message(message);
-
-
- }
+ const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
+
+
+ }
+
@@ -211,4 +197,19 @@
// return valid_player;
}
+
+ bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
+ {
+ return false;
+ }
+
+ bool SpaceRace::allowPawnDamage(Pawn* victim, Pawn* originator)
+ {
+ return false;
+ }
+
+ bool SpaceRace::allowPawnDeath(Pawn* victim, Pawn* originator)
+ {
+ return false;
+ }
}
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRace.h 2011-12-08 17:07:32 UTC (rev 8968)
@@ -75,7 +75,11 @@
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);
+ bool allowPawnHit(Pawn* victim, Pawn* originator);
+
+ bool allowPawnDamage(Pawn* victim, Pawn* originator);
+
+ bool allowPawnDeath(Pawn* victim, Pawn* originator);
protected:
virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.cc 2011-12-08 17:07:32 UTC (rev 8968)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Mauro Salomon
+ * Celine Eggenberger
* Co-authors:
* ...
*
@@ -37,6 +37,8 @@
#include "util/Convert.h"
#include "util/Math.h"
+
+
namespace orxonox
{
CreateFactory(SpaceRaceManager);
@@ -45,9 +47,8 @@
{
RegisterObject(SpaceRaceManager);
- for (size_t i = 0; i < this->checkpoints_.size(); ++i)
- this->setNext(this->checkpoints_[i]);
-
+ this->firstcheckpointvisible_=false;
+
}
SpaceRaceManager::~SpaceRaceManager()
@@ -94,10 +95,10 @@
void SpaceRaceManager::tick(float dt)
{
SUPER(SpaceRaceManager,tick,dt);
- SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
- gametype->setV(this);
+
+ if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
+ {this->checkpoints_[0]->setRadarVisibility(true);this->firstcheckpointvisible_=false;}
-
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_);
@@ -110,16 +111,17 @@
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);
+ Vector3 v=Vector3 (-1,-1,-1);
if (index>-1){
RaceCheckPoint* tmp= this->getCheckpoint(index);
- Vector3 v= tmp->getNextcheckpoint();
+ v= tmp->getNextcheckpoint();
- // orxout()<<"index not -1"<<endl;
+
if (this->getCheckpoint(v.x)==check){
b=true;
}
@@ -136,7 +138,7 @@
{
gametype->clock_.capture();
float time = gametype->clock_.getSecondsPrecise();
- if (check->bTimeLimit_!=0 && time > check->bTimeLimit_)
+ if (check->getTimeLimit()!=0 && time > check->getTimeLimit())
{
gametype->timeIsUp();
gametype->end();
@@ -145,24 +147,40 @@
gametype->end();
else
{
+ if (index > -1)this->setRadVis(player,false);
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.
+
+
+
+ this->setRadVis(player, true);
+
}
}
check->reached_=NULL;
}
+ void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b){
+ SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+ assert(gametype);
+ int index=gametype->getCheckpointReached(player);
+ Vector3 v=Vector3(-1,-1,-1);
+ RaceCheckPoint* tmp= this->getCheckpoint(index);
+ v= tmp->getNextcheckpoint();
- 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));
- }
+ if(v.x > -1){this->getCheckpoint(v.x)->setRadarVisibility(b);
+ this->getCheckpoint(v.x)->settingsChanged();}
+ if(v.y > -1){this->getCheckpoint(v.y)->setRadarVisibility(b);
+ this->getCheckpoint(v.y)->settingsChanged();}
+ if(v.z > -1){this->getCheckpoint(v.z)->setRadarVisibility(b);
+ this->getCheckpoint(v.z)->settingsChanged();}
+ }
+
+
+
}
Modified: code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/modules/gametypes/SpaceRaceManager.h 2011-12-08 17:07:32 UTC (rev 8968)
@@ -41,6 +41,8 @@
#include "tools/interfaces/Tickable.h"
#include "RaceCheckPoint.h"
+
+
namespace orxonox
{
/**
@@ -63,14 +65,14 @@
void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
- void setNext(RaceCheckPoint* check);
+
void tick(float dt);
protected:
-
+ void setRadVis(PlayerInfo* player, bool b);
private:
std::vector<RaceCheckPoint*> checkpoints_;
-
+ bool firstcheckpointvisible_;
};
Modified: code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc
===================================================================
--- code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/orxonox/controllers/WaypointPatrolController.cc 2011-12-08 17:07:32 UTC (rev 8968)
@@ -77,7 +77,7 @@
}
void WaypointPatrolController::searchEnemy()
- {
+ {/*
this->patrolTimer_.setInterval(rnd());
if (!this->getControllableEntity())
@@ -100,6 +100,6 @@
}
if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
- this->target_ = 0;
+ this->target_ = 0;*/
}
}
Modified: code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc 2011-12-08 16:01:18 UTC (rev 8967)
+++ code/branches/spaceraceTwo/src/orxonox/infos/PlayerInfo.cc 2011-12-08 17:07:32 UTC (rev 8968)
@@ -56,6 +56,7 @@
this->updateGametypeInfo();
this->registerVariables();
+
}
PlayerInfo::~PlayerInfo()
More information about the Orxonox-commit
mailing list