# Cocos Dating Game 基于 Cocos Creator 3.x 的恋爱养成游戏引擎。 ## 功能特性 - 🎭 剧情系统 - 支持分支对话和选项 - ❤️ 好感度系统 - 角色好感度等级 - 🎬 立绘切换 - 多种表情和位置 - 💾 存档系统 - 本地存储进度 ## 项目结构 ``` assets/ ├── scripts/ │ ├── StoryManager.ts # 剧情管理器 │ ├── DialogueBox.ts # 对话框组件 │ ├── CharacterView.ts # 立绘组件 │ ├── ChoiceButton.ts # 选项按钮 │ └── AffectionSystem.ts # 好感度系统 ├── resources/ │ ├── backgrounds/ # 背景图 │ ├── characters/ # 角色立绘 │ │ └── {角色ID}/ │ │ ├── normal.png │ │ ├── happy.png │ │ ├── angry.png │ │ └── smile.png │ └── story/ │ └── chapter1.json # 剧情脚本 └── scenes/ └── MainScene.ts # 主场景 ``` ## 快速开始 ### 1. 安装 Cocos Creator 下载并安装 [Cocos Creator 3.x](https://www.cocos.com/creator) ### 2. 创建项目 1. 打开 Cocos Creator 2. 选择 "新建项目" -> "空白项目" 3. 将本项目 assets 目录下的文件复制到新项目中 ### 3. 添加资源 在 `resources` 目录下添加: - 背景图 (1920x1080) - 角色立绘 (按角色ID和表情命名) - 音效/音乐 (可选) ### 4. 运行项目 点击 Cocos Creator 中的 "运行" 按钮 ## 剧情脚本格式 参考 `chapter1.json`: ```json { "title": "第一章", "scenes": [ { "id": "scene_1", "background": "bg.jpg", "characters": [ { "id": "角色ID", "name": "显示名称", "emotion": "normal", "position": "center", "visible": true } ], "dialogue": [ { "speaker": "说话者", "text": "对话内容", "emotion": "happy" } ], "choices": [ { "text": "选项文本", "nextScene": "下一场景ID", "affectionChange": { "角色ID": 5 } } ] } ] } ``` ## API 文档 ### StoryManager ```typescript // 加载章节 StoryManager.instance.loadChapter('chapter1'); // 跳转到指定场景 StoryManager.instance.goToScene('scene_id'); // 重新开始 StoryManager.instance.restart(); ``` ### AffectionSystem ```typescript // 获取好感度 const value = AffectionSystem.instance.getAffection('角色ID'); // 检查等级 const isLover = AffectionSystem.instance.hasReachedLevel( '角色ID', AffectionLevel.LOVER ); // 保存存档 const saveData = AffectionSystem.instance.save(); // 加载存档 AffectionSystem.instance.load(saveData); ``` ## 角色立绘规格 | 位置 | 尺寸 | |------|------| | left/right | 400x600 px | | center | 500x700 px | 表情文件命名:`{emotion}.png` 例如:`normal.png`, `happy.png`, `angry.png`, `sad.png`, `surprised.png`, `smile.png` ## 许可证 MIT License ## 贡献 欢迎提交 Issue 和 Pull Request!