Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Documenting and cleanup.

  • Property svn:eol-style set to native
File size: 4.3 KB
RevLine 
[6641]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.
[7456]32    @ingroup PickupItems
[6641]33*/
34
35#ifndef _InvisiblePickup_H__
36#define _InvisiblePickup_H__
37
38#include "pickup/PickupPrereqs.h"
39
40#include <string>
[7163]41
[6641]42#include "pickup/Pickup.h"
43
44namespace orxonox {
[7163]45
[6641]46    /**
47    @brief
48        A pickup that makes the Pawn invisible.
[7547]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.
[7541]53
[7547]54        An example of a XML implementation of a InvisiblePickup would be:
[7545]55        @code
[7547]56        <InvisiblePickup
[7545]57            activationType = "immediate"
58            durationType = "continuous"
59            duration = 30.0
60        />
61        @endcode
62
[6641]63    @author
64        Benedict Simlinger
[7541]65
66    @ingroup PickupItems
[6641]67    */
68    class _PickupExport InvisiblePickup : public Pickup
69    {
70        public:
[7163]71
[6641]72            InvisiblePickup(BaseObject* creator); //!< Constructor.
73            virtual ~InvisiblePickup(); //!< Destructor.
[7544]74           
[6641]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.
[7163]78
[6708]79            /**
80            @brief Checks whether the Pawn is invisible.
[6641]81            @return Returns if the Pawn is invisible.
82            */
[7547]83            inline bool getInvisibility(bool) const
[6641]84                { return this->invisible_; }
[7544]85            /**
86            @brief Get the time the InvisibilityPickup lasts.
87            @return Returns the time in seconds the InvisibiltyPickup lasts.
88            */
[7547]89            inline float getDuration(void) const
[6708]90                { return this->duration_; }
[7163]91
[6641]92        protected:
[7547]93            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
[7163]94
[7544]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
[6641]100        private:
[6708]101            void initialize(void); //!< Initializes the member variables.
[6641]102            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
[7208]103
104            Timer durationTimer_; //!< Timer.
105
[6708]106            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
107            float duration_; //! Duration of invisibility.
[6641]108    };
109}
110
111#endif // _InvisiblePickup_H__
Note: See TracBrowser for help on using the repository browser.