[Orxonox-commit 5210] r9874 - in code/branches/invaders: data/levels data/levels/includes data/levels/templates src/modules/invader

zifloria at orxonox.net zifloria at orxonox.net
Fri Dec 6 15:09:30 CET 2013


Author: zifloria
Date: 2013-12-06 15:09:30 +0100 (Fri, 06 Dec 2013)
New Revision: 9874

Added:
   code/branches/invaders/data/levels/includes/invaderWeaponEnemy.oxi
   code/branches/invaders/data/levels/templates/enemyInvaderShooter.oxt
   code/branches/invaders/src/modules/invader/InvaderEnemyShooter.cc
   code/branches/invaders/src/modules/invader/InvaderEnemyShooter.h
   code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.cc
   code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.h
Modified:
   code/branches/invaders/data/levels/Invaders.oxw
   code/branches/invaders/src/modules/invader/CMakeLists.txt
   code/branches/invaders/src/modules/invader/Invader.cc
   code/branches/invaders/src/modules/invader/Invader.h
   code/branches/invaders/src/modules/invader/InvaderEnemy.cc
   code/branches/invaders/src/modules/invader/InvaderEnemy.h
   code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
   code/branches/invaders/src/modules/invader/InvaderPrereqs.h
   code/branches/invaders/src/modules/invader/InvaderShip.cc
   code/branches/invaders/src/modules/invader/InvaderShip.h
   code/branches/invaders/src/modules/invader/InvaderWeapon.cc
   code/branches/invaders/src/modules/invader/InvaderWeapon.h
Log:
best game eva ^^

Modified: code/branches/invaders/data/levels/Invaders.oxw
===================================================================
--- code/branches/invaders/data/levels/Invaders.oxw	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/data/levels/Invaders.oxw	2013-12-06 14:09:30 UTC (rev 9874)
@@ -1,10 +1,9 @@
 <LevelInfo
  name = "Orxonox Arcade"
- description = "Arcade shooter. Maximise your points!!!"
+ description = "2D Arcade shooter. Maximise your points!!!\nTip: try to keep the multiplier high by avoiding shots and enemies."
  tags = "minigame"
  screenshot = "emptylevel.png"
 />
-<!-- include("HUDTemplates3.oxo") -->
 <?lua
   include("stats.oxo")
   include("templates/lodInformation.oxt")
@@ -15,6 +14,7 @@
   include("templates/spaceshipPirate.oxt")
   include("templates/spaceshipInvader.oxt")
   include("templates/enemyInvader.oxt")
+  include("templates/enemyInvaderShooter.oxt")
   include("overlays/InvaderHUD.oxo")
 ?>
 

Added: code/branches/invaders/data/levels/includes/invaderWeaponEnemy.oxi
===================================================================
--- code/branches/invaders/data/levels/includes/invaderWeaponEnemy.oxi	                        (rev 0)
+++ code/branches/invaders/data/levels/includes/invaderWeaponEnemy.oxi	2013-12-06 14:09:30 UTC (rev 9874)
@@ -0,0 +1,27 @@
+    <weaponslots>
+      <WeaponSlot position="-9.2,2,-13" />
+      <WeaponSlot position=" 9.2,2,-13" />
+    </weaponslots>
+    <weaponsets>
+      <WeaponSet firemode=0 />
+      <WeaponSet firemode=1 />
+    </weaponsets>
+    <weapons>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+          <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+        </links>
+        <Weapon>
+          <InvaderWeaponEnemy 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>
+          <InvaderWeaponEnemy 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>
+    </weapons>

