2012-09-09 20:50:15 +00:00
|
|
|
/*
|
|
|
|
* Weapon.h
|
|
|
|
*
|
|
|
|
* Created on: 12.08.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_WEAPON_H_
|
|
|
|
#define DG_WEAPON_H_
|
|
|
|
|
2013-03-29 17:34:51 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <SFML/System.hpp>
|
2012-09-09 20:50:15 +00:00
|
|
|
|
|
|
|
#include "../particle/Emitter.h"
|
|
|
|
|
2012-12-23 14:50:49 +00:00
|
|
|
class Sprite;
|
2012-10-12 17:22:53 +00:00
|
|
|
class Yaml;
|
2013-03-29 16:59:35 +00:00
|
|
|
class World;
|
|
|
|
class Particle;
|
2012-09-14 18:39:56 +00:00
|
|
|
|
2012-09-09 20:50:15 +00:00
|
|
|
/**
|
|
|
|
* Loading mechanism:
|
|
|
|
* - pass enum value and load mapped xml
|
|
|
|
* - pass xml filename
|
|
|
|
*/
|
2013-04-04 21:00:52 +00:00
|
|
|
class Weapon : public Emitter {
|
2012-09-09 20:50:15 +00:00
|
|
|
public:
|
2013-03-30 15:39:46 +00:00
|
|
|
explicit Weapon(World& world, Sprite& holder, const Yaml& config);
|
2012-09-09 20:50:15 +00:00
|
|
|
|
2012-12-24 00:14:22 +00:00
|
|
|
void pullTrigger();
|
|
|
|
void releaseTrigger();
|
2013-03-09 15:25:04 +00:00
|
|
|
void onThink(int elapsed);
|
2013-04-04 21:00:52 +00:00
|
|
|
|
2012-09-09 20:50:15 +00:00
|
|
|
protected:
|
2013-03-29 17:34:51 +00:00
|
|
|
std::shared_ptr<Sprite> createParticle();
|
2012-09-09 20:50:15 +00:00
|
|
|
|
|
|
|
private:
|
2012-12-22 14:10:26 +00:00
|
|
|
static const std::string KEY_BULLET;
|
|
|
|
static const std::string DEFAULT_BULLET;
|
|
|
|
static const std::string KEY_INTERVAL;
|
2012-12-20 13:59:05 +00:00
|
|
|
static const int DEFAULT_INTERVAL;
|
2012-12-24 00:14:22 +00:00
|
|
|
static const std::string KEY_AUTOMATIC;
|
|
|
|
static const bool DEFAULT_AUTOMATIC;
|
2012-09-11 19:15:16 +00:00
|
|
|
|
2012-12-23 14:50:49 +00:00
|
|
|
Sprite& mHolder;
|
2012-10-12 17:04:34 +00:00
|
|
|
|
2012-12-22 14:10:26 +00:00
|
|
|
sf::Vector2f mOffset; //< Offset to the point where bullets are inserted (from holder center).
|
2013-03-09 15:25:04 +00:00
|
|
|
const std::string mBullet; //< Bullet config filename.
|
|
|
|
int mLastShotWaitInterval; //< Remaining time left after firing last bullet before firing next one.
|
|
|
|
const int mFireInterval; //< Time between firing bullets.
|
|
|
|
bool mFire; //< True if the trigger is pulled.
|
|
|
|
bool mAutomatic; //< True if the weapon continues firing after pulling the trigger once.
|
2012-10-19 13:44:45 +00:00
|
|
|
|
2012-09-09 20:50:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_WEAPON_H_ */
|