[Orxonox-commit 7026] r11645 - in code/branches/Asteroid_HS17: data/levels/includes data/levels/templates data/overlays src/modules/asteroids2D

vyang at orxonox.net vyang at orxonox.net
Sat Dec 9 13:29:44 CET 2017


Author: vyang
Date: 2017-12-09 13:29:44 +0100 (Sat, 09 Dec 2017)
New Revision: 11645

Added:
   code/branches/Asteroid_HS17/data/levels/includes/asteroids2DWeapon.oxi
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h
Modified:
   code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt
   code/branches/Asteroid_HS17/data/overlays/Asteroids2DHUD.oxo
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
   code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
   code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt
Log:
Asteroids2DShip ist 3s immun, nachdem es von einem Asteroiden getroffen wurde. Das Raumschiff hat nun eine Waffe -> Richtung der Projektile muss noch angepasst werden

Added: code/branches/Asteroid_HS17/data/levels/includes/asteroids2DWeapon.oxi
===================================================================
--- code/branches/Asteroid_HS17/data/levels/includes/asteroids2DWeapon.oxi	                        (rev 0)
+++ code/branches/Asteroid_HS17/data/levels/includes/asteroids2DWeapon.oxi	2017-12-09 12:29:44 UTC (rev 11645)
@@ -0,0 +1,30 @@
+    <weaponslots>
+      <WeaponSlot position="-9.2,2,-13" />
+      <WeaponSlot position=" 9.2,2,-13" />
+    </weaponslots>
+    <weaponsets>
+      <WeaponSet firemode=0 />
+      <WeaponSet firemode=1 />
+    </weaponsets>
+    <weaponpacks>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+          <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+        </links>
+        <Weapon>
+          <Asteroids2DWeapon mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" projectileMesh="laserbeam.mesh" />
+        </Weapon>
+        <Weapon>
+          <Asteroids2DWeapon mode=0 munitionpershot=0 delay=0     damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" projectileMesh="laserbeam.mesh" />
+        </Weapon>
+      </WeaponPack>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=1 weaponmode=0 />
+        </links>
+      </WeaponPack>
+    </weaponpacks>
+    <munition>
+      <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
+    </munition>

Modified: code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt
===================================================================
--- code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt	2017-12-09 12:29:44 UTC (rev 11645)
@@ -42,8 +42,8 @@
    
   >
     <engines>
-      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipinvaderengine />
-      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipinvaderengine />
+      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipasteroids2dengine />
+      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipasteroids2dengine />
     </engines>
     <attached>
       <Model position="0,0,0" yaw=90 pitch=0 roll=0 scale=4 mesh="escortShip.mesh" />
@@ -71,7 +71,7 @@
       <ExplosionPart mesh="WingDebris2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
     </explosion>
 <?lua
-  include("../includes/invaderWeapon.oxi")
+  include("../includes/asteroids2DWeapon.oxi")
 ?>
   </Asteroids2DShip>
 </Template>
@@ -92,7 +92,7 @@
   </Asteroids2DShip>
 </Template>
 
-<Template name=spaceshipinvaderengine baseclass=MultiStateEngine>
+<Template name=spaceshipasteroids2dengine baseclass=MultiStateEngine>
   <MultiStateEngine
    boostfactor    = 2.2
 
@@ -110,6 +110,8 @@
    accelerationleftright =  500
    accelerationupdown    =  500
   >
+
+  <!-- backlight error if you fly over the edge
     <EffectContainer condition="idle">
       <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
     </EffectContainer>
@@ -129,5 +131,7 @@
       <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
     </EffectContainer>
 
+  -->
+
   </MultiStateEngine>
 </Template>
\ No newline at end of file

Modified: code/branches/Asteroid_HS17/data/overlays/Asteroids2DHUD.oxo
===================================================================
--- code/branches/Asteroid_HS17/data/overlays/Asteroids2DHUD.oxo	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/data/overlays/Asteroids2DHUD.oxo	2017-12-09 12:29:44 UTC (rev 11645)
@@ -7,6 +7,29 @@
   <OverlayGroup name="Asteroids2DHUD" scale = "1, 1">
 
     <OverlayText
+     position  = "0.02, 0.1"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "Lives:   "
+    />
+
+    <Asteroids2DHUDinfo
+     position  = "0.14, 0.1"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+
+     showlives     = true
+     showlevel     = false
+     showpoints     = false
+    />
+
+    <OverlayText
      position  = "0.02, 0.02"
      pickpoint = "0.0, 0.0"
      font      = "ShareTechMono"
@@ -27,6 +50,29 @@
      showpoints     = true
     />
 
+    <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   = "Level: "
+    />
+
+    <Asteroids2DHUDinfo
+     position  = "0.14, 0.055"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+
+     showlives     = false
+     showlevel     = true
+     showpoints     = false
+    />
+
     
   </OverlayGroup>
 </Template>

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc	2017-12-09 12:29:44 UTC (rev 11645)
@@ -51,7 +51,7 @@
         RegisterObject(Asteroids2D);
 
         bEndGame = false;
-        lives = 5;
+        lives = 1000;
         level = 1;
         point = 0;
         bShowLevel = false;
@@ -157,7 +157,7 @@
         }
     };
     
-
+//Funktion wird als erstes im Level aufgerufen
     void Asteroids2D::start()
     {
         orxout() << "start" << endl;

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc	2017-12-09 12:29:44 UTC (rev 11645)
@@ -40,7 +40,7 @@
         RegisterObject(Asteroids2DHUDinfo);
 
         this->Asteroids2DGame = nullptr;
-        this->Ship = nullptr;
+        //this->Ship = nullptr;
         this->bShowPoints_ = true;
         this->bShowHealth_ = true;
     }
