[Orxonox-commit 567] r3104 - in trunk/src/orxonox: objects/gametypes overlays/hud
landauf at orxonox.net
landauf at orxonox.net
Thu May 28 05:37:34 CEST 2009
Author: landauf
Date: 2009-05-28 05:37:34 +0200 (Thu, 28 May 2009)
New Revision: 3104
Added:
trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc
trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h
trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.cc
trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h
Modified:
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h
trunk/src/orxonox/objects/gametypes/UnderAttack.cc
trunk/src/orxonox/overlays/hud/CMakeLists.txt
Log:
Added two new HUD-elements for TeamBaseMatch and UnderAttack
Modified: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-28 02:56:37 UTC (rev 3103)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-28 03:37:34 UTC (rev 3104)
@@ -45,6 +45,8 @@
this->pointsTeam1_ = 0;
this->pointsTeam2_ = 0;
+
+ this->setHUDTemplate("TeamBaseMatchHUD");
}
// Change the control of the defeated base and respawn it with its initial health
@@ -53,8 +55,9 @@
TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim);
if (base)
{
- if ( !originator )
+ if (!originator)
return false;
+
std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base);
if (it != this->bases_.end())
{
@@ -216,6 +219,35 @@
this->endGame();
}
+ int TeamBaseMatch::getTeamPoints(int team)
+ {
+ if(team == 0)
+ {
+ return this->pointsTeam1_;
+ }
+ if(team == 1)
+ {
+ return this->pointsTeam2_;
+ }
+
+ return 0;
+ }
+
+ int TeamBaseMatch::getTeamBases(int team)
+ {
+ int count = 0;
+
+ for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
+ {
+ if ((*it)->getState() == BaseState::controlTeam1 && team == 0)
+ count++;
+ if ((*it)->getState() == BaseState::controlTeam2 && team == 1)
+ count++;
+ }
+
+ return count;
+ }
+
void TeamBaseMatch::addBase(TeamBaseMatchBase* base)
{
this->bases_.insert(base);
Modified: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h 2009-05-28 02:56:37 UTC (rev 3103)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.h 2009-05-28 03:37:34 UTC (rev 3104)
@@ -54,6 +54,8 @@
TeamBaseMatchBase* getBase(unsigned int index) const;
void addTeamPoints(int team, int points);
+ int getTeamPoints(int team);
+ int getTeamBases(int team);
protected:
void winPoints();
Modified: trunk/src/orxonox/objects/gametypes/UnderAttack.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-05-28 02:56:37 UTC (rev 3103)
+++ trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-05-28 03:37:34 UTC (rev 3104)
@@ -49,6 +49,8 @@
this->destroyer_ = 0;
this->gameEnded_ = false;
+ this->setHUDTemplate("UnderAttackHUD");
+
this->setConfigValues();
this->timesequence_ = (int) this->gameTime_;
}
Modified: trunk/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-28 02:56:37 UTC (rev 3103)
+++ trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-28 03:37:34 UTC (rev 3104)
@@ -11,4 +11,6 @@
KillMessage.cc
DeathMessage.cc
PongScore.cc
+ UnderAttackHealthBar.cc
+ TeamBaseMatchScore.cc
)
Added: trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc 2009-05-28 03:37:34 UTC (rev 3104)
@@ -0,0 +1,127 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "TeamBaseMatchScore.h"
+
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "objects/gametypes/TeamBaseMatch.h"
+#include "objects/infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ CreateFactory(TeamBaseMatchScore);
+
+ TeamBaseMatchScore::TeamBaseMatchScore(BaseObject* creator) : OverlayText(creator)
+ {
+ RegisterObject(TeamBaseMatchScore);
+
+ this->owner_ = 0;
+
+ this->bShowBases_ = false;
+ this->bShowScore_ = false;
+ this->bShowLeftTeam_ = false;
+ this->bShowRightTeam_ = false;
+ }
+
+ TeamBaseMatchScore::~TeamBaseMatchScore()
+ {
+ }
+
+ void TeamBaseMatchScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TeamBaseMatchScore, XMLPort, xmlelement, mode);
+
+ XMLPortParam(TeamBaseMatchScore, "showbases", setShowBases, getShowBases, xmlelement, mode).defaultValues(false);
+ XMLPortParam(TeamBaseMatchScore, "showscore", setShowScore, getShowScore, xmlelement, mode).defaultValues(false);
+ XMLPortParam(TeamBaseMatchScore, "showleftteam", setShowLeftTeam, getShowLeftTeam, xmlelement, mode).defaultValues(false);
+ XMLPortParam(TeamBaseMatchScore, "showrightteam", setShowRightTeam, getShowRightTeam, xmlelement, mode).defaultValues(false);
+ }
+
+ void TeamBaseMatchScore::tick(float dt)
+ {
+ SUPER(TeamBaseMatchScore, tick, dt);
+
+ if (this->owner_)
+ {
+ std::string bases1 = "(" + convertToString(this->owner_->getTeamBases(0)) + ")";
+ std::string bases2 = "(" + convertToString(this->owner_->getTeamBases(1)) + ")";
+
+ std::string score1 = convertToString(this->owner_->getTeamPoints(0));
+ std::string score2 = convertToString(this->owner_->getTeamPoints(1));
+
+ std::string output1;
+ if (this->bShowLeftTeam_)
+ {
+ if (this->bShowBases_ && this->bShowScore_)
+ output1 = bases1 + " - " + score1;
+ else if (this->bShowScore_)
+ output1 = score1;
+ else if (this->bShowBases_)
+ output1 = bases1;
+ }
+
+ std::string output2;
+ if (this->bShowRightTeam_)
+ {
+ if (this->bShowBases_ && this->bShowScore_)
+ output2 = score2 + " - " + bases2;
+ else if (this->bShowScore_)
+ output2 = score2;
+ else if (this->bShowBases_)
+ output2 = bases2;
+ }
+
+ std::string output = "";
+ if (this->bShowBases_ || this->bShowScore_)
+ {
+ if (this->bShowLeftTeam_ && this->bShowRightTeam_)
+ output = output1 + ":" + output2;
+ else if (this->bShowLeftTeam_ || this->bShowRightTeam_)
+ output = output1 + output2;
+ }
+
+ this->setCaption(output);
+ }
+ }
+
+
+ void TeamBaseMatchScore::changedOwner()
+ {
+ SUPER(TeamBaseMatchScore, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ this->owner_ = dynamic_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
+ else
+ this->owner_ = 0;
+ }
+}
Property changes on: trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h
===================================================================
--- trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h 2009-05-28 03:37:34 UTC (rev 3104)
@@ -0,0 +1,77 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _TeamBaseMatchScore_H__
+#define _TeamBaseMatchScore_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport TeamBaseMatchScore : public OverlayText, public Tickable
+ {
+ public:
+ TeamBaseMatchScore(BaseObject* creator);
+ ~TeamBaseMatchScore();
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ inline void setShowBases(bool value)
+ { this->bShowBases_ = value; }
+ inline bool getShowBases() const
+ { return this->bShowBases_; }
+
+ inline void setShowScore(bool value)
+ { this->bShowScore_ = value; }
+ inline bool getShowScore() const
+ { return this->bShowScore_; }
+
+ inline void setShowLeftTeam(bool value)
+ { this->bShowLeftTeam_ = value; }
+ inline bool getShowLeftTeam() const
+ { return this->bShowLeftTeam_; }
+
+ inline void setShowRightTeam(bool value)
+ { this->bShowRightTeam_ = value; }
+ inline bool getShowRightTeam() const
+ { return this->bShowRightTeam_; }
+
+ private:
+ TeamBaseMatch* owner_;
+ bool bShowBases_;
+ bool bShowScore_;
+ bool bShowLeftTeam_;
+ bool bShowRightTeam_;
+ };
+}
+#endif /* _TeamBaseMatchScore_H__ */
Property changes on: trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.h
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.cc 2009-05-28 03:37:34 UTC (rev 3104)
@@ -0,0 +1,98 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "UnderAttackHealthBar.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/infos/PlayerInfo.h"
+#include "objects/gametypes/UnderAttack.h"
+#include "objects/worldentities/pawns/Destroyer.h"
+
+namespace orxonox
+{
+ CreateFactory(UnderAttackHealthBar);
+
+ UnderAttackHealthBar::UnderAttackHealthBar(BaseObject* creator) : HUDHealthBar(creator)
+ {
+ RegisterObject(UnderAttackHealthBar);
+
+ this->owner_ = 0;
+
+ this->text_ = new OverlayText(this);
+ this->text_->setFont("Monofur");
+ this->text_->setTextSize(0.04);
+ this->text_->setAlignmentString("center");
+ this->text_->setColour(ColourValue::White);
+ this->text_->setPickPoint(Vector2(0.5, 0));
+
+ this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init)));
+ }
+
+ UnderAttackHealthBar::~UnderAttackHealthBar()
+ {
+ if (this->isInitialized())
+ delete this->text_;
+ }
+
+ void UnderAttackHealthBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(UnderAttackHealthBar, XMLPort, xmlelement, mode);
+
+ XMLPortParam(UnderAttackHealthBar, "descriptionpickpoint", setDescriptionPickPoint, getDescriptionPickPoint, xmlelement, mode);
+ XMLPortParam(UnderAttackHealthBar, "descriptionoffset", setDescriptionOffset, getDescriptionOffset, xmlelement, mode);
+ }
+
+ void UnderAttackHealthBar::changedOwner()
+ {
+ SUPER(UnderAttackHealthBar, changedOwner);
+
+ PlayerInfo* player = dynamic_cast<PlayerInfo*>(this->getOwner());
+ if (player)
+ {
+ this->owner_ = player;
+
+ UnderAttack* ua = dynamic_cast<UnderAttack*>(player->getGametype());
+ if (ua)
+ {
+ this->setOwner(ua->getDestroyer());
+
+ if (ua->getTeam(player) == 0)
+ this->text_->setCaption("Attack the Transporter!");
+ else
+ this->text_->setCaption("Defend the Transporter!");
+ }
+ }
+ }
+
+ void UnderAttackHealthBar::init()
+ {
+ this->setOwner(this->owner_);
+ }
+}
Property changes on: trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h
===================================================================
--- trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h 2009-05-28 03:37:34 UTC (rev 3104)
@@ -0,0 +1,66 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _UnderAttackHealthBar_H__
+#define _UnderAttackHealthBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDHealthBar.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport UnderAttackHealthBar : public HUDHealthBar
+ {
+ public:
+ UnderAttackHealthBar(BaseObject* creator);
+ ~UnderAttackHealthBar();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ inline void setDescriptionPickPoint(const Vector2& pickpoint)
+ { this->text_->setPickPoint(pickpoint); }
+ inline Vector2 getDescriptionPickPoint() const
+ { return this->text_->getPickPoint(); }
+
+ inline void setDescriptionOffset(const Vector2& position)
+ { this->text_->setPosition(this->getPosition() + (position - this->getPickPoint()) * this->getSize()); }
+ inline Vector2 getDescriptionOffset() const
+ { return (this->text_->getPosition() - this->getPosition()) / this->getSize() + this->getPickPoint(); }
+
+ private:
+ void init();
+
+ PlayerInfo* owner_;
+ OverlayText* text_;
+ Timer<UnderAttackHealthBar> inittimer_;
+ };
+}
+#endif /* _UnderAttackHealthBar_H__ */
Property changes on: trunk/src/orxonox/overlays/hud/UnderAttackHealthBar.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list