Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12288 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 4.7 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
[9667]78            ShieldPickup(Context* context); //!< Constructor.
[6869]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
[7547]85            /**
86            @brief Get the duration, the time the shield is actvie at the most.
87            @return Returns the duration in seconds.
88            */
89            inline float getDuration(void) const
[6869]90                { return this->duration_; }
[7547]91            /**
92            @brief Get the shield health, the amount of damage the shield can sustain.
93            @return Returns the shield health.
94            */
95            inline float getShieldHealth() const
[6884]96                { return this->shieldHealth_; }
[7547]97            /**
98            @brief Get the shield absorption, the percentage of damage that is absorbed by the shield.
99            @return Returns the shield absorption.
100            */
101            inline float getShieldAbsorption() const
[6884]102                { return this->shieldAbsorption_; }
[6869]103
104        protected:
[7547]105            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
[6884]106
[7547]107            void setDuration(float duration); //!< Sets the duration.
108            void setShieldHealth(float shieldHealth); //!< Sets the health of the shield.
109            void setShieldAbsorption(float shieldAbsorption); //!< Sets the percentage the shield absorbs of the dealt damage.
[6869]110
111        private:
112            void initialize(void); //!< Initializes the member variables.
[6884]113            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
[6869]114
[7208]115            Timer durationTimer_; //!< Timer.
116
[6869]117            float duration_; //!< The health that is transferred to the Pawn.
[7547]118            float shieldHealth_; //!< The amount of damage the shield can sustain.
119            float shieldAbsorption_; //!< The percentage of damage that is absorbed by the shield.
[6884]120
[6869]121    };
122}
123
124#endif // _ShieldPickup_H__
Note: See TracBrowser for help on using the repository browser.