@@ -50,7 +50,6 @@
         SUPER(Asteroids2DHUDinfo, XMLPort, xmlelement, mode);
 
         XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
-        XMLPortParam(Asteroids2DHUDinfo,"showHealth", setShowHealth, getShowHealth, xmlelement, mode).defaultValues(false);
     }
 
     void Asteroids2DHUDinfo::tick(float dt)

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h	2017-12-09 12:29:44 UTC (rev 11645)
@@ -60,9 +60,11 @@
 
         private:
             Asteroids2D* Asteroids2DGame;
-            Asteroids2DShip* Ship;
+            bool bShowLives_;
+            bool bShowLevel_;
             bool bShowPoints_;
             bool bShowHealth_;
+
     };
 }
 #endif /* _Asteroids2DHUDinfo_H__ */

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc	2017-12-09 12:29:44 UTC (rev 11645)
@@ -97,13 +97,16 @@
     inline bool Asteroids2DShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     {
 
-        orxout() << "touched" << endl; 
         Asteroids2DStone* stone = orxonox_cast<Asteroids2DStone*>(otherObject);       
-        if(stone != nullptr && (stone != lastStone || lastStone == nullptr))
+        if(stone != nullptr && !bImmune)
         {
             removeHealth(100); 
-            lastStone = stone;
-          
+            this->getGame()->addPoints(10);
+
+            //The ship will be immune for 3 seconds after it has been hit by an asteroid
+            bImmune = true;
+            isimmune.setTimer(3.0f, false, createExecutor(createFunctor(&Asteroids2DShip::toggleImmune, this)));
+            orxout()<< "touched" << endl;
         }
         return false;
     }

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h	2017-12-09 12:29:44 UTC (rev 11645)
@@ -67,8 +67,6 @@
             virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
             virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
 
-
-
             virtual void updateLevel();
 
             virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
@@ -76,6 +74,10 @@
             float speed, damping, posforeward;
             bool isFireing;
             void showposition();
+            void toggleImmune()
+            {
+                bImmune = !bImmune;
+            }
 
         protected:
             virtual void death() override;
@@ -85,9 +87,9 @@
 
             float width, height;
             WeakPtr<Asteroids2D> game;
-            WeakPtr<Asteroids2DStone> lastStone;
-
+            bool bImmune;
             Timer timer;
+            Timer isimmune;
     };
 }
 

Added: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc	2017-12-09 12:29:44 UTC (rev 11645)
@@ -0,0 +1,94 @@
+/*
+ *   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:
+ *      Florian Zinggeler
+ *   Co-authors:
+ *      --
+ *
+ */
+
+/**
+    @file Asteroids2DWeapon.h
+    @brief Implementation of the Asteroids2DWeapon class.
+*/
+
+#include "Asteroids2DWeapon.h"
+
+#include "core/CoreIncludes.h"
+// #include "core/XMLPort.h"
+// #include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+    RegisterClass(Asteroids2DWeapon);
+
+    Asteroids2DWeapon::Asteroids2DWeapon(Context* context) : HsW01(context)
+    {
+        RegisterObject(Asteroids2DWeapon);
+    }
+
+    Asteroids2DWeapon::~Asteroids2DWeapon()
+    {
+
+    }
+
+    void Asteroids2DWeapon::shot()
+    {
+        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+        // Create the projectile.
+        Projectile* projectile = new Projectile(this->getContext());
+        Model* model = new Model(projectile->getContext());
+        model->setMeshSource(mesh_);
+        model->setCastShadows(false);
+        projectile->attach(model);
+        model->setScale(5);
+
+        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+        projectile->setOrientation(this->getMuzzleOrientation());
+        projectile->setPosition(this->getMuzzlePosition());
+
+        Vector3 muzzle2D = this->getMuzzleDirection();
+        muzzle2D.y = 0; 
+
+        projectile->setVelocity(muzzle2D * this->speed_);
+
+        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+        projectile->setDamage(this->getDamage());
+        projectile->setShieldDamage(this->getShieldDamage());
+        projectile->setHealthDamage(this->getHealthDamage());
+
+        // Display the muzzle flash.
+        this->HsW01::muzzleflash();
+    }
+    
+}

Added: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h	                        (rev 0)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h	2017-12-09 12:29:44 UTC (rev 11645)
@@ -0,0 +1,55 @@
+/*
+ *   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:
+ *      Florian Zinggeler
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Asteroids2DWeapon.h
+    @brief Definition of the Asteroids2DWeapon class.
+*/
+
+#ifndef _Asteroids2DWeapon_H__
+#define _Asteroids2DWeapon_H__
+
+#include "asteroids2D/Asteroids2DPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/weaponmodes/HsW01.h"
+
+namespace orxonox
+{
+    class _Asteroids2DExport Asteroids2DWeapon : public HsW01
+    {
+        public:
+            Asteroids2DWeapon(Context* context);
+            virtual ~Asteroids2DWeapon();
+        protected:
+            virtual void shot() override;
+            WeakPtr<Projectile> projectile;
+    };
+}
+
+#endif /* _Asteroids2DWeapon_H__ */

Modified: code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt
===================================================================
--- code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt	2017-12-08 13:55:15 UTC (rev 11644)
+++ code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt	2017-12-09 12:29:44 UTC (rev 11645)
@@ -4,6 +4,7 @@
 Asteroids2DShip.cc
 Asteroids2DStone.cc
 Asteroids2DHUDinfo.cc
+Asteroids2DWeapon.cc
 )
 
 ORXONOX_ADD_LIBRARY(asteroids2D



More information about the Orxonox-commit mailing list