Added: code/branches/invaders/data/levels/templates/enemyInvaderShooter.oxt
===================================================================
--- code/branches/invaders/data/levels/templates/enemyInvaderShooter.oxt	                        (rev 0)
+++ code/branches/invaders/data/levels/templates/enemyInvaderShooter.oxt	2013-12-06 14:09:30 UTC (rev 9874)
@@ -0,0 +1,120 @@
+<Template name=enemyinvadershooter>
+  <InvaderEnemyShooter
+   hudtemplate            = spaceshiphud
+   camerapositiontemplate = spaceshipescortcameras
+   spawnparticlesource    = "Orxonox/fairytwirl"
+   spawnparticleduration  = 3
+   explosionchunks        = 4
+
+   health            = 20
+   maxhealth         = 20
+   initialhealth     = 20
+
+   shieldhealth        = 20
+   initialshieldhealth = 20
+   maxshieldhealth     = 20
+   shieldabsorption    = 0.9
+   reloadrate          = 1
+   reloadwaittime      = 1
+
+   primaryThrust     = 150
+   auxilaryThrust    = 30
+   rotationThrust    = 50
+
+   lift = 1;
+   stallSpeed = 220;
+
+   boostPower            = 20
+   boostPowerRate        = 1
+   boostRate             = 5
+   boostCooldownDuration = 10
+
+   shakeFrequency = 15
+   shakeAmplitude = 6
+
+   collisionType     = "dynamic"
+   mass              = 100
+   linearDamping     = 0
+   angularDamping    = 0
+
+    collisiondamage = 100
+    enablecollisiondamage = true
+  >
+    <engines>
+      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
+      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipescortengine />
+    </engines>
+    <attached>
+      <Model position="0,0,0" yaw=180 pitch=270 roll=0 scale=2 mesh="ghost.mesh" />
+      <Model position="0,0,0" yaw=180 pitch=270 roll=0 scale=2 mesh="escortWeapon.mesh" />
+<!--Model mesh="cube.mesh" mass=10 position="0,0,3" scale3D="10,4,8" />
+
+swallow_mat.mesh
+"ghost.mesh"
+
+<Model mesh="cube.mesh" mass=10 position="12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="-12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
+    </attached>
+    <collisionShapes>
+      <BoxCollisionShape position="0    ,0 ,  3" halfExtents="10,   4,8" />
+      <BoxCollisionShape position="12.6 ,-2,  3" halfExtents="2.8,2.8,11"/>
+      <BoxCollisionShape position="-12.6,-2,  3" halfExtents="2.8,2.8,11"/>
+      <BoxCollisionShape position="0,     0,-12" halfExtents="4  , 4 ,7" />
+    </collisionShapes>
+<?lua
+  include("../includes/invaderWeaponEnemy.oxi")
+?>
+  </InvaderEnemyShooter>
+</Template>
+
+<!-- <Template name=spaceshipescortcameras defaults=0>
+  <InvaderEnemyShooter>
+    <camerapositions>
+      <CameraPosition position="0,15, 60" drag=true mouselook=true />
+      <CameraPosition position="0,20, 90" drag=true mouselook=true />
+      <CameraPosition position="0,30,120" drag=true mouselook=true />
+      <CameraPosition position="0,300,-100" direction="0, -1, 0" drag=false mouselook=true />
+    </camerapositions>
+  </InvaderEnemyShooter>
+</Template> -->
+
+<Template name=spaceshipescortengine baseclass=MultiStateEngine>
+  <MultiStateEngine
+   boostfactor    = 2.2
+
+   speedfront     = 200
+   speedback      =  70
+   speedleftright =  70
+   speedupdown    =  70
+
+   defEngineSndNormal = "sounds/Engine_low.ogg"
+   defEngineSndBoost = "sounds/Engine_high.ogg"
+
+   accelerationfront     = 700
+   accelerationbrake     = 700
+   accelerationback      =  125
+   accelerationleftright =  125
+   accelerationupdown    =  125
+  >
+    <EffectContainer condition="idle">
+      <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+    </EffectContainer>
+    <EffectContainer condition="not idle">
+      <FadingBillboard mainstate=activity active=false scale=0.09 position="12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+      <FadingBillboard mainstate=activity active=false scale=0.09 position="-12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+    </EffectContainer>
+    <EffectContainer condition="normal or brake">
+
+    </EffectContainer>
+    <EffectContainer condition="normal or boost">
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+    </EffectContainer>
+    <EffectContainer condition="boost">
+      <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" />
+      <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>

Modified: code/branches/invaders/src/modules/invader/CMakeLists.txt
===================================================================
--- code/branches/invaders/src/modules/invader/CMakeLists.txt	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/CMakeLists.txt	2013-12-06 14:09:30 UTC (rev 9874)
@@ -4,7 +4,9 @@
   InvaderCenterPoint.cc
   InvaderShip.cc
   InvaderEnemy.cc
+  InvaderEnemyShooter.cc
   InvaderWeapon.cc
+  InvaderWeaponEnemy.cc
   InvaderHUDinfo.cc
 END_BUILD_UNIT
 )

