Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/items/InvisiblePickup.h @ 11241

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

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 4.1 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 *      Benedict Simlinger
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file InvisiblePickup.h
31    @brief Declaration of the InvisiblePickup class.
32    @ingroup PickupItems
33*/
34
35#ifndef _InvisiblePickup_H__
36#define _InvisiblePickup_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 that makes the Pawn invisible.
49        There are 3 parameters that can be chosen:
50        - The @b activationType It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it. The default is <em>immediate</em>.
51        - The @b durationType< It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the InvisiblePickup just makes the Pawn invisible for as long as it is used, for <em>continuous</em> the Pawn is invisible for the specified duration. The default is <em>once</em>.
52        - The @b duration Specifies how long (in seconds) the invisibility lasts. The default is 0.
53
54        An example of a XML implementation of a InvisiblePickup would be:
55        @code
56        <InvisiblePickup
57            activationType = "immediate"
58            durationType = "continuous"
59            duration = 30.0
60        />
61        @endcode
62
63    @author
64        Benedict Simlinger
65
66    @ingroup PickupItems
67    */
68    class _PickupExport InvisiblePickup : public Pickup
69    {
70        public:
71
72            InvisiblePickup(Context* context); //!< Constructor.
73            virtual ~InvisiblePickup(); //!< Destructor.
74
75            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
76            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
77
78            /**
79            @brief Checks whether the Pawn is invisible.
80            @return Returns if the Pawn is invisible.
81            */
82            inline bool getInvisibility(bool) const
83                { return this->invisible_; }
84            /**
85            @brief Get the time the InvisibilityPickup lasts.
86            @return Returns the time in seconds the InvisibiltyPickup lasts.
87            */
88            inline float getDuration(void) const
89                { return this->duration_; }
90
91        protected:
92            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
93            void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last.
94
95            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
96
97        private:
98            void initialize(void); //!< Initializes the member variables.
99            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
100
101            Timer durationTimer_; //!< Timer.
102
103            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
104            float duration_; //! Duration of invisibility.
105    };
106}
107
108#endif // _InvisiblePickup_H__
Note: See TracBrowser for help on using the repository browser.