1 | /*! |
---|
2 | * @file spawning_point.h |
---|
3 | * Definition of a spawning point within the game, used for network game |
---|
4 | */ |
---|
5 | |
---|
6 | |
---|
7 | #ifndef _SPAWNING_POINT |
---|
8 | #define _SPAWNING_POINT |
---|
9 | |
---|
10 | #include "world_entity.h" |
---|
11 | |
---|
12 | class World; |
---|
13 | class TiXmlElement; |
---|
14 | |
---|
15 | //! The spawning point for world entities |
---|
16 | class SpawningPoint : public WorldEntity { |
---|
17 | |
---|
18 | public: |
---|
19 | SpawningPoint (World* world, const Vector& absCoordinate = Vector(0.0, 0.0, 0.0)); |
---|
20 | SpawningPoint (const Vector& position, float frequency, float seed, ClassID classID, World* world); |
---|
21 | virtual ~SpawningPoint (); |
---|
22 | void init(); |
---|
23 | |
---|
24 | virtual void loadParams(const TiXmlElement* root); |
---|
25 | |
---|
26 | /** sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */ |
---|
27 | void SpawningPoint::setSpawningEntity(ClassID classID) { this->classID = classID; } |
---|
28 | /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */ |
---|
29 | void SpawningPoint::setSpawningFrequency(float frequency) { this->frequency = frequency; } |
---|
30 | /** sets the seed of the position vector @param seed: the random seed around the given vector */ |
---|
31 | void SpawningPoint::setPositionSeed(float seed) { this->seed = seed; } |
---|
32 | |
---|
33 | void spawn(); |
---|
34 | |
---|
35 | virtual void tick(float dt); |
---|
36 | virtual void draw(); |
---|
37 | |
---|
38 | private: |
---|
39 | float frequency; //!< the frequency for entity spawning |
---|
40 | float countDown; //!< the timer that counts down until the next spawn |
---|
41 | float seed; //!< the random seed of the position |
---|
42 | ClassID classID; //!< the classid of the entity to spawn |
---|
43 | World* world; //!< reference to the world it belongs to (or in the future: the object manager) |
---|
44 | |
---|
45 | }; |
---|
46 | |
---|
47 | #endif /* _SPAWNING_POINT */ |
---|