Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/items/ShieldPickup.h @ 8124

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

Documenting and cleanup.

  • Property svn:eol-style set to native
File size: 4.9 KB
RevLine 
[6884]1
[6869]2/*
3 *   ORXONOX - the hottest 3D action shooter ever to exist
4 *                    > www.orxonox.net <
5 *
6 *
7 *   License notice:
8 *
9 *   This program is free software; you can redistribute it and/or
10 *   modify it under the terms of the GNU General Public License
11 *   as published by the Free Software Foundation; either version 2
12 *   of the License, or (at your option) any later version.
13 *
14 *   This program is distributed in the hope that it will be useful,
15 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *   GNU General Public License for more details.
18 *
19 *   You should have received a copy of the GNU General Public License
20 *   along with this program; if not, write to the Free Software
21 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 *
23 *   Author:
24 *      Eric Beier
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30/**
31    @file ShieldPickup.h
32    @brief Declaration of the ShieldPickup class.
[7456]33    @ingroup PickupItems
[6869]34*/
35
36#ifndef _ShieldPickup_H__
37#define _ShieldPickup_H__
38
39#include "pickup/PickupPrereqs.h"
40
41#include <string>
42
43#include "pickup/Pickup.h"
44
45namespace orxonox {
46
47    /**
48    @brief
49        A Pickup which can add a Shield to the Pawn.
50
[7547]51        There are 5 parameters that can be cosen.
52        - The @b shieldhealth< The amount of damage points a shield can take before collapsing. The default is 0.
53        - The @b shieldabsorption The percentage the shield takes from the damage dealt to a Pawn. The default is 0.
54        - The @b activationType, <em>immediate</em> or <em>onUse</em>. defines if the ShiedlPickup is used when it's picked up or only after the player chooses to use it. The default is <em>immediate</em>.
55        - The @b durationType, <em>once</em> means, that the shield will stay until it collapses, <em>continuous</em> means, that the shield only stays for a limited amount of time, specifiey by the duration. The default is <em>once</em>.
56        - The @b duration the time in seconds the shield is active at the most. The default is 0.
[6869]57
[7547]58        An example of a XML implementation of a ShieldPickup would be:
59        @code
60        <ShieldPickup
61            shieldhealth = 30
62            shieldabsorption = 0.8
63            activationType = "immediate"
64            durationtype = "continuous"
65            duration = 20.0
66        />
67        @endcode
68
[6869]69    @author
70        Eric Beier
[7547]71
72    @ingroup PickupItems
[6869]73    */
74    class _PickupExport ShieldPickup : public Pickup
75    {
76        public:
77
78            ShieldPickup(BaseObject* creator); //!< Constructor.
79            virtual ~ShieldPickup(); //!< Destructor.
80
81            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
82
83            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
84            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
85
[7547]86            /**
87            @brief Get the duration, the time the shield is actvie at the most.
88            @return Returns the duration in seconds.
89            */
90            inline float getDuration(void) const
[6869]91                { return this->duration_; }
[7547]92            /**
93            @brief Get the shield health, the amount of damage the shield can sustain.
94            @return Returns the shield health.
95            */
96            inline float getShieldHealth() const
[6884]97                { return this->shieldHealth_; }
[7547]98            /**
99            @brief Get the shield absorption, the percentage of damage that is absorbed by the shield.
100            @return Returns the shield absorption.
101            */
102            inline float getShieldAbsorption() const
[6884]103                { return this->shieldAbsorption_; }
[6869]104
105        protected:
106            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
[7547]107            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
[6884]108
[7547]109            void setDuration(float duration); //!< Sets the duration.
110            void setShieldHealth(float shieldHealth); //!< Sets the health of the shield.
111            void setShieldAbsorption(float shieldAbsorption); //!< Sets the percentage the shield absorbs of the dealt damage.
[6869]112
113        private:
114            void initialize(void); //!< Initializes the member variables.
[6884]115            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
[6869]116
[7208]117            Timer durationTimer_; //!< Timer.
118
[6869]119            float duration_; //!< The health that is transferred to the Pawn.
[7547]120            float shieldHealth_; //!< The amount of damage the shield can sustain.
121            float shieldAbsorption_; //!< The percentage of damage that is absorbed by the shield.
[6884]122
[6869]123    };
124}
125
126#endif // _ShieldPickup_H__
Note: See TracBrowser for help on using the repository browser.