[Orxonox-commit 6529] r11171 - in code/branches/tgidronFS16: data/levels data/levels/includes data/overlays src/modules/hover

tgidron at orxonox.net tgidron at orxonox.net
Thu Apr 21 15:37:28 CEST 2016


Author: tgidron
Date: 2016-04-21 15:37:28 +0200 (Thu, 21 Apr 2016)
New Revision: 11171

Added:
   code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc
   code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h
Removed:
   code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.cc
   code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.h
Modified:
   code/branches/tgidronFS16/data/levels/Hover.oxw
   code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi
   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/HoverShip.cc
   code/branches/tgidronFS16/src/modules/hover/HoverShip.h
Log:
Pickups work; Lives Counter and Total Flag Counter

Modified: code/branches/tgidronFS16/data/levels/Hover.oxw
===================================================================
--- code/branches/tgidronFS16/data/levels/Hover.oxw	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/data/levels/Hover.oxw	2016-04-21 13:37:28 UTC (rev 11171)
@@ -41,7 +41,7 @@
 </Template>
 
 <Template name=destroyhoverpickup baseclass=MetaPickup>
-  <MetaPickup representation="destroyhover" metaType="destroy" />
+  <MetaPickup representation="destroyhover" metaType="destroyCarrier" />
 </Template>
 
 <Level

Modified: code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi
===================================================================
--- code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/data/levels/includes/weaponSettingsHover.oxi	2016-04-21 13:37:28 UTC (rev 11171)
@@ -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     damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.8, 1, -18.0" projectileMesh="LaserBeam2.mesh" />
+      <EnergyDrink mode=0 munitionpershot=0 delay=0  material="Flares/point_lensflare" muzzleoffset=" 0.8, 1, -18.0" projectileMesh="LaserBeam2.mesh" />
     </Weapon>
   </WeaponPack>
   <WeaponPack>

Modified: code/branches/tgidronFS16/data/overlays/HoverHUD.oxo
===================================================================
--- code/branches/tgidronFS16/data/overlays/HoverHUD.oxo	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/data/overlays/HoverHUD.oxo	2016-04-21 13:37:28 UTC (rev 11171)
@@ -56,7 +56,7 @@
 
 
     <OverlayText
-     position  = "0.02, 0.02"
+     position  = "0.02, 0.08"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
      textsize  = 0.04
@@ -65,16 +65,37 @@
      caption   = "Total Flags: "
     />
 
-    <TotalFlagsHUD
+    <OverlayText
+     position  = "0.02, 0.12"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "Lives: "
+    />
+
+    <FlagsAndLivesHUD
      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"
+     showLives = false
+     />
 
-     showpoints     = true
-    />
+     <FlagsAndLivesHUD
+     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"
+     showLives = true
+
+     />
+
   </OverlayGroup>
 
 </Template>

Modified: code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/CMakeLists.txt	2016-04-21 13:37:28 UTC (rev 11171)
@@ -7,6 +7,7 @@
   TimeHUD.cc
   FlagHUD.cc
   MazeGenerator.cc
