[Orxonox-commit 6536] r11177 - in code/branches/tgidronFS16: data/levels data/levels/includes data/levels/templates data/overlays src/modules/hover
tgidron at orxonox.net
tgidron at orxonox.net
Thu Apr 28 16:04:42 CEST 2016
Author: tgidron
Date: 2016-04-28 16:04:42 +0200 (Thu, 28 Apr 2016)
New Revision: 11177
Added:
code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc
code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.h
Removed:
code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc
code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h
Modified:
code/branches/tgidronFS16/data/levels/Hover.oxw
code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi
code/branches/tgidronFS16/data/levels/templates/spaceshipHover.oxt
code/branches/tgidronFS16/data/overlays/HoverHUD.oxo
code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt
code/branches/tgidronFS16/src/modules/hover/Hover.cc
code/branches/tgidronFS16/src/modules/hover/Hover.h
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h
Log:
New Pickups (speed); Level Counter and Crate spawn (not working)
Modified: code/branches/tgidronFS16/data/levels/Hover.oxw
===================================================================
--- code/branches/tgidronFS16/data/levels/Hover.oxw 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/data/levels/Hover.oxw 2016-04-28 14:04:42 UTC (rev 11177)
@@ -23,7 +23,62 @@
MAZE_CELL_HEIGHT = 30
MAZE_SIZE = MAZE_NUM_CELLS*MAZE_CELL_SIZE
?>
+<!--
+<Template name=mediumdamagehoverpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1 >
+ <attached>
+ <Billboard position="0,0,0" colour="0.70,0.10,0.10" material="Damage" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+<Template name=damagehover baseclass=DamageBoostPickup>
+ <DamageBoostPickup
+ representation = "mediumdamagehoverpickup"
+ duration = 10.0
+ damageMultiplier = 5.0
+ activationType = "immediate"
+ durationType = "continuous"
+ />
+</Template> -->
+
+<Template name=hugespeedpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugespeedpickup baseclass=SpeedPickup>
+ <SpeedPickup
+ representation = "hugespeedpickup"
+ duration = 10.0
+ speedAdd = 0.0
+ SpeedMultiply = 50.0
+ activationType = "immediate"
+ durationType = "continuous"
+ />
+</Template>
+
+
+
<Template name=destroyhoverpickupRepresentation>
<PickupRepresentation>
<spawner-representation>
@@ -44,6 +99,18 @@
<MetaPickup representation="destroyhover" metaType="destroyCarrier" />
</Template>
+<Template name=obstacle baseclass=Pawn>
+ <Pawn team=1 health=30 position="0,100,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box RVName = "Box 4" >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" />
+ </collisionShapes>
+ </Pawn>
+</Template>
+
+
<Level
plugins = hover
gametype = Hover
@@ -71,14 +138,33 @@
inventoryRepresentation = "destroyHoverPickup"
/>
+ <PickupRepresentation
+ name = "hugespeedpickup"
+ pickupName = "Huge Speed Boost"
+ pickupDescription = "Multiplies Speed of the Ship by a huge amount."
+ spawnerTemplate = "hugespeedpickupRepresentation"
+ inventoryRepresentation = "HugeSpeed"
+ />
+<!--
+ <PickupRepresentation
+ name = "damagehover"
+ pickupName = "Medium Damage Hover Pickup"
+ pickupDescription = "Multiplies the ship damage with 5."
+ spawnerTemplate = "mediumdamagehoverpickupRepresentation"
+ inventoryRepresentation = "MediumDamageHover"
+ /> -->
+
<StaticEntity position="0,0,0" collisionType="static">
<attached>
<HoverOrigin
numCells="<?lua print(MAZE_NUM_CELLS)?>"
cellSize="<?lua print(MAZE_CELL_SIZE)?>"
cellHeight="<?lua print(MAZE_CELL_HEIGHT)?>"
+ obstacletemplate=obstacle
pickuptemplate=destroyhoverpickup
pickuprepresentationtemplate=destroyhoverpickupRepresentation
+ pickuptemplatedam=hugespeedpickup
+ pickuprepresentationtemplatedam=hugespeedpickupRepresentation
/>
<Model
position="<?lua print(MAZE_SIZE/2)?>,-16,<?lua print(MAZE_SIZE/2)?>"
Modified: code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi
===================================================================
--- code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi 2016-04-28 14:04:42 UTC (rev 11177)
@@ -16,7 +16,7 @@
<HsW01 mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1, 1,-18 " projectileMesh="LaserBeam2.mesh" />
</Weapon>
<Weapon>
- <EnergyDrink mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" muzzleoffset=" 0.8, 1, -18.0" projectileMesh="LaserBeam2.mesh" />
+ <EnergyDrink mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.8, 1, -18.0" projectileMesh="LaserBeam2.mesh" />
</Weapon>
</WeaponPack>
<WeaponPack>
Modified: code/branches/tgidronFS16/data/levels/templates/spaceshipHover.oxt
===================================================================
--- code/branches/tgidronFS16/data/levels/templates/spaceshipHover.oxt 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/data/levels/templates/spaceshipHover.oxt 2016-04-28 14:04:42 UTC (rev 11177)
@@ -78,7 +78,7 @@
<MultiStateEngine
boostfactor = 2
- speedfront = 120
+ speedfront = 150
speedback = 40
speedleftright = 40
speedupdown = 40
Modified: code/branches/tgidronFS16/data/overlays/HoverHUD.oxo
===================================================================
--- code/branches/tgidronFS16/data/overlays/HoverHUD.oxo 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/data/overlays/HoverHUD.oxo 2016-04-28 14:04:42 UTC (rev 11177)
@@ -75,27 +75,56 @@
caption = "Lives: "
/>
- <FlagsAndLivesHUD
+ <OverlayText
+ position = "0.02, 0.16"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Level: "
+ />
+
+ <TFlagsLivesLevelHUD
position = "0.14, 0.02"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
align = "left"
+ showFlags = true
showLives = false
+ showLevel = false
+
/>
- <FlagsAndLivesHUD
+ <TFlagsLivesLevelHUD
position = "0.14, 0.04"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
align = "left"
+ showFlags = false
showLives = true
+ showLevel = false
/>
+ <TFlagsLivesLevelHUD
+ position = "0.14, 0.06"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ showFlags = false
+ showLives = false
+ showLevel = true
+
+ />
+
+
</OverlayGroup>
</Template>
Modified: code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt 2016-04-28 14:04:42 UTC (rev 11177)
@@ -7,7 +7,7 @@
TimeHUD.cc
FlagHUD.cc
MazeGenerator.cc
- FlagsAndLivesHUD.cc
+ TFlagsLivesLevelHUD.cc
)
ORXONOX_ADD_LIBRARY(hover
Deleted: code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc 2016-04-28 14:04:42 UTC (rev 11177)
@@ -1,92 +0,0 @@
-/*
- * 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:
- * Tomer Gidron
- *
- */
-
-#include "FlagsAndLivesHUD.h"
-#include "HoverFlag.h"
-#include "Hover.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Convert.h"
-
-namespace orxonox
-{
- RegisterClass(FlagsAndLivesHUD);
-
- FlagsAndLivesHUD::FlagsAndLivesHUD(Context* context) : OverlayText(context)
- {
- RegisterObject(FlagsAndLivesHUD);
-
- this->hoverGame_ = nullptr;
- this->totFlags_ = 0;
- showLives_ = false;
- }
-
- void FlagsAndLivesHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(FlagsAndLivesHUD, XMLPort, xmlelement, mode);
-
- XMLPortParam(FlagsAndLivesHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode);
- XMLPortParam(FlagsAndLivesHUD, "showLives", setShowLives, getShowLives, xmlelement, mode);
- }
-
- void FlagsAndLivesHUD::tick(float dt)
- {
- SUPER(FlagsAndLivesHUD, tick, dt);
-
- const std::string& flags = multi_cast<std::string>(this->hoverGame_->getTotFlags());
- const std::string& lives = multi_cast<std::string>(this->hoverGame_->getLives());
-
- if(showLives_ == false){
- setTextSize(0.04);
- setPosition(Vector2(0.18, 0.08));
- this->setColour(ColourValue(1, 1, 1, 1));
- this->setCaption(flags);
- }
-
- else{
- setTextSize(0.04);
- setPosition(Vector2(0.18, 0.12));
- this->setColour(ColourValue(1, 1, 1, 1));
- this->setCaption(lives);
- }
-
- }
-
- void FlagsAndLivesHUD::changedOwner()
- {
- SUPER(FlagsAndLivesHUD, changedOwner);
-
- if (this->getOwner() && this->getOwner()->getGametype())
- {
- this->hoverGame_ = orxonox_cast<Hover*>(this->getOwner()->getGametype());
- }
- else
- {
- this->hoverGame_ = nullptr;
- }
- }
-}
Deleted: code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h 2016-04-28 14:04:42 UTC (rev 11177)
@@ -1,71 +0,0 @@
-/*
- * 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:
- * Tomer Gidron
- *
- */
-
- /**
- @file TimeHUD.h
- @brief Declaration of the TimeHUD class.
-*/
-
-#ifndef _FlagsAndLivesHUD_H__
-#define _FlagsAndLivesHUD_H__
-
-
-#include "HoverPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "overlays/OverlayText.h"
-
-namespace orxonox
-{
- class _HoverExport FlagsAndLivesHUD : public OverlayText, public Tickable
- {
- public:
- FlagsAndLivesHUD(Context* context);
-
- virtual void tick(float dt) override;
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
- virtual void changedOwner() override;
-
- /// sets TOTAL flags taken
- inline void setShowTot(int totFlags)
- { this->totFlags_ = totFlags; }
- /// returns total flags >=0
- inline int getShowTot() const
- { return this->totFlags_; }
-
- void setShowLives(const bool showLives)
- { showLives_ = showLives; }
-
- const bool getShowLives() const
- { return showLives_; }
-
- private:
- Hover* hoverGame_;
- int totFlags_;
- bool showLives_;
- };
-}
-#endif /* _FlagsAndLivesHUD_H__ */
\ No newline at end of file
Modified: code/branches/tgidronFS16/src/modules/hover/Hover.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.cc 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.cc 2016-04-28 14:04:42 UTC (rev 11177)
@@ -120,7 +120,7 @@
}
- //Generate 5 PickupSpawners randomly
+ //Generate 5 PickupSpawners randomly (destroy hover pickup)
for (int i = 0; i<5; i++)
{
PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
@@ -133,6 +133,31 @@
// Add pickup spawner to the pickup spawner list
pickupSpawners_.push_back(pickupSpawner);
}
+
+ //Generate 5 PickupSpawners randomly (damage pickup)
+ for (int i = 0; i<5; i++)
+ {
+ PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
+
+ pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
+ pickupSpawner->setPickupTemplateName(origin_->getPickupTemplateDam());
+ pickupSpawner->setMaxSpawnedItems(5);
+ pickupSpawner->setRespawnTime(30);
+ pickupSpawner->setTriggerDistance(5);
+ // Add pickup spawner to the pickup spawner list
+ pickupSpawners_.push_back(pickupSpawner);
+ }
+
+ //*****************************************************************************
+
+ Pawn* crate = new Pawn(origin_->getContext());
+
+ crate->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
+ crate->addTemplate(origin_->getObstacleTemplate());
+
+
+
+
//If no lives are left, end game
if(lives <= 0){
GSLevel::startMainMenu();
@@ -140,12 +165,15 @@
orxout() << this->origin_->getPickupTemplate() << endl;
orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
+
+ orxout() << this->origin_->getPickupTemplateDam() << endl;
+ orxout() << this->origin_->getPickupRepresentationTemplateDam() << endl;
}
}
- // Rename/delete this function.
- void Hover::startLevel()
+ // Start new level
+ void Hover::newLevel()
{
//Generate 5 flags randomly (test only 1 flag)
for ( int i = 0; i < 5; i++ )
@@ -154,21 +182,6 @@
flag->init(rand()%numCells, rand()%numCells, cellSize);
flags_.push_back(flag);
}
-
- //Generate 5 PickupSpawners randomly
- for (int i = 0; i<5; i++)
- {
- PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
-
- pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
- pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate());
- pickupSpawner->setMaxSpawnedItems(5);
- pickupSpawner->setRespawnTime(30);
- pickupSpawner->setTriggerDistance(5);
- // Add pickup spawner to the pickup spawner list
- pickupSpawners_.push_back(pickupSpawner);
- }
-
}
@@ -186,7 +199,7 @@
flags_.erase (flags_.begin()+i);
totFlags++;
if(flags_.size()<=0){
- ChatManager::message("Level Up!");
+ //ChatManager::message("Level Up!");
levelUp();
//GSLevel::startMainMenu();
@@ -204,7 +217,12 @@
void Hover::levelUp()
{
level++;
- startLevel();
+ //increment lives after every 4 levels
+ if(level%4 == 0)
+ {
+ lives++;
+ }
+ newLevel();
}
Modified: code/branches/tgidronFS16/src/modules/hover/Hover.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.h 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.h 2016-04-28 14:04:42 UTC (rev 11177)
@@ -57,7 +57,7 @@
{ this->origin_ = origin; }
void start();
- void startLevel();
+ void newLevel();
void levelUp();
void endLevel();
void costLife();
@@ -73,6 +73,9 @@
inline int getLives() const
{ return this->lives; }
+ inline int getLevel() const
+ { return this->level; }
+
private:
WeakPtr<HoverOrigin> origin_;
Modified: code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc 2016-04-28 14:04:42 UTC (rev 11177)
@@ -47,6 +47,9 @@
pickupTemplate_ = "";
pickupRepresentationTemplate_ = "";
+
+ pickupTemplateDam_ = "";
+ pickupRepresentationTemplateDam_ = "";
}
void HoverOrigin::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -58,8 +61,12 @@
XMLPortParam(HoverOrigin, "cellHeight", setCellHeight, getCellHeight, xmlelement, mode);
XMLPortParam(HoverOrigin, "pickuptemplate", setPickupTemplate, getPickupTemplate, xmlelement, mode);
XMLPortParam(HoverOrigin, "pickuprepresentationtemplate", setPickupRepresentationTemplate, getPickupRepresentationTemplate, xmlelement, mode);
+ XMLPortParam(HoverOrigin, "pickuptemplatedam", setPickupTemplateDam, getPickupTemplateDam, xmlelement, mode);
+ XMLPortParam(HoverOrigin, "pickuprepresentationtemplatedam", setPickupRepresentationTemplateDam, getPickupRepresentationTemplateDam, xmlelement, mode);
+ XMLPortParam(HoverOrigin, "obstacletemplate", setObstacleTemplate, getObstacleTemplate, xmlelement, mode);
}
+
void HoverOrigin::checkGametype()
{
if (getGametype() != nullptr && this->getGametype()->isA(Class(Hover)))
Modified: code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h 2016-04-28 13:45:32 UTC (rev 11176)
+++ code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h 2016-04-28 14:04:42 UTC (rev 11177)
@@ -65,6 +65,8 @@
inline int getCellHeight() const
{ return this->cellHeight_; }
+ //pickup template set and get for destroy hover pickup
+
inline void setPickupTemplate(std::string pickupTemplate)
{ this->pickupTemplate_ = pickupTemplate; }
inline std::string getPickupTemplate() const
@@ -75,8 +77,28 @@
inline std::string getPickupRepresentationTemplate() const
{ return this->pickupRepresentationTemplate_; }
+ //pickup template get and set for damage hover pickup
+
+ inline void setPickupTemplateDam(std::string pickupTemplateDam)
+ { this->pickupTemplateDam_ = pickupTemplateDam; }
+ inline std::string getPickupTemplateDam() const
+ { return this->pickupTemplateDam_; }
+
+ inline void setPickupRepresentationTemplateDam(std::string pickupRepresenationaTemplateDam)
+ { this->pickupRepresentationTemplateDam_ = pickupRepresenationaTemplateDam; }
+ inline std::string getPickupRepresentationTemplateDam() const
+ { return this->pickupRepresentationTemplateDam_; }
+
+ //get and set for obstacle template
+
+ inline void setObstacleTemplate(std::string obstacleTemplate)
+ { this->obstacleTemplate_ = obstacleTemplate; }
+ inline std::string getObstacleTemplate() const
+ { return this->obstacleTemplate_; }
+
private:
void checkGametype();
+
int numCells_;
int cellSize_;
@@ -85,6 +107,13 @@
// Tempaltes for the destroy hover pickup
std::string pickupTemplate_;
std::string pickupRepresentationTemplate_;
+
+ // Tempaltes for the damage hover pickup
+ std::string pickupTemplateDam_;
+ std::string pickupRepresentationTemplateDam_;
+
+ //Template for crate obstacle
+ std::string obstacleTemplate_;
};
}
Added: code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc (rev 0)
+++ code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.cc 2016-04-28 14:04:42 UTC (rev 11177)
@@ -0,0 +1,104 @@
+/*
+ * 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:
+ * Tomer Gidron
+ *
+ */
+
+#include "TFlagsLivesLevelHUD.h"
+#include "HoverFlag.h"
+#include "Hover.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+ RegisterClass(TFlagsLivesLevelHUD);
+
+ TFlagsLivesLevelHUD::TFlagsLivesLevelHUD(Context* context) : OverlayText(context)
+ {
+ RegisterObject(TFlagsLivesLevelHUD);
+
+ this->hoverGame_ = nullptr;
+ this->totFlags_ = 0;
+ showLives_ = true;
+ showLevel_ = true;
+ showTotFlags_= true;
+ }
+
+ void TFlagsLivesLevelHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TFlagsLivesLevelHUD, XMLPort, xmlelement, mode);
+
+ XMLPortParam(TFlagsLivesLevelHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode);
+ XMLPortParam(TFlagsLivesLevelHUD, "showLives", setShowLives, getShowLives, xmlelement, mode);
+ XMLPortParam(TFlagsLivesLevelHUD, "showLevel", setShowLevel, getShowLevel, xmlelement, mode);
+ }
+
+ void TFlagsLivesLevelHUD::tick(float dt)
+ {
+ SUPER(TFlagsLivesLevelHUD, tick, dt);
+
+ const std::string& flags = multi_cast<std::string>(this->hoverGame_->getTotFlags());
+ const std::string& lives = multi_cast<std::string>(this->hoverGame_->getLives());
+ const std::string& level = multi_cast<std::string>(this->hoverGame_->getLevel());
+
+ if(showTotFlags_ == true){
+ setTextSize(0.04);
+ setPosition(Vector2(0.18, 0.08));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(flags);
+ }
+
+
+ if(showLives_ == true){
+ setTextSize(0.04);
+ setPosition(Vector2(0.18, 0.12));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(lives);
+ }
+
+ if(showLevel_ == true){
+ setTextSize(0.04);
+ setPosition(Vector2(0.18, 0.16));
+ this->setColour(ColourValue(1, 1, 1, 1));
+ this->setCaption(level);
+ }
+
+ }
+
+ void TFlagsLivesLevelHUD::changedOwner()
+ {
+ SUPER(TFlagsLivesLevelHUD, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->hoverGame_ = orxonox_cast<Hover*>(this->getOwner()->getGametype());
+ }
+ else
+ {
+ this->hoverGame_ = nullptr;
+ }
+ }
+}
Added: code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.h (rev 0)
+++ code/branches/tgidronFS16/src/modules/hover/TFlagsLivesLevelHUD.h 2016-04-28 14:04:42 UTC (rev 11177)
@@ -0,0 +1,96 @@
+/*
+ * 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:
+ * Tomer Gidron
+ *
+ */
+
+ /**
+ @file TFlagsLivesLevelHUD.h
+ @brief Declaration of the TFlagsLivesLevelHUD class.
+*/
+
+#ifndef _TFlagsLivesLevelHUD_H__
+#define _TFlagsLivesLevelHUD_H__
+
+
+#include "HoverPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _HoverExport TFlagsLivesLevelHUD : public OverlayText, public Tickable
+ {
+ public:
+ TFlagsLivesLevelHUD(Context* context);
+
+ virtual void tick(float dt) override;
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void changedOwner() override;
+
+ /// sets TOTAL flags taken
+ inline void setShowTot(int totFlags)
+ { this->totFlags_ = totFlags; }
+ /// returns total flags >=0
+ inline int getShowTot() const
+ { return this->totFlags_; }
+
+ /// sets show tot lives
+ void setShowLives(const bool showLives)
+ { showLives_ = showLives; }
+ /// gets show tot lives
+ const bool getShowLives() const
+ { return showLives_; }
+
+ /// sets show level
+ void setShowLevel(const bool showLevel)
+ { showLevel_ = showLevel; }
+ /// gets show level
+ const bool getShowLevel() const
+ { return showLevel_; }
+
+ /// sets show tot flags
+ void setShowTotFlags(const bool showTotFlags)
+ { showTotFlags_ = showTotFlags; }
+ /// gets show tot flags
+ const bool getShowTotFlags() const
+ { return showTotFlags_; }
+
+ /// sets Game Level
+ inline void setTotLevel(int totLevel)
+ { this->totLevel_ = totLevel; }
+ /// returns level >=0
+ inline int getTotLevel() const
+ { return this->totLevel_; }
+
+ private:
+ Hover* hoverGame_;
+ int totFlags_;
+ int totLevel_;
+ bool showLives_;
+ bool showLevel_;
+ bool showTotFlags_;
+ };
+}
+#endif /* _TFlagsLivesLevelHUD_H__ */
\ No newline at end of file
More information about the Orxonox-commit
mailing list