98 lines
2.1 KiB
C++
98 lines
2.1 KiB
C++
#pragma once
|
|
#include "Actor/Map/GameMapLayer.h"
|
|
#include "Asset/Asset_Script.h"
|
|
#include "Actor/Map/Tile.h"
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <variant>
|
|
|
|
class BaseObject;
|
|
class GameMapCamera;
|
|
class GameMap : public Actor
|
|
{
|
|
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;
|
|
int area;
|
|
};
|
|
|
|
using MapInfoBody = std::variant<
|
|
int,
|
|
std::string,
|
|
std::vector<BackGroundAni>,
|
|
std::vector<MapAni>,
|
|
std::vector<MapNpc>,
|
|
std::vector<MapMoveArea>,
|
|
std::vector<int>,
|
|
std::vector<std::string>>;
|
|
|
|
public:
|
|
// 地图信息
|
|
std::unordered_map<std::string, MapInfoBody> _MapInfo;
|
|
// 地图路径
|
|
std::string _MapPath;
|
|
// 地图文件夹
|
|
std::string _MapDir;
|
|
// 地板画布
|
|
RefPtr<Tile> _Tile = nullptr;
|
|
// 地图宽度
|
|
int _MapLength = 0;
|
|
// 地图高度
|
|
int _MapHeight = 0;
|
|
// 可行区域
|
|
std::vector<SDL_FRect> _MovableArea;
|
|
// 调试模式
|
|
bool _DebugMode = false;
|
|
|
|
public:
|
|
// 图层Map 图层类型 显示对象
|
|
std::unordered_map<std::string, RefPtr<GameMapLayer>> _LayerMap;
|
|
|
|
// 背景层移动速率
|
|
int BackgroundMoveSpeed = 103;
|
|
// 地图Y轴偏移量
|
|
int MapOffsetY = 0;
|
|
public:
|
|
GameMap(/* args */);
|
|
~GameMap();
|
|
|
|
void LoadMap(std::string mapName);
|
|
void InitConfiguration(std::string mapName);
|
|
void InitTile();
|
|
void InitBackgroundAnimation();
|
|
void InitMapAnimation();
|
|
void InitVirtualMovableArea();
|
|
void Enter(Scene *scene);
|
|
void Update(float deltaTime) override;
|
|
void AddObject(RefPtr<BaseObject> object);
|
|
|
|
public:
|
|
// 检查是否可移动
|
|
VecFPos3 CheckIsItMovable(VecFPos3 CurPos, VecFPos3 PosOffset);
|
|
};
|