Complete Cocos Creator port with level bundles, themes, and tooling.
Adds level prefabs, theme assets, audio, extensions, and deployment scripts for the Unity WebGL migration. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
53
tools/unity-level-prefab.md
Normal file
53
tools/unity-level-prefab.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Unity 关卡 Prefab 结构说明(以 Level3 为例)
|
||||
|
||||
## 两套数据源
|
||||
|
||||
| 来源 | 文件 | 内容 |
|
||||
|------|------|------|
|
||||
| 逻辑配置 | `Assets/Scripts/Core/Levels600.cs` | `spawns`(玩家/道具坐标)、`boundary`、`levelPath` |
|
||||
| 地图视觉 | `Assets/Prefabs/Level/Level3.prefab` | `Ground` / `Border` 两层 **Tilemap** |
|
||||
|
||||
运行时 `GameManager.CreateNewLevel`:
|
||||
|
||||
1. Addressables 加载 `levelPath` → 实例化 `Level3` 预制体(含 Grid + Tilemap)
|
||||
2. 再按 `spawns` 实例化 `Player.prefab`、`Prop.prefab` 等到关卡根节点
|
||||
|
||||
**玩家/道具不在 Prefab 里**,只在 `Levels*.cs` 的 `spawns` 中定义。
|
||||
|
||||
## Level3.prefab 层级
|
||||
|
||||
```
|
||||
Level3
|
||||
├── Grid # cellSize (1, 0.5),等距/菱形格
|
||||
├── Border # Tilemap — 墙/障碍 → GridType.Block
|
||||
└── Ground # Tilemap — 可走地块 → GridType.Across / Jump
|
||||
```
|
||||
|
||||
### 第 3 关格子(从 Prefab 解析)
|
||||
|
||||
- **Ground(8 格)**:`(-3,0)…(4,0)` 一字横排,`Baseblock` → 可走 `Across`
|
||||
- **Border(22 格)**:底部一排 + 左右墙 + 顶部墙,围成通道
|
||||
|
||||
与 `Levels600.cs` 中 spawns 一致:
|
||||
|
||||
- Player `(0,0)` North
|
||||
- Prop `(-3,0)`、`(4,0)` 在通道两端
|
||||
|
||||
## Cocos 侧对应
|
||||
|
||||
`tools/export_unity_levels.py --prefab-dir` 会把 Prefab Tilemap 写入:
|
||||
|
||||
- `LevelConfig.ground`: `"x,y" → "Baseblock" | "JumpBlock"`
|
||||
- `LevelConfig.border`: `"x,y" → true`
|
||||
|
||||
`GameManager` 按这些稀疏格子绘制地形并计算 `CalculateGridType`(与 Unity `Border.HasTile` / `Ground.GetTile` 一致)。
|
||||
|
||||
## 重新导出命令
|
||||
|
||||
```bash
|
||||
python3 tools/export_unity_levels.py \
|
||||
--input "/path/to/主站/Assets/Scripts/Core/Levels600.cs" \
|
||||
--output assets/scripts/level/levels-20.generated.ts \
|
||||
--prefab-dir "/path/to/主站/Assets/Prefabs/Level" \
|
||||
--limit 20 --export-const LEVELS_20
|
||||
```
|
||||
Reference in New Issue
Block a user