IMapAdventureObject.h
2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// IMapAdventureObject.h
// WattsenglishFoodApp
//
// Created by Katarzyna Kalinowska-Górska on 21/03/2020.
//
#ifndef IMapAdventureObject_h
#define IMapAdventureObject_h
#include "AniMapUtils.h"
#include "AniJSONParseUtils.h"
#include "cocos2d.h"
#include "IMapImageObject.h"
class IMapAdventureObjectDelegate;
class IMapAdventureObject
{
public:
inline const std::string& getObjectName() const { return m_objectName; }
inline const std::string& getObjectClassName() const { return m_objectClassName; }
inline bool isActive() const {return m_active; }
// the tiles that we click on to start interacting wit hthe object / approach
virtual std::vector<AniMapUtils::TileData> getOccupiedTiles() const = 0;
// the tiles that we finish on when approaching the object
virtual std::vector<AniMapUtils::TileData> getEntryTiles() const = 0;
// the tiles that are blocked because of this object
virtual std::vector<AniMapUtils::TileData> getBlockedTiles() const { return std::vector<AniMapUtils::TileData>(); };
inline std::map<std::string, IMapImageObject*> getAssociatedMapImageObjects() const { return m_mapImageObjects; }
inline void setDelegate(IMapAdventureObjectDelegate* p_delegate){ m_delegate = p_delegate; }
inline void setActive(bool p_active) { m_active = p_active; }
virtual void reset() = 0;
virtual ~IMapAdventureObject(){}
protected:
std::string m_objectName;
std::string m_objectClassName;
// std::vector<AniMapUtils::TileData> m_occupiedTiles;
std::map<std::string, IMapImageObject*> m_mapImageObjects;
IMapAdventureObjectDelegate* m_delegate {nullptr};
bool m_active {true};
IMapAdventureObject(const rapidjson::Value& p_mapObjectData) {
if(AniJSONParseUtils::hasMemberString(p_mapObjectData, "objectName")){
m_objectName = p_mapObjectData["objectName"].GetString();
}
m_objectClassName = "MapAdventureObject";
}
IMapAdventureObject(std::string p_objectName) {
m_objectName = p_objectName;
m_objectClassName = "MapAdventureObject";
}
};
typedef std::string IMapAdventureObjectEventType;
static IMapAdventureObjectEventType IMapAdventureObjectEventTypeNone = "";
class IMapAdventureObjectEvent {
public:
IMapAdventureObjectEvent(IMapAdventureObjectEventType p_eventType) : eventType(p_eventType){}
IMapAdventureObjectEventType eventType {IMapAdventureObjectEventTypeNone};
void* eventData {nullptr};
};
class IMapAdventureObjectDelegate {
public:
virtual void onMapAdventureObjectEvent(IMapAdventureObject* p_object, IMapAdventureObjectEvent* event) = 0;
virtual void onOccupiedTilesDataChanged(IMapAdventureObject* p_object) = 0; // call whenever the return value of getoccupiedTiles() or blockedtiles change
virtual void onBlockedTilesDataChanged(IMapAdventureObject* p_object, std::vector<AniMapUtils::TileData> p_oldBlockedTiles, std::vector<AniMapUtils::TileData> p_newBlockedTiles) = 0;
};
#endif /* IMapAdventureObject_h */