[Orxonox-commit 4270] r8941 - in code/branches/gamecontent/src: modules/weapons/weaponmodes orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Wed Nov 16 17:02:13 CET 2011
Author: jo
Date: 2011-11-16 17:02:12 +0100 (Wed, 16 Nov 2011)
New Revision: 8941
Modified:
code/branches/gamecontent/src/modules/weapons/weaponmodes/LightningGun.cc
code/branches/gamecontent/src/orxonox/gametypes/Mission.cc
code/branches/gamecontent/src/orxonox/gametypes/Mission.h
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
Log:
Object colouring added - according to current team implementation. Doesn't totally work as intended.
Modified: code/branches/gamecontent/src/modules/weapons/weaponmodes/LightningGun.cc
===================================================================
--- code/branches/gamecontent/src/modules/weapons/weaponmodes/LightningGun.cc 2011-11-16 15:20:26 UTC (rev 8940)
+++ code/branches/gamecontent/src/modules/weapons/weaponmodes/LightningGun.cc 2011-11-16 16:02:12 UTC (rev 8941)
@@ -51,7 +51,7 @@
this->reloadTime_ = 1.0f;
this->damage_ = 0.0f;
- this->speed_ = 250.0f;
+ this->speed_ = 700.0f;
this->setMunitionName("LaserMunition");
this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
Modified: code/branches/gamecontent/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Mission.cc 2011-11-16 15:20:26 UTC (rev 8940)
+++ code/branches/gamecontent/src/orxonox/gametypes/Mission.cc 2011-11-16 16:02:12 UTC (rev 8941)
@@ -29,6 +29,7 @@
#include "Mission.h"
//#include "TeamGametype.h"
#include "items/Engine.h"
+#include "controllers/ArtificialController.h"
#include "core/CoreIncludes.h"
#include "network/Host.h"
@@ -69,7 +70,7 @@
void Mission::start()
{
Gametype::start();
-
+ this->setTeams();
/*for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it != ObjectList<Engine>::end(); ++it)
it->setActive(false); // works -> @sr :*/
this->gtinfo_->sendAnnounceMessage("Your mission has started!");
@@ -86,4 +87,13 @@
this->gtinfo_->sendAnnounceMessage("Mission failed!");
* */
}
+
+ void Mission::setTeams()
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ this->setObjectColour(*it);
+ }
+
+
+
}
Modified: code/branches/gamecontent/src/orxonox/gametypes/Mission.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/Mission.h 2011-11-16 15:20:26 UTC (rev 8940)
+++ code/branches/gamecontent/src/orxonox/gametypes/Mission.h 2011-11-16 16:02:12 UTC (rev 8941)
@@ -45,6 +45,7 @@
virtual void start();
virtual void end();
+ virtual void setTeams();
virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
inline void setLives(unsigned int amount)
{this->lives_ = amount;}
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-16 15:20:26 UTC (rev 8940)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc 2011-11-16 16:02:12 UTC (rev 8941)
@@ -34,6 +34,7 @@
#include "interfaces/TeamColourable.h"
#include "worldentities/TeamSpawnPoint.h"
#include "worldentities/pawns/Pawn.h"
+#include "controllers/ArtificialController.h"
namespace orxonox
{
@@ -69,7 +70,12 @@
void TeamGametype::playerEntered(PlayerInfo* player)
{
Gametype::playerEntered(player);
+ if(player == NULL) return;
this->findAndSetTeam(player);
+ if( getNumberOfPlayers() < maxPlayers_ || maxPlayers_ == 0)
+ this->allowedInGame_[player]= true;
+ else
+ this->allowedInGame_[player]= false;
}
void TeamGametype::findAndSetTeam(PlayerInfo* player)
@@ -107,13 +113,16 @@
void TeamGametype::spawnDeadPlayersIfRequested()
{
- for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end();
-++it)
- if (it->second.state_ == PlayerState::Dead)
+ for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\
{
- if ((it->first->isReadyToSpawn() || this->bForceSpawn_))
+ if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow
+ continue;
+ if (it->second.state_ == PlayerState::Dead)
{
- this->spawnPlayer(it->first);
+ if ((it->first->isReadyToSpawn() || this->bForceSpawn_))
+ {
+ this->spawnPlayer(it->first);
+ }
}
}
}
@@ -208,6 +217,33 @@
if (!player)
return;
+ this->setTeamColour(player,pawn);
+ }
+
+ bool TeamGametype::pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2)
+ {
+ if (pawn1 && pawn2)
+ {
+ std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
+ std::map<PlayerInfo*, int>::const_iterator it2 = this->teamnumbers_.find(pawn2->getPlayer());
+
+ if (it1 != this->teamnumbers_.end() && it2 != this->teamnumbers_.end())
+ return (it1->second == it2->second);
+ }
+ return false;
+ }
+
+ int TeamGametype::getTeam(PlayerInfo* player)
+ {
+ std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
+ if (it_player != this->teamnumbers_.end())
+ return it_player->second;
+ else
+ return -1;
+ }
+
+ void TeamGametype::setTeamColour(PlayerInfo* player, Pawn* pawn)
+ {
// Set the team colour
std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < static_cast<int>(this->teamcolours_.size()))
@@ -229,25 +265,31 @@
}
}
- bool TeamGametype::pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2)
+ void TeamGametype::setObjectColour(Pawn* pawn)
{
- if (pawn1 && pawn2)
+ if(pawn == NULL)
+ return;
+ //get Pawn's controller
+ ArtificialController* controller = orxonox_cast<ArtificialController*>(pawn);
+ if(controller == NULL)
+ return;
+ //get Teamnumber - get the data
+ int teamnumber= controller->getTeam();
+ if(teamnumber < 0)
+ return;
+ //set ObjectColour
+ pawn->setRadarObjectColour(this->teamcolours_[teamnumber]);
+
+ std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
+ for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
{
- std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
- std::map<PlayerInfo*, int>::const_iterator it2 = this->teamnumbers_.find(pawn2->getPlayer());
-
- if (it1 != this->teamnumbers_.end() && it2 != this->teamnumbers_.end())
- return (it1->second == it2->second);
- }
- return false;
+ if ((*it)->isA(Class(TeamColourable)))
+ {
+ TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
+ tc->setTeamColour(this->teamcolours_[teamnumber]);
+ }
+ }
}
- int TeamGametype::getTeam(PlayerInfo* player)
- {
- std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
- if (it_player != this->teamnumbers_.end())
- return it_player->second;
- else
- return -1;
- }
+
}
Modified: code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h
===================================================================
--- code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-16 15:20:26 UTC (rev 8940)
+++ code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h 2011-11-16 16:02:12 UTC (rev 8941)
@@ -72,6 +72,9 @@
unsigned int teams_; //<! Number of teams. Value 0 : no teams!
//unsigned int playersPerTeam_; //<! Defines Maximum for players per team. Value 0: no maximum!
unsigned int maxPlayers_; //<! Defines Maximum for number of players. Value 0 : no maximum!
+ std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'.
+ void setTeamColour(PlayerInfo* player, Pawn* pawn);
+ void setObjectColour(Pawn* pawn);
};
}
More information about the Orxonox-commit
mailing list