Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/items/SpeedPickup.h @ 8757

Last change on this file since 8757 was 8727, checked in by dafrick, 13 years ago

Cleaning up in SpaceShip and Engine. Fixed several bugs.
Kicked localLinearAcceleration, primaryThrust and auxiliaryThrust out of the SpaceShip, since it wasn't used anymore.
Moved the trail lights back a bit.
Added some documentation to SpaceShip and Engine.
SpeedPickup is working again, will need some further tuning.

  • Property svn:eol-style set to native
File size: 4.9 KB
RevLine 
[6681]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.
[7456]32    @ingroup PickupItems
[6681]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
[7547]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.
[6681]56
[7547]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
[6681]68    @author
69        Eric Beier
[7547]70
71    @ingroup PickupItems
[6681]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
[7547]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
[6681]90                { return this->duration_; }
[7547]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
[6681]96                { return this->speedAdd_; }
[7547]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
[6681]102                { return this->speedMultiply_; }
103
104        protected:
105            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
[7208]106            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
[6681]107
[7547]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.
[6681]111
112        private:
113            void initialize(void); //!< Initializes the member variables.
[8727]114            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceSHip, and throw an error message if the conversion fails.
[6681]115
[7208]116            Timer durationTimer_; //!< Timer.
117
[7547]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.
[6681]121    };
122}
123
[6705]124#endif // _SpeedPickup_H__
Note: See TracBrowser for help on using the repository browser.