Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/menuanimations/src/orxonox/pickup/ModifierPickup.h @ 6921

Last change on this file since 6921 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
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 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Definition of ModifierPickup (temporary(?) pickup for testing).
32*/
33
34#ifndef _ModifierPickup_H__
35#define _ModifierPickup_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include <climits>
40#include <map>
41
42#include "tools/Timer.h"
43#include "ModifierType.h"
44#include "PassiveItem.h"
45
46namespace orxonox
47{
48    /**
49        @brief Class for a (temporary) modifier effect.
50        @author Daniel 'Huty' Haggenmueller
51    */
52    class _OrxonoxExport ModifierPickup : public PassiveItem
53    {
54    public:
55        ModifierPickup(BaseObject* creator);
56        virtual ~ModifierPickup();
57
58        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< To create a ModifierPickup through the level file.
59
60        virtual bool pickedUp(Pawn* pawn);                              //!< Override of the BaseItem::pickedUp() method.
61        virtual bool dropped(Pawn* pawn);                               //!< Override of the BaseItem::dropped() method
62
63        virtual int getMaxCarryAmount(){ return INT_MAX; }              //!< Allow the player to carry infinite ModPickups
64
65        /**
66            @brief Get the duration of this pickup.
67            @return Returns how long the effect holds on.
68        */
69        inline float getDuration() const
70            { return this->duration_; }
71        /**
72            @brief Set the duration of this pickup.
73            @param duration How long the effect should hold.
74        */
75        inline void setDuration(float duration)
76            { this->duration_ = duration; }
77
78        /**
79            @brief Get the amount of damage this pickup adds.
80            @return Returns how much damage this pickup adds.
81        */
82        inline float getAdditiveDamage() const
83            { return this->getAdditiveModifier(ModifierType::Damage); }
84        /**
85            @brief Get the factor by which this pickup multiplies the damage.
86            @return Returns the factor by which to multiply damage.
87        */
88        inline float getMultiplicativeDamage() const
89            { return this->getMultiplicativeModifier(ModifierType::Damage); }
90
91        /**
92            @brief Set the amount of damage this pickup adds.
93            @param value How much damage this pickup adds.
94        */
95        inline void setAdditiveDamage(float value)
96            { this->setAdditiveModifier(ModifierType::Damage, value); }
97        /**
98            @brief Set the factor by which this pickup multiplies the damage.
99            @param value Factor by which to multiply damage.
100        */
101        inline void setMultiplicativeDamage(float value)
102            { this->setMultiplicativeModifier(ModifierType::Damage, value); }
103
104        /**
105            @brief Get the amount of acceleration this pickup adds.
106            @return Returns how much acceleration this pickup adds.
107        */
108        inline float getAdditiveAcceleration() const
109            { return this->getAdditiveModifier(ModifierType::Acceleration); }
110        /**
111            @brief Get the factor by which this pickup multiplies the acceleration.
112            @return Returns the factor by which to multiply acceleration.
113        */
114        inline float getMultiplicativeAcceleration() const
115            { return this->getMultiplicativeModifier(ModifierType::Acceleration); }
116
117        /**
118            @brief Set the amount of acceleration this pickup adds.
119            @param value How much acceleration this pickup adds.
120        */
121        inline void setAdditiveAcceleration(float value)
122            { this->setAdditiveModifier(ModifierType::Acceleration, value); }
123        /**
124            @brief Set the factor by which this pickup multiplies the acceleration.
125            @param value Factor by which to multiply acceleration.
126        */
127        inline void setMultiplicativeAcceleration(float value)
128            { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
129
130        void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out.
131       
132    private:
133        float getAdditiveModifier(ModifierType::Value type) const;               //!< Get the additive modifier for a given ModifierType.
134        float getMultiplicativeModifier(ModifierType::Value type) const;         //!< Get the multiplicative modifier for a given ModifierType.
135        void setAdditiveModifier(ModifierType::Value type, float value);         //!< Set the additive modifier for a given ModifierType.
136        void setMultiplicativeModifier(ModifierType::Value type, float value);   //!< Set the multiplicative modifier for a given ModifierType
137
138        std::map<ModifierType::Value, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
139        std::map<ModifierType::Value, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
140
141        float duration_;                                                         //!< Duration of this pickup's effect (0 for unlimited).
142        Timer timer_;                                                            //!< Timer used if the pickup's effect has a time limit.
143    };
144}
145
146#endif /* _ModifierPickup_H__ */
Note: See TracBrowser for help on using the repository browser.