Removed Pathfinder class.
This commit is contained in:
parent
394ebc04c7
commit
1dfd878a20
10 changed files with 11 additions and 69 deletions
|
@ -57,10 +57,10 @@ Game::generate() {
|
|||
mTileManager.insertTile(TileManager::TilePosition(x, 4), TileManager::Type::WALL);
|
||||
}
|
||||
|
||||
mWorld.insert(std::shared_ptr<Sprite>(new Enemy(mWorld, mPathfinder,
|
||||
mWorld.insert(std::shared_ptr<Sprite>(new Enemy(mWorld,
|
||||
sf::Vector2f(400.0f, 200.0f), Yaml("enemy.yaml"))));
|
||||
|
||||
mPlayer = std::shared_ptr<Player>(new Player(mWorld, mPathfinder,
|
||||
mPlayer = std::shared_ptr<Player>(new Player(mWorld,
|
||||
sf::Vector2f(200.0f, 100.0f), Yaml("player.yaml")));
|
||||
mWorld.insert(mPlayer);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "sprites/TileManager.h"
|
||||
#include "sprites/Player.h"
|
||||
#include "World.h"
|
||||
#include "util/Pathfinder.h"
|
||||
|
||||
class Player;
|
||||
class World;
|
||||
|
@ -57,7 +56,6 @@ private:
|
|||
|
||||
World mWorld;
|
||||
TileManager mTileManager;
|
||||
Pathfinder mPathfinder;
|
||||
std::shared_ptr<Player> mPlayer;
|
||||
|
||||
bool mQuit;
|
||||
|
|
|
@ -27,11 +27,9 @@ std::vector<Character*> Character::mCharacterInstances = std::vector<Character*>
|
|||
/**
|
||||
* Saves pointer to this instance in static var for think().
|
||||
*/
|
||||
Character::Character(World& world, Pathfinder& pathfinder,
|
||||
const Data& data, const Yaml& config) :
|
||||
Character::Character(World& world, const Data& data, const Yaml& config) :
|
||||
Sprite(data, config),
|
||||
mWorld(world),
|
||||
mPathfinder(pathfinder),
|
||||
mMaxHealth(config.get(KEY_HEALTH, DEFAULT_HEALTH)),
|
||||
mCurrentHealth(mMaxHealth),
|
||||
mMovementSpeed(config.get(KEY_SPEED, DEFAULT_SPEED)),
|
||||
|
@ -129,7 +127,7 @@ Character::releaseTrigger() {
|
|||
*/
|
||||
bool
|
||||
Character::setDestination(const sf::Vector2f& destination) {
|
||||
mPath = mPathfinder.getPath(*this, destination);
|
||||
//mPath = mPathfinder.getPath(*this, destination);
|
||||
// Make sure we found a path.
|
||||
if (mPath.empty()) {
|
||||
LOG_I("No path found to destination.");
|
||||
|
|
|
@ -14,14 +14,12 @@
|
|||
#include "Sprite.h"
|
||||
#include "../World.h"
|
||||
#include "../items/Weapon.h"
|
||||
#include "../util/Pathfinder.h"
|
||||
#include "../util/Yaml.h"
|
||||
|
||||
class World;
|
||||
class Weapon;
|
||||
class Instances;
|
||||
class Sprite;
|
||||
class Pathfinder;
|
||||
class Yaml;
|
||||
|
||||
/**
|
||||
|
@ -30,8 +28,7 @@ class Yaml;
|
|||
class Character : public Sprite {
|
||||
// Public functions.
|
||||
public:
|
||||
Character(World& world, Pathfinder& pathfinder,
|
||||
const Data& data, const Yaml& config);
|
||||
Character(World& world, const Data& data, const Yaml& config);
|
||||
virtual ~Character() = 0;
|
||||
|
||||
static void think(int elapsed);
|
||||
|
@ -62,7 +59,6 @@ private:
|
|||
static std::vector<Character*> mCharacterInstances;
|
||||
|
||||
World& mWorld;
|
||||
Pathfinder& mPathfinder;
|
||||
|
||||
const int mMaxHealth;
|
||||
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
#include "Corpse.h"
|
||||
|
||||
Enemy::Enemy(World& collection, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config) :
|
||||
Character(collection, pathfinder,
|
||||
Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||
Enemy::Enemy(World& collection, const sf::Vector2f& position, const Yaml& config) :
|
||||
Character(collection, Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||
config) {
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ class Yaml;
|
|||
class Enemy : public Character {
|
||||
// Public functions.
|
||||
public:
|
||||
Enemy(World& collection, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config);
|
||||
Enemy(World& collection, const sf::Vector2f& position, const Yaml& config);
|
||||
};
|
||||
|
||||
#endif /* DG_ENEMY_H_ */
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
/**
|
||||
* Initializes Sprite.
|
||||
*/
|
||||
Player::Player(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config) :
|
||||
Character(world, pathfinder,
|
||||
Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||
Player::Player(World& world, const sf::Vector2f& position, const Yaml& config) :
|
||||
Character(world, Data(position, 0, CATEGORY_ACTOR, MASK_ALL),
|
||||
config),
|
||||
mDirection(0) {
|
||||
}
|
||||
|
|
|
@ -13,12 +13,10 @@
|
|||
|
||||
#include "../abstract/Character.h"
|
||||
#include "../items/Weapon.h"
|
||||
#include "../util/Pathfinder.h"
|
||||
#include "../util/Yaml.h"
|
||||
|
||||
class Character;
|
||||
class Instances;
|
||||
class Pathfinder;
|
||||
class Weapon;
|
||||
class Yaml;
|
||||
|
||||
|
@ -40,8 +38,7 @@ public:
|
|||
|
||||
// Public functions.
|
||||
public:
|
||||
Player(World& world, Pathfinder& pathfinder,
|
||||
const sf::Vector2f& position, const Yaml& config);
|
||||
Player(World& world, const sf::Vector2f& position, const Yaml& config);
|
||||
|
||||
void setCrosshairPosition(const sf::Vector2f& position);
|
||||
void pullTrigger();
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Game.cpp
|
||||
*
|
||||
* Created on: 24.09.2012
|
||||
* Author: Felix
|
||||
*/
|
||||
|
||||
#include "Pathfinder.h"
|
||||
|
||||
|
||||
Pathfinder::Pathfinder() {
|
||||
}
|
||||
|
||||
std::vector<sf::Vector2f>
|
||||
Pathfinder::getPath(Sprite& physical, const sf::Vector2f& destination) {
|
||||
return std::vector<sf::Vector2f>();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* pathfinder.h
|
||||
*
|
||||
* Created on: 24.09.2012
|
||||
* Author: Felix
|
||||
*/
|
||||
|
||||
#ifndef PATHFINDER_H_
|
||||
#define PATHFINDER_H_
|
||||
|
||||
#include <SFML/System.hpp>
|
||||
|
||||
#include "../abstract/Sprite.h"
|
||||
|
||||
class Sprite;
|
||||
|
||||
class Pathfinder {
|
||||
// Public functions.
|
||||
public:
|
||||
Pathfinder();
|
||||
|
||||
std::vector<sf::Vector2f> getPath(Sprite& physical, const sf::Vector2f& destination);
|
||||
};
|
||||
|
||||
#endif /* PATHFINDER_H_ */
|
Reference in a new issue