[Orxonox-commit 2935] r7635 - in code/branches/lastmanstanding: data/overlays src/modules/overlays/hud src/orxonox/gametypes
jo at orxonox.net
jo at orxonox.net
Wed Nov 10 21:59:50 CET 2010
Author: jo
Date: 2010-11-10 21:59:50 +0100 (Wed, 10 Nov 2010)
New Revision: 7635
Added:
code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc
code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h
Modified:
code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo
code/branches/lastmanstanding/src/modules/overlays/hud/CMakeLists.txt
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
Log:
NON-compiling version. Work in Progress.
Modified: code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo
===================================================================
--- code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo 2010-11-10 15:22:58 UTC (rev 7634)
+++ code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo 2010-11-10 20:59:50 UTC (rev 7635)
@@ -19,5 +19,67 @@
colour = "1.0, 1.0, 0.5, 1.0"
align = "center"
/>
+ <!--LastManStandingInfos
+ position = "0.63, 0.05"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "0.8, 0.8, 1.0, 1.0"
+ align = "right"
+
+ showlives = true
+ showplayers = false
+ /-->
+
+ <OverlayText
+ position = "0.02, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Lives: "
+ />
+
+ <OverlayText
+ position = "0.02, 0.055"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Players: "
+ />
+
+ <OverlayText
+ position = "0.02, 0.07"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "__________|"
+ />
+
+ <OverlayText
+ position = "0.022, 0.07"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "__________"
+ />
+
+ <OverlayText
+ position = "0.1733, 0.038"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "|"
+ />
+
</OverlayGroup>
</Template>
Modified: code/branches/lastmanstanding/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/hud/CMakeLists.txt 2010-11-10 15:22:58 UTC (rev 7634)
+++ code/branches/lastmanstanding/src/modules/overlays/hud/CMakeLists.txt 2010-11-10 20:59:50 UTC (rev 7635)
@@ -14,4 +14,5 @@
TeamBaseMatchScore.cc
GametypeStaticMessage.cc
GametypeFadingMessage.cc
+ LastManStandingInfos.cc
)
Added: code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc (rev 0)
+++ code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc 2010-11-10 20:59:50 UTC (rev 7635)
@@ -0,0 +1,86 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+#include "LastManStandingInfos.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "gametypes/LastManStanding.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ CreateFactory(LastManStandingInfos);
+
+ LastManStandingInfos::LastManStandingInfos(BaseObject* creator) : OverlayText(creator)
+ {
+ RegisterObject(LastManStandingInfos);
+
+ this->owner_ = 0;
+ this->bShowLives_ = false;
+ this->bShowPlayers_ = false;
+ }
+
+ LastManStandingInfos::~LastManStandingInfos()
+ {
+ }
+
+ void LastManStandingInfos::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(LastManStandingInfos, XMLPort, xmlelement, mode);
+
+ XMLPortParam(LastManStandingInfos, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
+ XMLPortParam(LastManStandingInfos, "showplayers", setShowPlayers, getShowPlayers, xmlelement, mode).defaultValues(false);
+ }
+
+ void LastManStandingInfos::tick(float dt)
+ {
+ SUPER(LastManStandingInfos, tick, dt);
+
+ if (this->owner_)
+ {
+
+ Pawn* pawn = dynamic_cast<Pawn*>(this->getOwner()->getControllableEntity());
+ /*LastManStanding* */ owner_ = dynamic_cast<LastManStanding*>(this->getOwner()->getGametype());
+ int iLives = this->owner_->pawnGetLives(pawn);
+ const std::string& lives = multi_cast<std::string>(iLives);
+
+ const std::string& players = multi_cast<std::string>(this->owner_->playersAlive);
+
+ if (this->bShowLives_)
+ {
+ this->setCaption(lives);
+ }
+ else if(this->bShowPlayers_)
+ {
+ this->setCaption(players);
+ }
+ }
+ }
+}
Added: code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h (rev 0)
+++ code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h 2010-11-10 20:59:50 UTC (rev 7635)
@@ -0,0 +1,64 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _LastManStandingInfos_H__
+#define _LastManStandingInfos_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _OverlaysExport LastManStandingInfos : public OverlayText, public Tickable
+ {
+ public:
+ LastManStandingInfos(BaseObject* creator);
+ virtual ~LastManStandingInfos();
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ inline void setShowLives(bool value)
+ { this->bShowLives_ = value; }
+ inline bool getShowLives() const
+ { return this->bShowLives_; }
+
+ inline void setShowPlayers(bool value)
+ { this->bShowPlayers_ = value; }
+ inline bool getShowPlayers() const
+ { return this->bShowPlayers_; }
+
+ private:
+ LastManStanding* owner_;
+ bool bShowLives_;
+ bool bShowPlayers_;
+ };
+}
+#endif /* _LastManStandingInfos_H__ */
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-11-10 15:22:58 UTC (rev 7634)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc 2010-11-10 20:59:50 UTC (rev 7635)
@@ -146,7 +146,24 @@
}
}
+ int LastManStanding::pawnGetLives(Pawn* pawn)
+ {
+ if(!pawn)
+ return -1;
+ PlayerInfo* player= dynamic_cast<PlayerInfo*>(pawn);
+ if(!player)
+ return -2;
+ return playerLives_[player];
+ }
+ const int LastManStanding::playerGetLives(PlayerInfo* player)
+ {
+ if (player)
+ return playerLives_[player];
+ else
+ return 0;
+ }
+
void LastManStanding::playerEntered(PlayerInfo* player)
{
if (!player)// only for safety
@@ -223,14 +240,6 @@
}
}
- const int LastManStanding::playerGetLives(PlayerInfo* player)
- {
- if (player)
- return playerLives_[player];
- else
- return 0;
- }
-
void LastManStanding::punishPlayer(PlayerInfo* player)
{
if(!player)
Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-11-10 15:22:58 UTC (rev 7634)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h 2010-11-10 20:59:50 UTC (rev 7635)
@@ -72,12 +72,13 @@
virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives.
virtual void end(); //!< Sends an end message.
+ virtual int pawnGetLives(Pawn* pawn); //!< Returns amount of Lives of a certain player.
+ const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
virtual void playerEntered(PlayerInfo* player); //!< Initializes values. Manages the gametype's HUD. #Players alive via StaticMessage.
virtual bool playerLeft(PlayerInfo* player); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. player's lives via FadingMessage.
virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
- const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
void tick (float dt); //!< used to end the game
};
More information about the Orxonox-commit
mailing list