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

60 lines
1.3 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_
2012-10-01 09:13:26 +00:00
#include "Sprite.h"
class TileManager;
2012-12-22 00:44:36 +00:00
class World;
2012-10-13 16:57:12 +00:00
class Weapon;
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-09-12 12:21:57 +00:00
public:
explicit Character(World& world, TileManager& tileManager,
const Data& data, const Yaml& config);
2012-10-01 09:02:44 +00:00
virtual ~Character() = 0;
void onDamage(int damage);
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();
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);
bool isMoving() const;
bool isVisible(const sf::Vector2f& target) const;
std::vector<std::shared_ptr<Character> > getCharacters() const;
2012-10-01 09:02:44 +00:00
private:
void move();
2012-10-01 09:02:44 +00:00
private:
/// Maximum distance where an enemy will be detected.
static const float VISION_DISTANCE;
friend class World;
2012-12-22 00:44:36 +00:00
World& mWorld;
TileManager& mTileManager;
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;
std::unique_ptr<Weapon> mWeapon;
2012-12-22 14:10:26 +00:00
std::vector<sf::Vector2f> mPath; //< Contains nodes to reach a set destination.
sf::Vector2f mLastPosition;
2012-10-01 09:02:44 +00:00
};
#endif /* DG_ACTOR_H_ */