Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h @ 3137

Last change on this file since 3137 was 3046, checked in by bknecht, 16 years ago

introducing the bouncing pickup

  • Property svn:eol-style set to native
File size: 4.4 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 PickupSpawner.
32*/
33
34#ifndef _PickupSpawner_H__
35#define _PickupSpawner_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include "core/BaseObject.h"
40#include "objects/Tickable.h"
41#include "objects/worldentities/StaticEntity.h"
42#include "tools/Timer.h"
43
44namespace orxonox
45{
46    class BaseItem;
47
48    /**
49        @brief PickupSpawner.
50        @author Daniel 'Huty' Haggenmueller
51    */
52    class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
53    {
54    public:
55        PickupSpawner(BaseObject* creator);
56        virtual ~PickupSpawner();
57
58        virtual void changedActivity();                                 //!< Invoked when activity has changed (set visibilty).
59        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
60        virtual void tick(float dt);
61
62        void trigger(Pawn* pawn);                                       //!< Method called when a Pawn is close enough.
63        void respawnTimerCallback();                                    //!< Method called when the timer runs out.
64
65        /**
66            @brief Get the template name for the item to spawn.
67            @return Returns the name of the template of the item to spawn.
68        */
69        inline const std::string& getItemTemplateName() const
70            { return this->itemTemplateName_; }
71        void setItemTemplateName(const std::string& name);              //!< Set the template name of the item to spawn.
72
73        /**
74            @brief Get the template for the item to spawn.
75            @return Returns the template of the item to spawn.
76        */
77        inline Template* getItemTemplate() const
78            { return this->itemTemplate_; }
79
80        /**
81            @brief Get the distance in which to trigger.
82            @return Returns the distance in which this gets triggered.
83        */
84        inline float getTriggerDistance() const
85            { return this->triggerDistance_; }
86        /**
87            @brief Set the distance in which to trigger.
88            @param value The new distance in which to trigger.
89        */
90        inline void setTriggerDistance(float value)
91            { this->triggerDistance_ = value; }
92
93        /**
94            @brief Get the time to respawn.
95            @returns Returns the time after which this gets re-actived.
96        */
97        inline float getRespawnTime() const
98            { return this->respawnTime_; }
99        /**
100            @brief Set the time to respawn.
101            @param time New time after which this gets re-actived.
102        */
103        inline void setRespawnTime(float time)
104            { this->respawnTime_ = time; }
105    private:
106        std::string itemTemplateName_;          //!< Template name of the item to spawn.
107        Template* itemTemplate_;                //!< Template of the item to spawn.
108
109        float triggerDistance_;                 //!< Distance in which this gets triggered.
110
111        /* Pickup animation */
112        float tickSum_;                         //!< Adds up tick to use in sine movement
113        static const float bounceSpeed_s;       //!< Speed of pickup to bounce up and down
114        static const float bounceDistance_s;    //!< Distance the pickup bounces up and down
115        static const float rotationSpeed_s;     //!< Rotation speed of pickup
116
117        float respawnTime_;                     //!< Time after which this gets re-actived.
118        Timer<PickupSpawner> respawnTimer_;     //!< Timer used for re-activating.
119    };
120}
121
122#endif /* _PickupSpawner_H__ */
Note: See TracBrowser for help on using the repository browser.