Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10214 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
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
[9667]72            InvisiblePickup(Context* context); //!< Constructor.
[6641]73            virtual ~InvisiblePickup(); //!< Destructor.
[9348]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.
[7163]77
[6708]78            /**
79            @brief Checks whether the Pawn is invisible.
[6641]80            @return Returns if the Pawn is invisible.
81            */
[7547]82            inline bool getInvisibility(bool) const
[6641]83                { return this->invisible_; }
[7544]84            /**
85            @brief Get the time the InvisibilityPickup lasts.
86            @return Returns the time in seconds the InvisibiltyPickup lasts.
87            */
[7547]88            inline float getDuration(void) const
[6708]89                { return this->duration_; }
[7163]90
[6641]91        protected:
[7544]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
[6641]97        private:
[6708]98            void initialize(void); //!< Initializes the member variables.
[6641]99            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
[7208]100
101            Timer durationTimer_; //!< Timer.
102
[6708]103            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
104            float duration_; //! Duration of invisibility.
[6641]105    };
106}
107
108#endif // _InvisiblePickup_H__
Note: See TracBrowser for help on using the repository browser.