Modified: code/branches/invaders/src/modules/invader/Invader.cc
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.cc	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/Invader.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -47,8 +47,10 @@
 #include "InvaderCenterPoint.h"
 #include "InvaderShip.h"
 #include "InvaderEnemy.h"
+#include "InvaderEnemyShooter.h"
 
 #include "core/command/ConsoleCommand.h"
+#include "worldentities/BigExplosion.h"
 
 namespace orxonox
 {
@@ -69,28 +71,61 @@
         // TODO:
         level = 1;
         point = 0;
+        bShowLevel = false;
         multiplier = 1;
         b_combo = false;
-        // spawn enemy every 2 seconds
-        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
-        comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
+        // spawn enemy every 3.5 seconds
+        enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
+        comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
     }
 
-    void Invader::spawnEnemy()
+    void Invader::levelUp()
     {
+        level++;
+        if (getPlayer() != NULL)
+        {   
+            for (int i = 0; i < 7; i++)
+            {
+                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+                chunk->setPosition(Vector3(600, 0, 100 * i - 300));
+                chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
+                chunk->setScale(20);
+            }
+        }
+        addPoints(multiplier * 42);
+        multiplier *= 2;
+        toggleShowLevel();
+        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this)));
+    }
+
+    WeakPtr<InvaderShip> Invader::getPlayer()
+    {
         if (player == NULL)
         {
             for (ObjectList<InvaderShip>::iterator it = ObjectList<InvaderShip>::begin(); it != ObjectList<InvaderShip>::end(); ++it)
                 player = *it;
         }
-        if (player == NULL)
+        return player;
+    }
+
+    void Invader::spawnEnemy()
+    {
+        if (getPlayer() == NULL)
             return;
-
         srand(player->getPosition().x + player->getPosition().y);
-        for (int i = 0; i < level * 2; i++)
+        for (int i = 0; i < (3*log(level) + 1); i++)
         {
-            WeakPtr<InvaderEnemy> newPawn = new InvaderEnemy(this->center_->getContext());
-            newPawn->addTemplate("enemyinvader");
+            WeakPtr<InvaderEnemy> newPawn;
+            if (rand() % 42/(1 + level*level) == 0)
+            {
+                newPawn = new InvaderEnemyShooter(this->center_->getContext());
+                newPawn->addTemplate("enemyinvadershooter");
+            }
+            else
+            {
+                newPawn = new InvaderEnemy(this->center_->getContext());
+                newPawn->addTemplate("enemyinvader");
+            }
             newPawn->setPlayer(player);
             newPawn->level = level;
             // spawn enemy at random points in front of player.
@@ -132,8 +167,15 @@
         // Call start for the parent class.
         Deathmatch::start();
     }
+    void Invader::addPoints(int numPoints)
+    {
+        if (!bEndGame)
+        {
+            point += numPoints * multiplier;
+            b_combo = true;
+        }
+    }
 
-
     void Invader::end()
     {
         // DON'T CALL THIS!

Modified: code/branches/invaders/src/modules/invader/Invader.h
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.h	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/Invader.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -65,20 +65,24 @@
             int getMultiplier(){return this->multiplier;}
 
             void costLife();
-            void levelUp(){level++;}
-            void addPoints(int numPoints){point += numPoints * multiplier; b_combo = true;}
+            void levelUp();
+            void addPoints(int numPoints);
             // checks if multiplier should be reset.
             void comboControll();
             void init();
             int lives;
             int multiplier;
             bool bEndGame;
+            bool bShowLevel;
         private:
+            void toggleShowLevel(){bShowLevel = !bShowLevel;}
+            WeakPtr<InvaderShip> getPlayer();
             WeakPtr<InvaderCenterPoint> center_;
             WeakPtr<InvaderShip> player;
 
             Timer enemySpawnTimer;
             Timer comboTimer;
+            Timer showLevelTimer;
             //Context* context;
             int level;
             int point;

Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.cc	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -33,7 +33,7 @@
 
 #include "invader/InvaderPrereqs.h"
 #include "InvaderEnemy.h"
-// #include "worldentities/pawns/SpaceShip.h"
+#include "InvaderShip.h"
 
 namespace orxonox
 {
@@ -63,7 +63,7 @@
 
     inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     {
-        if(orxonox_cast<Pawn*>(otherObject))
+        if(orxonox_cast<InvaderShip*>(otherObject))
             removeHealth(2000);
         return false;
     }
@@ -80,8 +80,8 @@
 
     void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     {
-        if (getGame())
+        Pawn::damage(damage, healthdamage, shielddamage, originator);
+        if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0)
             getGame()->addPoints(42);
-        Pawn::damage(damage, healthdamage, shielddamage, originator);
     }
 }
\ No newline at end of file

Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.h	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -51,7 +51,7 @@
             virtual void setPlayer(WeakPtr<InvaderShip> player){this->player = player;}
 
             int level;
-        private:
+        protected:
             WeakPtr<Invader> getGame();
             WeakPtr<Invader> game;
             WeakPtr<InvaderShip> player;

Added: code/branches/invaders/src/modules/invader/InvaderEnemyShooter.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemyShooter.cc	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderEnemyShooter.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -0,0 +1,79 @@
+/*
+ *   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 InvaderEnemyShooter.h
+    @brief Declaration of the InvaderEnemyShooter class.
+*/
+
+#include "invader/InvaderPrereqs.h"
+#include "InvaderEnemyShooter.h"
+// #include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+    RegisterClass(InvaderEnemyShooter);
+
+    InvaderEnemyShooter::InvaderEnemyShooter(Context* context) : InvaderEnemy(context)
+    {
+        RegisterObject(InvaderEnemyShooter);
+        enableCollisionCallback();
+        lifetime = 0;
+        // shoot every second
+        shootTimer.setTimer(1.0f, true, createExecutor(createFunctor(&InvaderEnemyShooter::shoot, this)));
+    }
+
+    void InvaderEnemyShooter::tick(float dt)
+    {
+        lifetime += dt;
+        // die after 20 seconds.
+        if (lifetime > 20000)
+            removeHealth(2000);
+
+        if (player != NULL)
+        {
+            float distPlayer = player->getPosition().z - getPosition().z;
+            // orxout() << "i'm different!" << endl;
+            float newZ = 2/(pow(abs(getPosition().x - player->getPosition().x) * 0.01, 2) + 1) * distPlayer;
+            setVelocity(Vector3(950 - abs(distPlayer), 0, newZ));
+        }
+        Pawn::tick(dt);
+    }
+
+    void InvaderEnemyShooter::shoot()
+    {
+        ControllableEntity::fire(0);
+    }
+
+    void InvaderEnemyShooter::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
+    {
+        Pawn::damage(damage, healthdamage, shielddamage, originator);
+        if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0)
+            getGame()->addPoints(3*42);
+    }
+}
\ No newline at end of file

