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-10-04 17:24:46 +00:00
|
|
|
#include "../Instances.h"
|
2012-10-01 09:13:26 +00:00
|
|
|
|
2012-10-04 17:24:46 +00:00
|
|
|
class Instances;
|
2012-10-01 09:13:26 +00:00
|
|
|
class Sprite;
|
|
|
|
|
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-10-04 17:24:46 +00:00
|
|
|
Character(const Instances& instances, const sf::String& texturePath,
|
|
|
|
const PhysicalData& data, int health);
|
2012-10-01 09:02:44 +00:00
|
|
|
virtual ~Character() = 0;
|
|
|
|
|
|
|
|
static void think(float elapsedTime);
|
|
|
|
|
|
|
|
void onDamage(int damage);
|
|
|
|
|
|
|
|
// Protected functions.
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Implement this function for any (regular) AI computations.
|
|
|
|
*
|
|
|
|
* @param elapsedTime Amount of time to simulate.
|
|
|
|
*/
|
|
|
|
virtual void onThink(float elapsedTime) = 0;
|
|
|
|
|
|
|
|
virtual void onDeath();
|
|
|
|
|
|
|
|
// Private variables.
|
|
|
|
private:
|
2012-10-04 17:24:46 +00:00
|
|
|
static std::vector<Character*> mCharacterInstances;
|
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-04 17:24:46 +00:00
|
|
|
Instances mInstances;
|
2012-10-01 09:02:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_ACTOR_H_ */
|