Files
cocos/README.md
刘宇飞 cba5105908 Initial Cocos Creator port of main-site Unity WebGL game.
Includes core gameplay, 600 exported levels, visual assets, web bridge, and bootstrap scene.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 14:57:46 +08:00

76 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tfrh001 — 主站网格编程游戏Cocos Creator 版)
Unity「主站」移植工程**Cocos Creator 3.8.8** + **Web**API 与 `unityInstance.SendMessage` 兼容。
## 当前进度
| 项 | 状态 |
|----|------|
| 核心玩法 / JS 桥 | ✅ |
| Unity Levels600600 关) | ✅ 已导出 |
| 丝路主题 Sprite | ✅ player/ship/coin/tile |
| 主站 Web 对接模板 | ✅ `web-template/` |
## 快速开始
1. Cocos Creator 3.8.8 打开本目录
2. 新建场景 → 空节点挂 **AppBootstrap** → 存 `assets/scenes/main.scene` → 设为启动场景
3. 播放预览
## 关卡
- **600 关**`assets/scripts/level/levels-600.generated.ts`(由 `tools/export_unity_levels.py` 生成)
- 注册入口:`assets/scripts/level/LevelRegistry.ts`
- 重新导出:
```bash
python3 tools/export_unity_levels.py \
--input "/path/to/Unity/Assets/Scripts/Core/Levels600.cs" \
--output assets/scripts/level/levels-600.generated.ts
# 或
bash tools/export_all.sh "/path/to/Unity项目"
```
## 贴图资源
已复制至 `assets/resources/textures/`(需在编辑器中刷新资源):
- `silu/player_F.png`, `player_B.png`, `ship_F.png`, `ship_B.png`, `Baseblock.png`
- `ui/coin.png`, `ui/bg.png`
加载逻辑:`assets/scripts/visual/VisualAssets.ts`
## 主站 Web 联调
1. **构建发布** → Web Desktop → 得到 `build/web-desktop/`
2. 阅读 [`web-template/主站对接说明.md`](web-template/主站对接说明.md)
3. 使用 [`web-template/main-site.html`](web-template/main-site.html) + [`cocos-bridge.js`](web-template/cocos-bridge.js) 联调
```javascript
// 与 Unity 完全相同
unityInstance.SendMessage("GameController", "SwitchLevel", 21);
unityInstance.SendMessage("Player", "CallMove", 2);
unityInstance.SendMessage("Player", "CallPlayerInfo");
```
## 目录
```
assets/scripts/ 游戏逻辑
assets/resources/ 贴图Sprite
assets/scripts/level/levels-600.generated.ts
web-template/ 主站对接
tools/ 关卡导出脚本
```
## 源项目
`/Users/liuyufei/tfrh/主站文件/主站`
## 后续
- 运行 `tools/export_all.sh` 导出 Levels1000、Levels10000 等
- 将 Unity 动画改为 Cocos Animation / Spine
- 用 Tiled 导出真实地块填充 `LevelConfig.ground`