Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/modules/pickup/items/InvisiblePickup.h @ 9226

Last change on this file since 9226 was 7547, checked in by dafrick, 14 years ago

Documenting and cleanup.

  • Property svn:eol-style set to native
File size: 4.3 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(BaseObject* creator); //!< 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            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
78
79            /**
80            @brief Checks whether the Pawn is invisible.
81            @return Returns if the Pawn is invisible.
82            */
83            inline bool getInvisibility(bool) const
84                { return this->invisible_; }
85            /**
86            @brief Get the time the InvisibilityPickup lasts.
87            @return Returns the time in seconds the InvisibiltyPickup lasts.
88            */
89            inline float getDuration(void) const
90                { return this->duration_; }
91
92        protected:
93            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
94
95            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
96            void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last.
97
98            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
99
100        private:
101            void initialize(void); //!< Initializes the member variables.
102            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
103
104            Timer durationTimer_; //!< Timer.
105
106            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
107            float duration_; //! Duration of invisibility.
108    };
109}
110
111#endif // _InvisiblePickup_H__
Note: See TracBrowser for help on using the repository browser.