Added: code/branches/invaders/src/modules/invader/InvaderEnemyShooter.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemyShooter.h	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderEnemyShooter.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -0,0 +1,58 @@
+/*
+ *   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 InvaderEnemyShooter.h
+    @brief Declaration of the InvaderEnemyShooter class.
+*/
+
+#ifndef _InvaderEnemyShooter_H__
+#define _InvaderEnemyShooter_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "invader/InvaderEnemy.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _InvaderExport InvaderEnemyShooter : public InvaderEnemy
+    {
+        public:
+            InvaderEnemyShooter(Context* context);
+
+            virtual void tick(float dt);
+            virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
+        protected:
+            void shoot();
+            Timer shootTimer;
+
+    };
+}
+
+#endif /* _InvaderEnemyShooter_H__ */

Modified: code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -77,6 +77,14 @@
                     setTextSize(0.05);
                     this->InvaderGame->bEndGame = true;
                 }
+                else if (this->InvaderGame->bShowLevel)
+                {
+                    setTextSize(0.1);
+                    setPosition(Vector2(0.3, 0.55));
+                    std::stringstream sstm;
+                    sstm << "Level " << Level;
+                    this->setCaption(sstm.str()); // + level
+                }
                 else
                 {
                     setTextSize(0.04);

Modified: code/branches/invaders/src/modules/invader/InvaderPrereqs.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderPrereqs.h	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderPrereqs.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -71,7 +71,9 @@
     class InvaderCenterPoint;
     class InvaderShip;
     class InvaderEnemy;
+    class InvaderEnemyShooter;
     class InvaderWeapon;
+    class InvaderWeaponEnemy;
     class InvaderHUDinfo;
 }
 

