[Orxonox-commit 540] r3086 - in trunk/src/orxonox: objects/controllers objects/gametypes objects/worldentities/pawns overlays/hud
landauf at orxonox.net
landauf at orxonox.net
Wed May 27 01:44:48 CEST 2009
Author: landauf
Date: 2009-05-27 01:44:48 +0200 (Wed, 27 May 2009)
New Revision: 3086
Modified:
trunk/src/orxonox/objects/controllers/ArtificialController.cc
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
trunk/src/orxonox/overlays/hud/HUDRadar.cc
Log:
added bot-support for TeamBaseMatch (and some small fixes)
Modified: trunk/src/orxonox/objects/controllers/ArtificialController.cc
===================================================================
--- trunk/src/orxonox/objects/controllers/ArtificialController.cc 2009-05-26 19:27:15 UTC (rev 3085)
+++ trunk/src/orxonox/objects/controllers/ArtificialController.cc 2009-05-26 23:44:48 UTC (rev 3086)
@@ -35,6 +35,7 @@
#include "objects/gametypes/TeamDeathmatch.h"
#include "objects/controllers/WaypointPatrolController.h"
+#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
namespace orxonox
{
@@ -202,6 +203,40 @@
team2 = tdm->getTeam(entity2->getPlayer());
}
+ TeamBaseMatchBase* base = 0;
+ base = dynamic_cast<TeamBaseMatchBase*>(entity1);
+ if (base)
+ {
+ switch (base->getState())
+ {
+ case BaseState::controlTeam1:
+ team1 = 0;
+ break;
+ case BaseState::controlTeam2:
+ team1 = 1;
+ break;
+ case BaseState::uncontrolled:
+ default:
+ team1 = -1;
+ }
+ }
+ base = dynamic_cast<TeamBaseMatchBase*>(entity2);
+ if (base)
+ {
+ switch (base->getState())
+ {
+ case BaseState::controlTeam1:
+ team2 = 0;
+ break;
+ case BaseState::controlTeam2:
+ team2 = 1;
+ break;
+ case BaseState::uncontrolled:
+ default:
+ team2 = -1;
+ }
+ }
+
return (team1 == team2 && team1 != -1);
}
}
Modified: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-26 19:27:15 UTC (rev 3085)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-26 23:44:48 UTC (rev 3086)
@@ -40,7 +40,7 @@
RegisterObject(TeamBaseMatch);
this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));
- this->outputTimer_.setTimer(30, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
+ this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
this->pointsTeam1_ = 0;
this->pointsTeam2_ = 0;
@@ -78,9 +78,9 @@
{
std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
if (it != this->bases_.end())
- return (!this->pawnsAreInTheSameTeam(victim, base));
+ return (!this->pawnsAreInTheSameTeam(originator, base));
}
- return (!this->pawnsAreInTheSameTeam(victim, originator));
+ return TeamDeathmatch::allowPawnDamage(victim, originator);
}
bool TeamBaseMatch::pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base)
@@ -89,7 +89,7 @@
{
std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
int teamnrbase = -1;
- int teamnrplayer = getTeam(pawn1->getPlayer());
+ int teamnrplayer = this->getTeam(pawn1->getPlayer());
switch (base->getState())
{
@@ -105,9 +105,9 @@
}
if (teamnrbase == teamnrplayer)
- return false;
+ return true;
}
- return true;
+ return false;
}
@@ -125,8 +125,8 @@
void TeamBaseMatch::showPoints()
{
COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
- if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl;
- if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl;
+ if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
+ if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) COUT(0) << "Team 2 is near victory!" << std::endl;
}
@@ -156,9 +156,16 @@
// end game if one team reaches 2000 points
void TeamBaseMatch::endGame()
{
- if(this->pointsTeam1_>=2000 || this->pointsTeam2_ >=2000)
+ if (this->pointsTeam1_ >= 2000 || this->pointsTeam2_ >= 2000)
{
+ if (this->pointsTeam1_ > this->pointsTeam2_)
+ COUT(0) << "Team 1 has won the match" << std::endl;
+ else
+ COUT(0) << "Team 2 has won the match" << std::endl;
+
this->end();
+ this->scoreTimer_.stopTimer();
+ this->outputTimer_.stopTimer();
}
}
Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-05-26 19:27:15 UTC (rev 3085)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-05-26 23:44:48 UTC (rev 3086)
@@ -146,13 +146,10 @@
class _OrxonoxExport PawnListener : virtual public OrxonoxClass
{
- friend class Pawn;
-
public:
PawnListener();
virtual ~PawnListener() {}
- protected:
virtual void destroyedPawn(Pawn* pawn) = 0;
};
}
Modified: trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-05-26 19:27:15 UTC (rev 3085)
+++ trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-05-26 23:44:48 UTC (rev 3086)
@@ -47,6 +47,8 @@
{
gametype->addBase(this);
}
+
+ this->setRadarObjectShape(RadarViewable::Triangle);
}
void TeamBaseMatchBase::changeTeamColour()
@@ -69,7 +71,7 @@
break;
case BaseState::uncontrolled:
default:
- colour = ColourValue(0.5, 0.5, 0.7, 1.0);
+ colour = ColourValue(0.5, 0.5, 0.5, 1.0);
break;
}
@@ -83,6 +85,12 @@
tc->setTeamColour(colour);
}
}
+
+ this->setRadarObjectColour(colour);
+
+ // Call this so bots stop shooting at the base after they converted it
+ for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
+ it->destroyedPawn(this);
}
}
Modified: trunk/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDRadar.cc 2009-05-26 19:27:15 UTC (rev 3085)
+++ trunk/src/orxonox/overlays/hud/HUDRadar.cc 2009-05-26 23:44:48 UTC (rev 3086)
@@ -63,7 +63,7 @@
this->setMaximumDotSize(0.1f);
this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.tga";
- this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
+ this->shapeMaterials_[RadarViewable::Triangle] = "RadarTriangle.tga";
this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga";
this->owner_ = 0;
More information about the Orxonox-commit
mailing list