Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/modules/pickup/items/ShieldPickup.h @ 12380

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

Documenting and cleanup.

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1
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.
33    @ingroup PickupItems
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
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.
57
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
69    @author
70        Eric Beier
71
72    @ingroup PickupItems
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
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
91                { return this->duration_; }
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
97                { return this->shieldHealth_; }
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
103                { return this->shieldAbsorption_; }
104
105        protected:
106            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
107            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
108
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.
112
113        private:
114            void initialize(void); //!< Initializes the member variables.
115            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
116
117            Timer durationTimer_; //!< Timer.
118
119            float duration_; //!< The health that is transferred to the Pawn.
120            float shieldHealth_; //!< The amount of damage the shield can sustain.
121            float shieldAbsorption_; //!< The percentage of damage that is absorbed by the shield.
122
123    };
124}
125
126#endif // _ShieldPickup_H__
Note: See TracBrowser for help on using the repository browser.