feat: 实现游戏地图和城镇系统基础架构
新增GameMap和GameTown类实现游戏地图和城镇的核心功能 添加GameWorld作为游戏世界管理器处理场景切换 完善音频系统支持从路径加载音乐和音效 重构PVF资源系统增加路径规范化功能 添加.gitignore排除游戏资源目录
This commit is contained in:
55
Game/include/Actor/GameMap.h
Normal file
55
Game/include/Actor/GameMap.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameDataLoader.h"
|
||||
#include "GameMapLayer.h"
|
||||
#include <frostbite2D/2d/actor.h>
|
||||
#include <frostbite2D/audio/music.h>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace frostbite2D {
|
||||
|
||||
class GameMap : public Actor {
|
||||
public:
|
||||
using MapMoveArea = game::MoveAreaTarget;
|
||||
|
||||
GameMap();
|
||||
~GameMap() override = default;
|
||||
|
||||
bool LoadMap(const std::string& mapName);
|
||||
void Enter();
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
void AddObject(RefPtr<Actor> object);
|
||||
|
||||
Vec3 CheckIsItMovable(const Vec3& curPos, const Vec3& posOffset) const;
|
||||
MapMoveArea CheckIsItMoveArea(const Vec3& curPos) const;
|
||||
const std::vector<MapMoveArea>& GetMoveAreaInfo() const;
|
||||
Rect GetMovablePositionArea(size_t index) const;
|
||||
|
||||
int GetMapLength() const { return mapLength_; }
|
||||
int GetMapHeight() const { return mapHeight_; }
|
||||
|
||||
private:
|
||||
void initLayers();
|
||||
void clearLayerChildren();
|
||||
void InitTile();
|
||||
void InitBackgroundAnimation();
|
||||
void InitMapAnimation();
|
||||
void InitVirtualMovableArea();
|
||||
void InitMoveArea();
|
||||
void updateCamera();
|
||||
void updateLayerPositions(const Vec2& cameraPos);
|
||||
|
||||
game::MapConfig mapConfig_;
|
||||
std::unordered_map<std::string, RefPtr<GameMapLayer>> layerMap_;
|
||||
std::vector<Rect> movableArea_;
|
||||
std::vector<Rect> moveArea_;
|
||||
int mapLength_ = 0;
|
||||
int mapHeight_ = 0;
|
||||
int mapOffsetY_ = 0;
|
||||
bool debugMode_ = false;
|
||||
Vec2 cameraFocus_ = Vec2::Zero();
|
||||
Ptr<Music> currentMusic_;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
Reference in New Issue
Block a user