Hello.
I am just programing the project i am working on.
The issue is that i seperated code like this:
In AI::ChaseUnit(...) i need to use Unit::unitDataID
I feel bad about passing it since it is one object?
Cant i do something like this->unitDataID from the AI::Chase(...) to access data from Unit:: ?
I can just pass the data to the function but as i said... i am looking for something other.
Hello.
//////////////////////// THE RAW CODE ////////////////////
//Unit.h
namespace en
{
enum UnitTypes
{
Player = 1,
Sheep = 2,
Wolf = 3,
};
};
struct unitData
{
std::string name;
en::UnitTypes type;
int hp;
int sightRange;
}
const unitDataT [] =
{
{"Player", en::Player, 999, 5},
{"Sheep", en::Sheep, 4, 4},
{"Wolf", en::Wolf, 6, 5},
};
class Unit : public AI
{
public:
Unit(Map & objMap, Textures & objTex, int unitType = en::UnitTypes::Sheep);
Unit(Map & objMap, Textures & objTex, int PosX, int PosY, en::UnitTypes unitType = en::UnitTypes::Sheep);
void LoopUnit();
int unitDataID;
int posX, posY;
sf::Sprite spr;
};
//AI.h
class AI
{
public:
AI(Map & ObjMap);
void DecideAction(int unitType);
void Execute(Unit & unit);
bool isDone;
private: //Functions
void Walk();
void Chase(UnitHolder objUniHol);
void Rest();
private:
int moveAmountX, moveAmountY;
int actionType;
int actTime;
sf::Clock clockLastActed;
//Clock how long // how long is the unit doing current action
Map & objMap;
};
Here is the raw code so sorry