Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sfxSebastian/src/modules/pickup/items/SpeedPickup.h @ 10087

Last change on this file since 10087 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 4.7 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(Context* context); //!< 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
84            /**
85            @brief Get the duration, the time the SpeedPickup is active.
86            @return Returns the duration in seconds.
87            */
88            inline float getDuration(void) const
89                { return this->duration_; }
90            /**
91            @brief Get the value that is added to the speed of the Pawn.
92            @return Returns the speedAdd.
93            */
94            inline float getSpeedAdd(void) const
95                { return this->speedAdd_; }
96            /**
97            @brief Get the factor by wich the speed of the Pawn is multplied.
98            @return Returns the speedMultiply.
99            */
100            inline float getSpeedMultiply(void) const
101                { return this->speedMultiply_; }
102
103        protected:
104            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
105
106            void setDuration(float duration); //!< Sets the duration.
107            void setSpeedAdd(float speedAdd); //!< Sets the SpeedAdd, the value that is added to the speed of the Pawn.
108            void setSpeedMultiply(float speedMultiply); //!< Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied.
109
110        private:
111            void initialize(void); //!< Initializes the member variables.
112            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
113
114            Timer durationTimer_; //!< Timer.
115
116            float duration_; //!< The time in seconds for which the SpeedPickup stays active.
117            float speedAdd_; //!< The value that is added to the speed of the Pawn.
118            float speedMultiply_; //!< The factor by which the speed of the Pawn is multiplied.
119    };
120}
121
122#endif // _SpeedPickup_H__
Note: See TracBrowser for help on using the repository browser.