// // 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 getOccupiedTiles() const = 0; // the tiles that we finish on when approaching the object virtual std::vector getEntryTiles() const = 0; // the tiles that are blocked because of this object virtual std::vector getBlockedTiles() const { return std::vector(); }; inline std::map 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 m_occupiedTiles; std::map 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 p_oldBlockedTiles, std::vector p_newBlockedTiles) = 0; }; #endif /* IMapAdventureObject_h */