#pragma once #include "Actor/Map/GameMapLayer.h" #include "Asset/Asset_Script.h" #include "Actor/Map/Tile.h" #include #include #include class BaseObject; class GameMapCamera; class GameMap : public Actor { public: struct BackGroundAni { std::string filename; std::string layer; std::string order; }; struct MapAni { std::string filename; std::string layer; int XPos; int YPos; int ZPos; }; struct MapNpc { int id; std::string direction; int XPos; int YPos; int ZPos; }; struct MapMoveArea { int town = 0; int area = 0; }; using MapInfoBody = std::variant< int, std::string, std::map, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector>; public: // 地图信息 std::unordered_map _MapInfo; // 地图路径 std::string _MapPath; // 地图文件夹 std::string _MapDir; // 地板画布 RefPtr _Tile = nullptr; // 地图宽度 int _MapLength = 0; // 地图高度 int _MapHeight = 0; // 可行区域 std::vector _MovableArea; // 传送区域 std::vector _MoveArea; // 调试模式 bool _DebugMode = false; public: // 图层Map 图层类型 显示对象 std::unordered_map> _LayerMap; // 背景层移动速率 int BackgroundMoveSpeed = 103; // 地图Y轴偏移量 int MapOffsetY = 0; public: GameMap(/* args */); ~GameMap(); /**加载地图 (地图路径) */ void LoadMap(std::string mapName); /**进入地图执行的操作 */ void Enter(); /**重载OnUpdate函数 */ void OnUpdate(float deltaTime) override; public: /**读取脚本配置 */ void InitConfiguration(std::string mapName); /**初始化地板 */ void InitTile(); /**初始化背景动画 */ void InitBackgroundAnimation(); /**初始化地图动画 */ void InitMapAnimation(); /**初始化移动区域 */ void InitVirtualMovableArea(); /**初始化传送区域 */ void InitMoveArea(); /**添加对象 */ void AddObject(RefPtr object); public: // 检查是否可移动 VecFPos3 CheckIsItMovable(VecFPos3 CurPos, VecFPos3 PosOffset); // 检查是否进入传送区域 MapMoveArea CheckIsItMoveArea(VecFPos3 CurPos); /**获取移动区域信息 */ std::vector &GetMoveAreaInfo(); /**获取移动区域坐标信息 */ SDL_Rect GetMovablePositionArea(int Index); };