This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/abstract/Character.h

73 lines
1.6 KiB
C
Raw Normal View History

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_
#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-10-14 16:14:06 +00:00
#include "../types/String.h"
2012-12-22 00:44:36 +00:00
#include "../util/Pathfinder.h"
#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;
class Instances;
2012-10-01 09:13:26 +00:00
class Sprite;
2012-12-22 00:44:36 +00:00
class Pathfinder;
class Yaml;
2012-10-01 09:13:26 +00:00
2012-10-01 09:02:44 +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,
const Data& data, const Yaml& config);
2012-10-01 09:02:44 +00:00
virtual ~Character() = 0;
static void think(float elapsedTime);
void onDamage(int damage);
// Protected functions.
protected:
virtual void onThink(float elapsedTime);
2012-10-01 09:02:44 +00:00
virtual void onDeath();
float getMovementSpeed() const;
2012-10-13 16:57:12 +00:00
void fire();
bool setDestination(const Vector2f& destination);
void move();
2012-10-01 09:02:44 +00:00
// Private variables.
private:
static const String KEY_HEALTH;
static const int DEFAULT_HEALTH;
static const String KEY_SPEED;
static const float DEFAULT_SPEED;
/// The distance to a point where it is considered reached.
static const float POINT_REACHED_DISTANCE;
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.
const float mMovementSpeed;
2012-10-13 16:57:12 +00:00
Weapon mWeapon;
std::vector<Vector2f> mPath; //< Contains nodes to reach a set destination.
bool mStartPathfinding; //< True if a movement destination was just set.
2012-10-01 09:02:44 +00:00
};
#endif /* DG_ACTOR_H_ */