Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup2012/src/modules/pickup/items/SpeedPickup.h @ 9200

Last change on this file since 9200 was 9155, checked in by lkevin, 13 years ago

Changed pickup icon and xml for possible varieties of the pickup in the future.

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Eric Beier
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file SpeedPickup.h
31    @brief Declaration of the SpeedPickup class.
32    @ingroup PickupItems
33*/
34
35#ifndef _SpeedPickup_H__
36#define _SpeedPickup_H__
37
38#include "pickup/PickupPrereqs.h"
39
40#include <string>
41
42#include "pickup/Pickup.h"
43
44namespace orxonox {
45
46    /**
47    @brief
48        A Pickup which can manipulate the Speed of a Pawn.
49
50        There are 5 parameters that can be cosen:
51        - The @b speedMultiply, specifies a factor by which the Spaceships speed is multiplied. The default is 1.
52        - The @b speedAdd, specifies a value that is added to the speed of the Spaceship. The default is 0.
53        - The @b activationType <em>immediate</em> or <em>onUse</em>, defines if the SpeedPickup is used when it's picked up or only after the player chooses to use it. The default is <em>immediate</em>.
54        - The @b durationType Can be either <em>once</em> or <em>continuous</em>. For <em>once</em> the SpeedPickup is just active for as long as it is used, for <em>continuous</em> the SpeedPickup is active only for the specified duration. The default is <em>once</em>.
55        - The @b duration The time in seconds the SpeedPickup is active at the most. The default is 0.
56
57        An example, how a SpeedPickup could be defined in XML could be:
58        @code
59        <SpeedPickup
60            speedMultiply = 2.0
61            speedAdd = 10.0
62            activationType = "immediate"
63            durationType = "continuous"
64            duration = 30.0
65        />
66        @endcode
67
68    @author
69        Eric Beier
70
71    @ingroup PickupItems
72    */
73    class _PickupExport SpeedPickup : public Pickup
74    {
75        public:
76
77            SpeedPickup(BaseObject* creator); //!< Constructor.
78            virtual ~SpeedPickup(); //!< Destructor.
79
80            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
81
82            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
83            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
84
85            /**
86            @brief Get the duration, the time the SpeedPickup is active.
87            @return Returns the duration in seconds.
88            */
89            inline float getDuration(void) const
90                { return this->duration_; }
91            /**
92            @brief Get the value that is added to the speed of the Pawn.
93            @return Returns the speedAdd.
94            */
95            inline float getSpeedAdd(void) const
96                { return this->speedAdd_; }
97            /**
98            @brief Get the factor by wich the speed of the Pawn is multplied.
99            @return Returns the speedMultiply.
100            */
101            inline float getSpeedMultiply(void) const
102                { return this->speedMultiply_; }
103
104        protected:
105            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
106            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
107
108            void setDuration(float duration); //!< Sets the duration.
109            void setSpeedAdd(float speedAdd); //!< Sets the SpeedAdd, the value that is added to the speed of the Pawn.
110            void setSpeedMultiply(float speedMultiply); //!< Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied.
111
112        private:
113            void initialize(void); //!< Initializes the member variables.
114            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
115
116            Timer durationTimer_; //!< Timer.
117
118            float duration_; //!< The time in seconds for which the SpeedPickup stays active.
119            float speedAdd_; //!< The value that is added to the speed of the Pawn.
120            float speedMultiply_; //!< The factor by which the speed of the Pawn is multiplied.
121    };
122}
123
124#endif // _SpeedPickup_H__
Note: See TracBrowser for help on using the repository browser.