feat: 添加游戏核心模块,包括地图、角色、场景和世界管理
实现游戏基础架构,包含以下主要功能: - 地图系统:支持地图加载、图层管理和相机控制 - 角色系统:实现角色装备、动画和行为管理 - 场景系统:提供测试场景和世界场景切换 - 世界管理:处理城镇和区域切换逻辑 - 数据加载:添加角色和装备配置加载器 这些改动为游戏开发奠定了基础框架,支持后续功能扩展
This commit is contained in:
45
Game/include/world/GameTown.h
Normal file
45
Game/include/world/GameTown.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "camera/GameCameraController.h"
|
||||
#include "map/GameDataLoader.h"
|
||||
#include "map/GameMap.h"
|
||||
#include <frostbite2D/2d/actor.h>
|
||||
#include <vector>
|
||||
|
||||
namespace frostbite2D {
|
||||
|
||||
class GameTown : public Actor {
|
||||
public:
|
||||
struct MapInfo {
|
||||
int areaId = -1;
|
||||
RefPtr<GameMap> map;
|
||||
std::string type;
|
||||
Vec2 generatePos = Vec2(-1.0f, -1.0f);
|
||||
};
|
||||
|
||||
GameTown();
|
||||
~GameTown() override = default;
|
||||
|
||||
bool Init(int index, const std::string& townPath);
|
||||
void AddCharacter(RefPtr<Actor> actor, int areaIndex = -2);
|
||||
|
||||
int GetCurAreaIndex() const { return curMapIndex_; }
|
||||
RefPtr<GameMap> GetArea(int index) const;
|
||||
const std::vector<MapInfo>& GetAreas() const { return mapList_; }
|
||||
|
||||
void Update(float deltaTime) override;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::string enteringTitle_;
|
||||
std::string enteringCutscene_;
|
||||
int needQuestId_ = -1;
|
||||
int needLevel_ = -1;
|
||||
int sariaRoomId_ = -1;
|
||||
Vec2 sariaRoomPos_ = Vec2(-1.0f, -1.0f);
|
||||
std::vector<MapInfo> mapList_;
|
||||
int curMapIndex_ = -1;
|
||||
GameCameraController cameraController_;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
32
Game/include/world/GameWorld.h
Normal file
32
Game/include/world/GameWorld.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "world/GameTown.h"
|
||||
#include <frostbite2D/scene/scene.h>
|
||||
#include <map>
|
||||
|
||||
namespace frostbite2D {
|
||||
|
||||
class GameWorld : public Scene {
|
||||
public:
|
||||
GameWorld();
|
||||
~GameWorld() override = default;
|
||||
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
|
||||
void AddCharacter(RefPtr<Actor> actor, int townId);
|
||||
void MoveCharacter(RefPtr<Actor> actor, int townId, int area);
|
||||
|
||||
static GameWorld* GetWorld();
|
||||
|
||||
private:
|
||||
bool InitWorld();
|
||||
|
||||
std::map<int, std::string> townPathMap_;
|
||||
std::map<int, RefPtr<GameTown>> townMap_;
|
||||
RefPtr<Actor> mainActor_;
|
||||
int curTown_ = -1;
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
Reference in New Issue
Block a user