Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups/src/orxonox/objects/pickup/ModifierPickup.h @ 2898

Last change on this file since 2898 was 2864, checked in by danielh, 16 years ago

first commit of pickup system

  • working PickupCollection
  • working PickupSpawner
  • base classes for items
  • updated Pawn to include PickupCollection
  • updated Projectile to use damage modifier on hit
File size: 4.7 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 "PassiveItem.h"
40#include "ModifierType.h"
41#include "orxonox/tools/timer.h"
42
43namespace orxonox
44{
45    /**
46        @brief Class for a (temporary) modifier effect.
47        @author Daniel 'Huty' Haggenmueller
48    */
49    class _OrxonoxExport ModifierPickup : public PassiveItem
50    {
51    public:
52        ModifierPickup(BaseObject* creator);
53        virtual ~ModifierPickup();
54
55        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< To create a ModifierPickup through the level file.
56
57        virtual bool pickedUp(Pawn* pawn);                              //!< Override of the BaseItem::pickedUp() method.
58        virtual bool dropped(Pawn* pawn);                               //!< Override of the BaseItem::dropped() method
59
60        /**
61            @brief Get the duration of this pickup.
62            @return Returns how long the effect holds on.
63        */
64        inline float getDuration() const
65            { return this->duration_; }
66        /**
67            @brief Set the duration of this pickup.
68            @param duration How long the effect should hold.
69        */
70        inline void setDuration(float duration)
71            { this->duration_ = duration; }
72
73        /**
74            @brief Get the amount of damage this pickup adds.
75            @return Returns how much damage this pickup adds.
76        */
77        inline float getAdditiveDamage() const
78            { return this->getAdditiveModifier(ModifierType::Damage); }
79        /**
80            @brief Get the factor by which this pickup multiplies the damage.
81            @return Returns the factor by which to multiply damage.
82        */
83        inline float getMultiplicativeDamage() const
84            { return this->getMultiplicativeModifier(ModifierType::Damage); }
85
86        /**
87            @brief Set the amount of damage this pickup adds.
88            @param value How much damage this pickup adds.
89        */
90        inline void setAdditiveDamage(float value)
91            { this->setAdditiveModifier(ModifierType::Damage, value); }
92        /**
93            @brief Set the factor by which this pickup multiplies the damage.
94            @param value Factor by which to multiply damage.
95        */
96        inline void setMultiplicativeDamage(float value)
97            { this->setMultiplicativeModifier(ModifierType::Damage, value); }
98
99        void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out.
100    private:
101        float getAdditiveModifier(ModifierType::Enum type) const;               //!< Get the additive modifier for a given ModifierType.
102        float getMultiplicativeModifier(ModifierType::Enum type) const;         //!< Get the multiplicative modifier for a given ModifierType.
103        void setAdditiveModifier(ModifierType::Enum type, float value);         //!< Set the additive modifier for a given ModifierType.
104        void setMultiplicativeModifier(ModifierType::Enum type, float value);   //!< Set the multiplicative modifier for a given ModifierType
105
106        std::map<ModifierType::Enum, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
107        std::map<ModifierType::Enum, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
108
109        float duration_;                                                        //!< Duration of this pickup's effect (0 for unlimited).
110        Timer<ModifierPickup> timer_;                                           //!< Timer used if the pickup's effect has a time limit.
111    };
112}
113
114#endif /* _ModifierPickup_H__ */
Note: See TracBrowser for help on using the repository browser.