+  FlagsAndLivesHUD.cc
 )
 
 ORXONOX_ADD_LIBRARY(hover

Added: code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc	                        (rev 0)
+++ code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.cc	2016-04-21 13:37:28 UTC (rev 11171)
@@ -0,0 +1,92 @@
+/*
+ *   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;
+        }
+    }
+}

Added: code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h	                        (rev 0)
+++ code/branches/tgidronFS16/src/modules/hover/FlagsAndLivesHUD.h	2016-04-21 13:37:28 UTC (rev 11171)
@@ -0,0 +1,71 @@
+/*
+ *   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-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.cc	2016-04-21 13:37:28 UTC (rev 11171)
@@ -39,6 +39,7 @@
 #include "MazeGenerator.h"
 #include "core/CoreIncludes.h"
 #include "gamestates/GSLevel.h"
+#include "HoverShip.h"
 
 #include "pickup/PickupSpawner.h"
 #include "pickup/Pickup.h"
@@ -56,6 +57,7 @@
         this->firstTick_ = true;
         level = 1; //start at level 1
         flagsTaken = 0;// took 0 flags in the beginning
+        lives = 3;
 
         numCells = 0;
         cellSize = 0;
@@ -131,6 +133,10 @@
                 // Add pickup spawner to the pickup spawner list
                 pickupSpawners_.push_back(pickupSpawner);
             }
+             //If no lives are left, end game
+            if(lives <= 0){
+                GSLevel::startMainMenu();
+            }
 
             orxout() << this->origin_->getPickupTemplate() << endl;
             orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
@@ -152,10 +158,15 @@
         //Generate 5 PickupSpawners randomly
             for (int i = 0; i<5; i++)
             {
-                PickupSpawner* pickup = new PickupSpawner(origin_->getContext());
-                //PickupSpawner->setPosition(rand()%numCells, rand()%numCells, cellSize);
-                //pickup->createDroppedPickup(this->getContext(), pickup , this, 5);
-                pickupSpawners_.push_back(pickup);
+                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);
             }
 
             
@@ -184,6 +195,10 @@
 
         }
         numberOfFlags_ = flags_.size();
+
+        if(lives <= 0){
+                GSLevel::startMainMenu();
+            }
     }
 
     void Hover::levelUp()
@@ -197,4 +212,11 @@
     {
         return Vector3(x*cellSize*1.0f + cellSize/2, heightOffset, y*cellSize*1.0f + cellSize/2);
     }
+
+    void Hover::costLife()
+    {
+        lives--;
+        if (lives <= 0)
+            GSLevel::startMainMenu();
+    }
 }

Modified: code/branches/tgidronFS16/src/modules/hover/Hover.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.h	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.h	2016-04-21 13:37:28 UTC (rev 11171)
@@ -36,6 +36,7 @@
 #define _Hover_H__
 
 #include "HoverPrereqs.h"
+#include "HoverShip.h"
 
 #include <vector>
 
@@ -59,13 +60,21 @@
             void startLevel();
             void levelUp();
             void endLevel();
+            void costLife();
 
             inline int getNumberOfFlags() const
                 { return this->numberOfFlags_; }
 
             virtual Vector3 get3dCoordinates(int x, int y, float heightOffset);
 
+            inline int getTotFlags() const
+                { return this->totFlags; }
+
+            inline int getLives() const
+                { return this->lives; }
+
         private:
+
             WeakPtr<HoverOrigin> origin_;
             std::vector<HoverFlag*> flags_;
             int numberOfFlags_;

Modified: code/branches/tgidronFS16/src/modules/hover/HoverShip.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverShip.cc	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/HoverShip.cc	2016-04-21 13:37:28 UTC (rev 11171)
@@ -32,6 +32,7 @@
 #include "HoverShip.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "Hover.h"
 //#include "NewHumanController.h"
 
 #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
@@ -121,4 +122,20 @@
             this->isFloor_ = false;
         }
     }
+
+    Hover* HoverShip::getGame()
+    {
+        if (game == nullptr)
+        {
+            for (Hover* hover : ObjectList<Hover>())
+                game = hover;
+        }
+        return game;
+    }
+
+    void HoverShip::death()
+    {
+        getGame()->costLife();
+        SpaceShip::death();
+    }
 }

Modified: code/branches/tgidronFS16/src/modules/hover/HoverShip.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverShip.h	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/HoverShip.h	2016-04-21 13:37:28 UTC (rev 11171)
@@ -33,6 +33,7 @@
 #define _HoverShip_H__
 
 #include "HoverPrereqs.h"
+#include "Hover.h"
 
 #include "worldentities/pawns/SpaceShip.h"
 
@@ -68,7 +69,12 @@
 
             virtual void boost(bool bBoost) override;
 
+        protected:
+            virtual void death() override;
+
         private:
+            Hover* getGame();
+            WeakPtr<Hover> game;
             float jumpBoost_;
             bool isFloor_;
     };

Deleted: code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.cc	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.cc	2016-04-21 13:37:28 UTC (rev 11171)
@@ -1,77 +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 "TotFlagsHUD.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Convert.h"
-
-namespace orxonox
-{
-    RegisterClass(TotFlagsHUD);
-
-    TotFlagsHUD::TotFlagsHUD(Context* context) : OverlayText(context)
-    {
-        RegisterObject(TotFlagsHUD);
-
-        this->hoverGame_ = nullptr;
-        this->totFlags_ = 0;
-    }
-
-    void TotFlagsHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(TotFlagsHUD, XMLPort, xmlelement, mode);
-
-        XMLPortParam(TotFlagsHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode);
-    }
-
-    void TotFlagsHUD::tick(float dt)
-    {
-        SUPER(TotFlagsHUD, tick, dt);
-
-            const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
-                setTextSize(0.04);
-                setPosition(Vector2(0.14, 0.02));
-                this->setColour(ColourValue(1, 1, 1, 1));
-                this->setCaption(points);
-            
-    }
-
-    void TotFlagsHUD::changedOwner()
-    {
-        SUPER(TotFlagsHUD, changedOwner);
-
-        if (this->getOwner() && this->getOwner()->getGametype())
-        {
-            this->TotFlagsHUD = orxonox_cast<Hover*>(this->getOwner()->getGametype());
-        }
-        else
-        {
-            this->DodgeRaceGame = nullptr;
-        }
-    }
-}

Deleted: code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.h	2016-04-21 13:33:48 UTC (rev 11170)
+++ code/branches/tgidronFS16/src/modules/hover/TotFlagsHUD.h	2016-04-21 13:37:28 UTC (rev 11171)
@@ -1,61 +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:
- *      Cyrill Burgener
- *
- */
-
- /**
-    @file TimeHUD.h
-    @brief Declaration of the TimeHUD class.
-*/
-
-#include "HoverPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "overlays/OverlayText.h"
-
-namespace orxonox
-{
-    class _HoverExport TotFlagsHUD : public OverlayText, public Tickable
-    {
-        public:
-            TotFlagsHUD(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_; }
-
-
-        private:
-            Hover* hoverGame_;
-            int totFlags_;
-    };
-}
-#endif /* _TimeHUD_H__ */




More information about the Orxonox-commit mailing list