Modified: code/branches/invaders/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -137,6 +137,7 @@
     {
         // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
         WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+        WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject);
         // ensure that this gets only called once per enemy.
         if (enemy != NULL && lastEnemy != enemy)
         {
@@ -145,12 +146,21 @@
             removeHealth(20);
             if (getGame())
             {
-                getGame()->multiplier = 1;
-                if (getHealth() <= 0)
-                    getGame()->costLife();                    
+                getGame()->multiplier = 1;                   
             }
-            return false;
         }
+        // was shot, decrease multiplier
+        else if (shot != NULL  && lastShot != shot)
+        {
+            if (getGame() && orxonox_cast<InvaderEnemy*>(shot->getShooter()) != NULL)
+            {
+                if (getGame()->multiplier > 1)
+                {
+                    lastShot = shot;
+                    getGame()->multiplier -= 1;     
+                }
+            }
+        }
         return false;
         // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
     }
@@ -164,4 +174,10 @@
         }
         return game;
     }
+
+    void InvaderShip::death()
+    {
+        getGame()->costLife();
+        SpaceShip::death();
+    }
 }

Modified: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -38,6 +38,7 @@
 
 #include "worldentities/pawns/SpaceShip.h"
 #include "graphics/Camera.h"
+#include "weapons/projectiles/Projectile.h"
 
 namespace orxonox
 {
@@ -64,6 +65,9 @@
             virtual void updateLevel();
 
             virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+        protected:
+            virtual void death();
         private:
             WeakPtr<Invader> getGame();
             WeakPtr<Invader> game;
@@ -78,6 +82,7 @@
             } velocity, desiredVelocity;
 
             WeakPtr<InvaderEnemy> lastEnemy;
+            WeakPtr<Projectile> lastShot;
 
     };
 }

Modified: code/branches/invaders/src/modules/invader/InvaderWeapon.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderWeapon.cc	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderWeapon.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -62,9 +62,9 @@
     {
         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());
+        // Create the projectile.projectile
+        projectile = new Projectile(this->getContext());
+        WeakPtr<Model> model = new Model(projectile->getContext());
         model->setMeshSource(mesh_);
         model->setCastShadows(false);
         projectile->attach(model);

Modified: code/branches/invaders/src/modules/invader/InvaderWeapon.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderWeapon.h	2013-12-06 10:42:18 UTC (rev 9873)
+++ code/branches/invaders/src/modules/invader/InvaderWeapon.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -48,6 +48,7 @@
             virtual ~InvaderWeapon();
         protected:
             virtual void shot();
+            WeakPtr<Projectile> projectile;
     };
 }
 

Added: code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.cc	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.cc	2013-12-06 14:09:30 UTC (rev 9874)
@@ -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 InvaderWeaponEnemy.h
+    @brief Implementation of the InvaderWeaponEnemy class.
+*/
+
+#include "InvaderWeaponEnemy.h"
+
+namespace orxonox
+{
+    RegisterClass(InvaderWeaponEnemy);
+
+    InvaderWeaponEnemy::InvaderWeaponEnemy(Context* context) : InvaderWeapon(context)
+    {
+        RegisterObject(InvaderWeaponEnemy);
+    }
+
+    void InvaderWeaponEnemy::shot()
+    {
+    	InvaderWeapon::shot();
+        // SUPER(InvaderWeaponEnemy, shot);
+        // only shoot in foreward direction
+        projectile->setVelocity(Vector3(1, 0, 0) * -500);
+        // projectile->setOrientation(Quaternion(sqrt(0.5),0,sqrt(0.5),0));
+    }
+}
+
+

Added: code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.h	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderWeaponEnemy.h	2013-12-06 14:09:30 UTC (rev 9874)
@@ -0,0 +1,53 @@
+/*
+ *   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 InvaderWeaponEnemy.h
+    @brief Definition of the InvaderWeaponEnemy class.
+*/
+
+#ifndef _InvaderWeaponEnemy_H__
+#define _InvaderWeaponEnemy_H__
+
+// #include "weapons/weaponmodes/HsW01.h"
+// #include "weapons/WeaponsPrereqs.h"
+#include "invader/InvaderWeapon.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _InvaderExport InvaderWeaponEnemy : public InvaderWeapon
+    {
+        public:
+            InvaderWeaponEnemy(Context* context);
+        protected:
+            virtual void shot();
+    };
+}
+
+#endif /* _InvaderWeaponEnemy_H__ */




More information about the Orxonox-commit mailing list