[Orxonox-commit 2153] r6869 - in code/branches/ppspickups3/src/modules/pickup: . items

ebeier at orxonox.net ebeier at orxonox.net
Mon May 10 13:28:19 CEST 2010


Author: ebeier
Date: 2010-05-10 13:28:19 +0200 (Mon, 10 May 2010)
New Revision: 6869

Added:
   code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.cc
   code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.h
Modified:
   code/branches/ppspickups3/src/modules/pickup/PickupPrereqs.h
   code/branches/ppspickups3/src/modules/pickup/items/CMakeLists.txt
Log:
added files for ShieldPickup, nothing implemented yet.


Modified: code/branches/ppspickups3/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/ppspickups3/src/modules/pickup/PickupPrereqs.h	2010-05-10 11:23:04 UTC (rev 6868)
+++ code/branches/ppspickups3/src/modules/pickup/PickupPrereqs.h	2010-05-10 11:28:19 UTC (rev 6869)
@@ -78,6 +78,7 @@
     class InvisiblePickup;
     class MetaPickup;
     class SpeedPickup;
+    class ShieldPickup;
 
 }
 

Modified: code/branches/ppspickups3/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/ppspickups3/src/modules/pickup/items/CMakeLists.txt	2010-05-10 11:23:04 UTC (rev 6868)
+++ code/branches/ppspickups3/src/modules/pickup/items/CMakeLists.txt	2010-05-10 11:28:19 UTC (rev 6869)
@@ -3,4 +3,5 @@
   InvisiblePickup.cc
   MetaPickup.cc
   SpeedPickup.cc
+  ShieldPickup.cc
 )

Added: code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.cc
===================================================================
--- code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.cc	                        (rev 0)
+++ code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.cc	2010-05-10 11:28:19 UTC (rev 6869)
@@ -0,0 +1,170 @@
+/*
+ *   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:
+ *      Eric Beier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ShieldPickup.cc
+    @brief Implementation of the ShieldPickup class.
+*/
+
+#include "ShieldPickup.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/StringUtils.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+#include "items/Engine.h"
+#include "pickup/PickupIdentifier.h"
+
+#include <sstream>
+
+
+namespace orxonox
+{
+    CreateFactory(ShieldPickup);
+
+    /**
+    @brief
+        Constructor. Registers the object and initializes the member variables.
+    */
+    ShieldPickup::ShieldPickup(BaseObject* creator) : Pickup(creator)
+    {
+        RegisterObject(ShieldPickup);
+
+        this->initialize();
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    ShieldPickup::~ShieldPickup()
+    {
+
+    }
+
+    /**
+    @brief
+        Initializes the member variables.
+    */
+    void ShieldPickup::initialize(void)
+    {
+        this->duration_ = 0.0f;
+
+        this->addTarget(ClassIdentifier<Engine>::getIdentifier());
+    }
+
+    /**
+    @brief
+        Initializes the PickupIdentifier of this pickup.
+    */
+    void ShieldPickup::initializeIdentifier(void)
+    {
+        std::stringstream stream;
+        stream << this->getDuration();
+        std::string type1 = "duration";
+        std::string val1 = stream.str();
+        this->pickupIdentifier_->addParameter(type1, val1);
+
+//         stream.clear();
+//         stream << this->getShieldAdd();
+//         std::string type2 = "ShieldAdd";
+//         std::string val2 = stream.str();
+//         this->pickupIdentifier_->addParameter(type2, val2);
+
+    }
+
+    /**
+    @brief
+        Method for creating a ShieldPickup object through XML.
+    */
+    void ShieldPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+    {
+        SUPER(ShieldPickup, XMLPort, xmlelement, mode);
+
+        XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode);
+
+        this->initializeIdentifier();
+    }
+
+    /**
+    @brief
+        Is called when the pickup has transited from used to unused or the other way around.
+    */
+    void ShieldPickup::changedUsed(void)
+    {
+        SUPER(ShieldPickup, changedUsed);
+
+        //! If the pickup is not picked up nothing must be done.
+        if(!this->isPickedUp())
+            return;
+    }
+
+    /**
+    @brief
+        Creates a duplicate of the input OrxonoxClass.
+    @param item
+        A pointer to the Orxonox class.
+    */
+    void ShieldPickup::clone(OrxonoxClass*& item)
+    {
+        if(item == NULL)
+            item = new ShieldPickup(this);
+
+        SUPER(ShieldPickup, clone, item);
+
+        ShieldPickup* pickup = dynamic_cast<ShieldPickup*>(item);
+        pickup->setDuration(this->getDuration());
+
+        pickup->initializeIdentifier();
+    }
+
+    /**
+    @brief
+        Sets the duration.
+    @param duration
+        The duration
+    */
+    void ShieldPickup::setDuration(float duration)
+    {
+        if(duration >= 0.0f)
+        {
+            this->duration_ = duration;
+        }
+        else
+        {
+            COUT(1) << "Invalid duration in ShieldPickup." << std::endl;
+            this->duration_ = 0.0f;
+        }
+    }
+
+    void ShieldPickup::pickupTimerCallback(void)
+    {       
+        this->setUsed(false);
+    }
+}


Property changes on: code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Added: code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.h
===================================================================
--- code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.h	                        (rev 0)
+++ code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.h	2010-05-10 11:28:19 UTC (rev 6869)
@@ -0,0 +1,91 @@
+/*
+ *   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:
+ *      Eric Beier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ShieldPickup.h
+    @brief Declaration of the ShieldPickup class.
+*/
+
+#ifndef _ShieldPickup_H__
+#define _ShieldPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/StaticEntity.h"
+
+#include "pickup/Pickup.h"
+
+namespace orxonox {
+
+    /**
+    @brief
+        A Pickup which can add a Shield to the Pawn.
+
+        1) The Shield multiplier:
+           The additional (forward) Shield:
+        2) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
+        4) The duration: the activation time of the pickup.
+
+    @author
+        Eric Beier
+    */
+    class _PickupExport ShieldPickup : public Pickup
+    {
+        public:
+
+            ShieldPickup(BaseObject* creator); //!< Constructor.
+            virtual ~ShieldPickup(); //!< Destructor.
+
+            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
+
+            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+            inline float getDuration(void)
+                { return this->duration_; }
+
+
+        protected:
+            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+            
+            virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
+
+            void setDuration(float duration);
+
+
+        private:
+            void initialize(void); //!< Initializes the member variables.
+            Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+
+            float duration_; //!< The health that is transferred to the Pawn.
+    };
+}
+
+#endif // _ShieldPickup_H__


Property changes on: code/branches/ppspickups3/src/modules/pickup/items/ShieldPickup.h
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Orxonox-commit mailing list