[Orxonox-commit 397] r2985 - in branches/gametypes/src/orxonox/objects: gametypes worldentities/pawns
vmikos at orxonox.net
vmikos at orxonox.net
Mon May 18 17:01:45 CEST 2009
Author: vmikos
Date: 2009-05-18 17:01:45 +0200 (Mon, 18 May 2009)
New Revision: 2985
Modified:
branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc
branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h
branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h
branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
Log:
final version
Modified: branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-18 14:52:26 UTC (rev 2984)
+++ branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-18 15:01:45 UTC (rev 2985)
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Author:
+ * Author: Val Mikos
*/
@@ -27,7 +27,6 @@
#include "TeamBaseMatch.h"
-//implement this! not done yet!
#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -98,6 +97,53 @@
return TeamDeathmatch::allowPawnDeath(victim, originator);
}
+
+ // if the player is in the same team as the base, he can't make any damage to it
+ bool TeamBaseMatch::allowPawnDamage(Pawn* victim, Pawn* originator)
+ {
+ TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
+ if (base)
+ {
+ std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
+ if (it != this->bases_.end())
+ return (!this->pawnsAreInTheSameTeam(victim, base));
+ }
+ return (!this->pawnsAreInTheSameTeam(victim, originator));
+ }
+
+ bool TeamBaseMatch::pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base)
+ {
+ if (pawn1 && base)
+ {
+ std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
+ int teamnrbase = -1;
+ int teamnrplayer = getTeam(pawn1->getPlayer());
+
+ switch(base->getState())
+ {
+ case BaseState::controlTeam1:
+ teamnrbase = 0;
+ break;
+ case BaseState::controlTeam2:
+ teamnrbase = 1;
+ break;
+ case BaseState::uncontrolled:
+ default:
+ teamnrbase = -1;
+ }
+
+
+ if(teamnrbase == teamnrplayer){
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+
+
+
// collect Points for killing oppenents
void TeamBaseMatch::playerScored(PlayerInfo* player)
{
@@ -180,16 +226,7 @@
}
return 0;
}
-
-
- // declare the functions 'getshape' and 'setshape' from the XML function here
-
-
-
-
}
-
-
Modified: branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h 2009-05-18 14:52:26 UTC (rev 2984)
+++ branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h 2009-05-18 15:01:45 UTC (rev 2985)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Val Mikos
*
*/
@@ -58,6 +58,10 @@
virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+ virtual bool allowPawnDamage(Pawn* victim, Pawn* originator);
+
+
+
// give information about the state of a base
// (this should be pretty useless atm)
// virtual int baseState(Base);
@@ -77,6 +81,10 @@
protected:
void winPoints();
+
+ bool pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base);
+ using TeamDeathmatch::pawnsAreInTheSameTeam;
+
std::set<TeamBaseMatchBase*> bases_;
Timer<TeamBaseMatch> scoreTimer_;
Timer<TeamBaseMatch> outputTimer_;
Modified: branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h 2009-05-18 14:52:26 UTC (rev 2984)
+++ branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h 2009-05-18 15:01:45 UTC (rev 2985)
@@ -54,6 +54,9 @@
virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
+ inline const ColourValue& getTeamColour(int teamnr) const
+ { return this->teamcolours_[teamnr]; }
+
protected:
virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
Modified: branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-05-18 14:52:26 UTC (rev 2984)
+++ branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-05-18 15:01:45 UTC (rev 2985)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Val Mikos
*
*/
@@ -30,6 +30,7 @@
#include "TeamBaseMatchBase.h"
#include "core/CoreIncludes.h"
#include "objects/gametypes/TeamBaseMatch.h"
+#include "objects/Teamcolourable.h"
namespace orxonox
{
@@ -47,5 +48,41 @@
gametype->addBase(this);
}
}
+
+ void TeamBaseMatchBase::changeTeamColour()
+ {
+ this->fireEvent();
+
+ TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
+ if (!gametype)
+ return;
+
+ ColourValue colour;
+
+ switch (this->state_)
+ {
+ case BaseState::controlTeam1:
+ colour = gametype->getTeamColour(0);
+ break;
+ case BaseState::controlTeam2:
+ colour = gametype->getTeamColour(1);
+ break;
+ case BaseState::uncontrolled:
+ default:
+ colour = ColourValue(0.5, 0.5, 0.7, 1.0);
+ break;
+ }
+
+
+ std::set<WorldEntity*> attachments = this->getAttachedObjects();
+ for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
+ {
+ if ((*it)->isA(Class(Teamcolourable)))
+ {
+ Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
+ tc->setTeamColour(colour);
+ }
+ }
+ }
}
Modified: branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h 2009-05-18 14:52:26 UTC (rev 2984)
+++ branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h 2009-05-18 15:01:45 UTC (rev 2985)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Val Mikos
*
*/
@@ -69,6 +69,7 @@
void setState(BaseState::Enum state)
{
this->state_ = state;
+ this->changeTeamColour();
}
@@ -80,6 +81,7 @@
protected:
+ void changeTeamColour();
BaseState::Enum state_;
};
More information about the Orxonox-commit
mailing list