#pragma once namespace f8 { class TiledObject { public: a8::XValue GetProperty(const std::string& prop_name); bool HasProperty(const std::string& prop_name); public: std::map prop_hash; }; class TiledLayer { public: a8::XValue GetProperty(const std::string& prop_name); bool HasProperty(const std::string& prop_name); public: std::map prop_hash; a8::XValue data; }; //格子对象 struct GridCell { int x = 0; int y = 0; int speed = 0; int value = 0; }; struct StagePoint { int x = 0; int y = 0; int point = 0; std::vector relation_list; }; struct TriggerPoint { int x = 0; int y = 0; int point = 0; bool istrigger = false; }; class TiledMap { public: TiledLayer* ground_layer = nullptr; std::list speed_layers; int tile_count = 0; //瓦片地图的尺寸。(以瓦片数量为单位) int tile_width = 0; //瓦片的宽。(以像素点为单位) int tile_height = 0; //瓦片的高。(以像素点为单位) int tile_rows = 0; //行 int tile_columns = 0; //列 bool LoadTmxFile(const std::string& filename, bool new_tmx_format = false); std::list* GetObjectGroup(const std::string& object_class_name); void Dump(); void Init(); StagePoint* GetStageObject(int point); bool HasStageObject(int point); std::vector* GetStagePath(const std::string& path_name); bool HasStagePath(const std::string& path_name); std::vector SortGridList(std::vector* grid_list, StagePoint* sp); bool CalcCurrPos(std::vector& path_points, int old_pos_x, int old_pos_y, int time_ms, int& curr_pos_x, int& curr_pos_y); //速度设置 void SetGridCellSpeedByAreaId(std::map& area_speed_hash);//key:area_id value:speed private: void LoadWayPointsData(); private: std::map> layer_hash; std::map> object_group_hash; std::map stage_object_hash; //key point std::vector trigger_list; std::map> stage_path_hash; //key 11|2 std::vector grid_cell_list; //所有的格子数组 size = x * y std::map> grid_cell_hash; //key 11|2 坐标 std::map>> waypoint_hash_; //路点数据 }; }