2012-10-01 09:02:44 +00:00
|
|
|
/*
|
|
|
|
* Actor.h
|
|
|
|
*
|
|
|
|
* Created on: 02.09.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_ACTOR_H_
|
|
|
|
#define DG_ACTOR_H_
|
|
|
|
|
2012-12-22 14:10:26 +00:00
|
|
|
#include <string>
|
2012-10-01 09:02:44 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2012-10-01 09:13:26 +00:00
|
|
|
#include "Sprite.h"
|
2012-12-22 00:44:36 +00:00
|
|
|
#include "../World.h"
|
2012-10-13 16:57:12 +00:00
|
|
|
#include "../items/Weapon.h"
|
2012-12-22 00:44:36 +00:00
|
|
|
#include "../util/Pathfinder.h"
|
2012-10-12 17:34:07 +00:00
|
|
|
#include "../util/Yaml.h"
|
2012-10-01 09:13:26 +00:00
|
|
|
|
2012-12-22 00:44:36 +00:00
|
|
|
class World;
|
2012-10-13 16:57:12 +00:00
|
|
|
class Weapon;
|
2012-10-04 17:24:46 +00:00
|
|
|
class Instances;
|
2012-10-01 09:13:26 +00:00
|
|
|
class Sprite;
|
2012-12-22 00:44:36 +00:00
|
|
|
class Pathfinder;
|
2012-10-12 17:34:07 +00:00
|
|
|
class Yaml;
|
2012-10-01 09:13:26 +00:00
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
/**
|
2012-10-04 17:24:46 +00:00
|
|
|
* Provides think function for AI, manages health, drops body on death.
|
2012-10-01 09:02:44 +00:00
|
|
|
*/
|
2012-10-01 09:13:26 +00:00
|
|
|
class Character : public Sprite {
|
2012-10-01 09:02:44 +00:00
|
|
|
// Public functions.
|
2012-09-12 12:21:57 +00:00
|
|
|
public:
|
2012-12-22 13:56:17 +00:00
|
|
|
Character(World& world, Pathfinder& pathfinder,
|
2012-12-22 12:44:17 +00:00
|
|
|
const Data& data, const Yaml& config);
|
2012-10-01 09:02:44 +00:00
|
|
|
virtual ~Character() = 0;
|
|
|
|
|
2013-03-09 15:25:04 +00:00
|
|
|
static void think(int elapsed);
|
2012-10-01 09:02:44 +00:00
|
|
|
|
|
|
|
void onDamage(int damage);
|
|
|
|
|
|
|
|
// Protected functions.
|
|
|
|
protected:
|
2013-03-09 15:25:04 +00:00
|
|
|
virtual void onThink(int elapsed);
|
2012-10-01 09:02:44 +00:00
|
|
|
virtual void onDeath();
|
2012-10-13 16:50:28 +00:00
|
|
|
float getMovementSpeed() const;
|
2012-12-24 00:14:22 +00:00
|
|
|
void pullTrigger();
|
|
|
|
void releaseTrigger();
|
2012-12-22 14:10:26 +00:00
|
|
|
bool setDestination(const sf::Vector2f& destination);
|
2012-10-13 17:36:33 +00:00
|
|
|
void move();
|
2012-10-01 09:02:44 +00:00
|
|
|
|
|
|
|
// Private variables.
|
|
|
|
private:
|
2012-12-22 14:10:26 +00:00
|
|
|
static const std::string KEY_HEALTH;
|
2012-12-20 13:59:05 +00:00
|
|
|
static const int DEFAULT_HEALTH;
|
2012-12-22 14:10:26 +00:00
|
|
|
static const std::string KEY_SPEED;
|
2012-12-20 13:59:05 +00:00
|
|
|
static const float DEFAULT_SPEED;
|
2012-12-23 23:49:49 +00:00
|
|
|
static const std::string KEY_WEAPON;
|
|
|
|
static const std::string DEFAULT_WEAPON;
|
2012-10-13 17:36:33 +00:00
|
|
|
/// The distance to a point where it is considered reached.
|
|
|
|
static const float POINT_REACHED_DISTANCE;
|
2012-10-12 17:34:07 +00:00
|
|
|
|
2012-10-04 17:24:46 +00:00
|
|
|
static std::vector<Character*> mCharacterInstances;
|
2012-10-01 09:02:44 +00:00
|
|
|
|
2012-12-22 00:44:36 +00:00
|
|
|
World& mWorld;
|
2012-12-22 13:56:17 +00:00
|
|
|
Pathfinder& mPathfinder;
|
2012-12-22 00:44:36 +00:00
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
const int mMaxHealth;
|
2012-09-12 12:21:57 +00:00
|
|
|
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
|
2012-10-13 16:50:28 +00:00
|
|
|
const float mMovementSpeed;
|
2012-10-13 16:57:12 +00:00
|
|
|
Weapon mWeapon;
|
2012-12-22 14:10:26 +00:00
|
|
|
std::vector<sf::Vector2f> mPath; //< Contains nodes to reach a set destination.
|
2012-10-13 17:36:33 +00:00
|
|
|
bool mStartPathfinding; //< True if a movement destination was just set.
|
2012-10-01 09:02:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_ACTOR_H_ */
|