[Orxonox-commit 298] r2933 - in branches/gametypes/src/orxonox/objects: gametypes worldentities/pawns

mockm at orxonox.net mockm at orxonox.net
Mon Apr 27 15:58:26 CEST 2009


Author: mockm
Date: 2009-04-27 15:58:25 +0200 (Mon, 27 Apr 2009)
New Revision: 2933

Added:
   branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
   branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
   branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.cc
   branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.h
Modified:
   branches/gametypes/src/orxonox/objects/gametypes/CMakeLists.txt
   branches/gametypes/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
Log:
Gametype UnderAttack added

Modified: branches/gametypes/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/CMakeLists.txt	2009-04-27 13:30:34 UTC (rev 2932)
+++ branches/gametypes/src/orxonox/objects/gametypes/CMakeLists.txt	2009-04-27 13:58:25 UTC (rev 2933)
@@ -3,4 +3,5 @@
   Deathmatch.cc
   TeamDeathmatch.cc
   Pong.cc
+  UnderAttack.cc
 )

Added: branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc	                        (rev 0)
+++ branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc	2009-04-27 13:58:25 UTC (rev 2933)
@@ -0,0 +1,131 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "UnderAttack.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "objects/Teamcolourable.h"
+#include "objects/worldentities/TeamSpawnPoint.h"
+
+namespace orxonox
+{
+    CreateUnloadableFactory(UnderAttack);
+
+    UnderAttack::UnderAttack(BaseObject* creator) : TeamDeathmatch(creator)
+    {
+        RegisterObject(UnderAttack);
+        this->gameTime_ = 30;
+        this->teams_ = 2;
+        this->destroyer_ = 0;
+        this->gameEnded_ = false;
+
+        this->setConfigValues();
+    }
+
+    void UnderAttack::addDestroyer(Destroyer* destroyer)
+    {
+        this->destroyer_ = destroyer;
+    }
+
+
+    void UnderAttack::destroyedPawn(Pawn* pawn)
+    {
+        if (pawn == this->destroyer_)
+        {
+
+            COUT(0) << "Ship destroyed! Team 0 has won!" << std::endl;
+            // Todo: end game
+        }
+    }
+
+    bool UnderAttack::allowPawnHit(Pawn* victim, Pawn* originator)
+    {
+        if (victim == this->destroyer_)
+        {
+            if (originator && originator->getPlayer() && !gameEnded_)
+            {
+                if (this->getTeam(originator->getPlayer()) == 0)
+                    return true;
+                else
+                    return false;
+            }
+
+            return false;
+        }
+
+        return TeamDeathmatch::allowPawnHit(victim, originator);
+    }
+
+    bool UnderAttack::allowPawnDamage(Pawn* victim, Pawn* originator)
+    {
+        if (victim == this->destroyer_)
+        {
+            if (originator && originator->getPlayer() && !gameEnded_)
+            {
+                if (this->getTeam(originator->getPlayer()) == 0)
+                    return true;
+                else
+                    return false;
+            }
+
+            return false;
+        }
+
+        return TeamDeathmatch::allowPawnDamage(victim, originator);
+    }
+
+    bool UnderAttack::allowPawnDeath(Pawn* victim, Pawn* originator)
+    {
+        if (victim == this->destroyer_)
+        {
+            if (originator && originator->getPlayer() && !gameEnded_)
+            {
+                if (this->getTeam(originator->getPlayer()) == 0)
+                    return true;
+                else
+                    return false;
+            }
+
+            return false;
+        }
+
+        return TeamDeathmatch::allowPawnDeath(victim, originator);
+    }
+    void UnderAttack::tick(float dt)
+    {
+        gameTime_ = gameTime_ - dt;
+        if (gameTime_<= 0)
+        {
+            gameEnded_ = true;
+            COUT(0) << "Time is up! Team 1 has won!" << std::endl;
+        }
+    }
+
+}

Added: branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h
===================================================================
--- branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h	                        (rev 0)
+++ branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h	2009-04-27 13:58:25 UTC (rev 2933)
@@ -0,0 +1,65 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _UnderAttack_H__
+#define _UnderAttack_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <vector>
+#include "objects/worldentities/pawns/Destroyer.h"
+#include "TeamDeathmatch.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport UnderAttack : public TeamDeathmatch, public PawnListener
+    {
+        public:
+            UnderAttack(BaseObject* creator);
+            virtual ~UnderAttack() {}
+            void tick (float dt);
+            void addDestroyer(Destroyer* destroyer);
+            inline Destroyer* getDestroyer() const
+                { return this->destroyer_; }
+
+            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
+            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+
+        protected:
+            virtual void destroyedPawn(Pawn* pawn);
+
+            Destroyer* destroyer_;
+            unsigned int teams_;
+            float gameTime_;
+            bool gameEnded_;
+    };
+}
+
+#endif /* _TeamDeathmatch_H__ */

Modified: branches/gametypes/src/orxonox/objects/worldentities/pawns/CMakeLists.txt
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	2009-04-27 13:30:34 UTC (rev 2932)
+++ branches/gametypes/src/orxonox/objects/worldentities/pawns/CMakeLists.txt	2009-04-27 13:58:25 UTC (rev 2933)
@@ -2,4 +2,5 @@
   Spectator.cc
   Pawn.cc
   SpaceShip.cc
+  Destroyer.cc
 )

Added: branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.cc
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.cc	                        (rev 0)
+++ branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.cc	2009-04-27 13:58:25 UTC (rev 2933)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Destroyer.h"
+
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+#include "util/Math.h"
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "objects/items/Engine.h"
+
+namespace orxonox
+{
+    CreateFactory(Destroyer);
+
+    Destroyer::Destroyer(BaseObject* creator) : SpaceShip(creator)
+    {
+        RegisterObject(Destroyer);
+
+    }
+
+}

Added: branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.h
===================================================================
--- branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.h	                        (rev 0)
+++ branches/gametypes/src/orxonox/objects/worldentities/pawns/Destroyer.h	2009-04-27 13:58:25 UTC (rev 2933)
@@ -0,0 +1,49 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Destroyer_H__
+#define _Destroyer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "LinearMath/btVector3.h"
+
+#include "SpaceShip.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Destroyer : public SpaceShip
+    {
+        public:
+            Destroyer(BaseObject* creator);
+            virtual ~Destroyer() {};
+
+    };
+}
+
+#endif /* _Destroyer_H__ */




More information about the Orxonox-commit mailing list