Compare commits
39 Commits
feature/lo
...
d49983079a
| Author | SHA1 | Date | |
|---|---|---|---|
| d49983079a | |||
| 51e79c6c6d | |||
| 0edd1c740b | |||
| a85a7b4d0e | |||
| 51d2ad1629 | |||
| 6f545b04e9 | |||
| 1ff677b3b2 | |||
| 2998fd2d11 | |||
| 60edcc9868 | |||
| d25d8d4dd3 | |||
| 190b6c9a66 | |||
| 899bc5d5d0 | |||
| e657cfce0e | |||
|
|
b9182bbc2e | ||
|
|
642a99970c | ||
|
|
0b533189ec | ||
| b1f3c0feff | |||
| 021c8623f8 | |||
| a1b867dfd7 | |||
| d17c766246 | |||
| 92c4eaed07 | |||
| abd683c766 | |||
| a05bac6f05 | |||
| 77af0bda39 | |||
| 8980e3d558 | |||
| 1294529d13 | |||
| 0935c5fd76 | |||
| 405710bdde | |||
| 7413574672 | |||
| c0f5d6a537 | |||
| 0b6b1c2040 | |||
| 8d071cb2ed | |||
| 370cffbdd8 | |||
| 5b67771bbc | |||
| 73478c0500 | |||
| 15548ebb52 | |||
| 47cfc14f68 | |||
| c6bcca4e7f | |||
| f11479f2cc |
55
.gitignore
vendored
@@ -1,3 +1,58 @@
|
|||||||
# Godot 4+ specific ignores
|
# Godot 4+ specific ignores
|
||||||
.godot/
|
.godot/
|
||||||
/android/
|
/android/
|
||||||
|
|
||||||
|
# Python cache files
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
.Python
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# IDE and editor files
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS generated files
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Godot executable files (should not be in version control)
|
||||||
|
Godot/
|
||||||
|
*.exe
|
||||||
|
*.app
|
||||||
|
*.dmg
|
||||||
|
|
||||||
|
# Logs and temporary files
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
|
||||||
|
# Build outputs
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
|
||||||
|
# Environment files
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Test coverage reports
|
||||||
|
coverage/
|
||||||
|
*.coverage
|
||||||
|
.nyc_output/
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
vendor/
|
||||||
|
|||||||
29
Config/game_config.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"game": {
|
||||||
|
"name": "whaleTown",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"debug_mode": true
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"api_base_url": "https://whaletownend.xinghangee.icu",
|
||||||
|
"timeout": 30,
|
||||||
|
"retry_count": 3
|
||||||
|
},
|
||||||
|
"ui": {
|
||||||
|
"default_font_size": 14,
|
||||||
|
"toast_duration": 2.0,
|
||||||
|
"transition_duration": 0.3
|
||||||
|
},
|
||||||
|
"gameplay": {
|
||||||
|
"auto_save_interval": 300,
|
||||||
|
"max_inventory_slots": 50,
|
||||||
|
"default_player_stats": {
|
||||||
|
"level": 1,
|
||||||
|
"coins": 100,
|
||||||
|
"exp": 0,
|
||||||
|
"max_exp": 100,
|
||||||
|
"energy": 100,
|
||||||
|
"max_energy": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Config/zh_CN.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"ui": {
|
||||||
|
"login": "登录",
|
||||||
|
"register": "注册",
|
||||||
|
"username": "用户名",
|
||||||
|
"password": "密码",
|
||||||
|
"email": "邮箱",
|
||||||
|
"confirm_password": "确认密码",
|
||||||
|
"verification_code": "验证码",
|
||||||
|
"send_code": "发送验证码",
|
||||||
|
"forgot_password": "忘记密码",
|
||||||
|
"enter_town": "进入小镇",
|
||||||
|
"logout": "退出登录"
|
||||||
|
},
|
||||||
|
"messages": {
|
||||||
|
"login_success": "登录成功!正在进入鲸鱼镇...",
|
||||||
|
"register_success": "注册成功!欢迎加入鲸鱼镇",
|
||||||
|
"network_error": "网络连接失败,请检查网络连接",
|
||||||
|
"invalid_username": "用户名只能包含字母、数字和下划线",
|
||||||
|
"invalid_email": "请输入有效的邮箱地址",
|
||||||
|
"password_too_short": "密码长度至少8位",
|
||||||
|
"password_mismatch": "两次输入的密码不一致",
|
||||||
|
"verification_code_sent": "验证码已发送到您的邮箱,请查收"
|
||||||
|
},
|
||||||
|
"game": {
|
||||||
|
"level": "等级",
|
||||||
|
"coins": "金币",
|
||||||
|
"experience": "经验",
|
||||||
|
"energy": "体力",
|
||||||
|
"explore": "探索小镇",
|
||||||
|
"inventory": "背包",
|
||||||
|
"shop": "商店",
|
||||||
|
"friends": "好友",
|
||||||
|
"settings": "设置"
|
||||||
|
}
|
||||||
|
}
|
||||||
235
MIGRATION_COMPLETE.md
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
# ✅ 项目结构重构完成报告
|
||||||
|
|
||||||
|
## 📅 完成时间
|
||||||
|
2025-12-31
|
||||||
|
|
||||||
|
## 🎉 重构成功
|
||||||
|
|
||||||
|
项目已成功从混乱的文件结构重构为清晰、模块化的架构!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 最终结构总览
|
||||||
|
|
||||||
|
```
|
||||||
|
whale-town-front/
|
||||||
|
├── _Core/ ✅ [框架层] 全局单例和系统
|
||||||
|
├── Scenes/ ✅ [玩法层] 游戏世界实体
|
||||||
|
├── UI/ ✅ [界面层] 所有UI界面
|
||||||
|
├── Assets/ ✅ [资源层] 美术资源
|
||||||
|
├── Config/ ✅ [配置层] 静态数据
|
||||||
|
├── Utils/ ✅ [工具层] 工具类
|
||||||
|
├── Tests/ ✅ [测试层] 测试脚本
|
||||||
|
└── docs/ 📄 项目文档
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ 已完成的迁移
|
||||||
|
|
||||||
|
### 1️⃣ 框架层 (_Core/)
|
||||||
|
- ✅ `GameManager.gd` → `_Core/managers/`
|
||||||
|
- ✅ `SceneManager.gd` → `_Core/managers/` (已更新路径)
|
||||||
|
- ✅ `NetworkManager.gd` → `_Core/managers/`
|
||||||
|
- ✅ `ResponseHandler.gd` → `_Core/managers/`
|
||||||
|
- ✅ `EventSystem.gd` → `_Core/systems/`
|
||||||
|
|
||||||
|
### 2️⃣ 场景层 (Scenes/)
|
||||||
|
- ✅ `scenes/main_scene.tscn` → `Scenes/Maps/main_scene.tscn`
|
||||||
|
- ✅ `scripts/scenes/MainScene.gd` → `Scenes/Maps/MainScene.gd`
|
||||||
|
- ✅ `scenes/prefabs/` → `Scenes/Components/`
|
||||||
|
|
||||||
|
### 3️⃣ 界面层 (UI/)
|
||||||
|
- ✅ `scenes/auth_scene.tscn` → `UI/Windows/LoginWindow.tscn`
|
||||||
|
- ✅ `scripts/scenes/AuthScene.gd` → `UI/Windows/AuthScene.gd`
|
||||||
|
- ✅ `assets/ui/chinese_theme.tres` → `UI/Theme/MainTheme.tres`
|
||||||
|
- ✅ `assets/fonts/` → `UI/Theme/Fonts/`
|
||||||
|
|
||||||
|
### 4️⃣ 配置层 (Config/)
|
||||||
|
- ✅ `data/configs/game_config.json` → `Config/game_config.json`
|
||||||
|
- ✅ `data/localization/zh_CN.json` → `Config/zh_CN.json`
|
||||||
|
|
||||||
|
### 5️⃣ 工具层 (Utils/)
|
||||||
|
- ✅ `core/utils/StringUtils.gd` → `Utils/StringUtils.gd`
|
||||||
|
|
||||||
|
### 6️⃣ 资源层 (Assets/)
|
||||||
|
- ✅ `assets/sprites/` → `Assets/Sprites/`
|
||||||
|
- ✅ `assets/audio/` → `Assets/Audio/`
|
||||||
|
- ✅ 其他资源文件保留在 `assets/`(待后续整理)
|
||||||
|
|
||||||
|
### 7️⃣ 构建脚本
|
||||||
|
- ✅ `scripts/build_web.sh` → `./build_web.sh`
|
||||||
|
- ✅ `scripts/serve_web.sh` → `./serve_web.sh`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🗑️ 已删除的旧目录
|
||||||
|
|
||||||
|
- ❌ `core/` - 已迁移到 `_Core/`
|
||||||
|
- ❌ `module/` - 空目录,未使用
|
||||||
|
- ❌ `scripts/` - 脚本已内联到场景目录
|
||||||
|
- ❌ `scenes/` - 已迁移到 `Scenes/` 和 `UI/`
|
||||||
|
- ❌ `data/` - 配置已移至 `Config/`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 已更新的配置
|
||||||
|
|
||||||
|
### project.godot
|
||||||
|
```ini
|
||||||
|
✅ run/main_scene="res://Scenes/Maps/main_scene.tscn"
|
||||||
|
✅ GameManager="*res://_Core/managers/GameManager.gd"
|
||||||
|
✅ SceneManager="*res://_Core/managers/SceneManager.gd"
|
||||||
|
✅ EventSystem="*res://_Core/systems/EventSystem.gd"
|
||||||
|
✅ NetworkManager="*res://_Core/managers/NetworkManager.gd"
|
||||||
|
✅ ResponseHandler="*res://_Core/managers/ResponseHandler.gd"
|
||||||
|
```
|
||||||
|
|
||||||
|
### SceneManager.gd
|
||||||
|
```gdscript
|
||||||
|
✅ "main": "res://Scenes/Maps/main_scene.tscn"
|
||||||
|
✅ "auth": "res://UI/Windows/LoginWindow.tscn"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 测试文件
|
||||||
|
```gdscript
|
||||||
|
✅ tests/auth/enhanced_toast_test.gd - 已更新脚本路径
|
||||||
|
✅ tests/auth/auth_ui_test.tscn - 已更新场景路径
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 创建的文档
|
||||||
|
|
||||||
|
1. **REFACTORING.md** - 详细的重构文档
|
||||||
|
- 迁移映射表
|
||||||
|
- 设计原则
|
||||||
|
- 注意事项
|
||||||
|
- 后续建议
|
||||||
|
|
||||||
|
2. **STRUCTURE_COMPARISON.md** - 结构对比分析
|
||||||
|
- 旧结构问题分析
|
||||||
|
- 新结构优势说明
|
||||||
|
- 对比表格
|
||||||
|
- 团队协作改进
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎯 关键改进
|
||||||
|
|
||||||
|
### 清晰的分层
|
||||||
|
- **_Core**: 框架代码,全局系统
|
||||||
|
- **Scenes**: 游戏世界,地图和实体
|
||||||
|
- **UI**: 所有界面,HUD和弹窗
|
||||||
|
- **Config**: 静态数据,策划可编辑
|
||||||
|
- **Utils**: 通用工具函数库
|
||||||
|
|
||||||
|
### 组件化设计
|
||||||
|
```gdscript
|
||||||
|
Scenes/Components/ // 可复用组件
|
||||||
|
├── characters/ // 角色预制体
|
||||||
|
├── effects/ // 特效预制体
|
||||||
|
├── items/ // 物品预制体
|
||||||
|
└── ui/ // UI预制体
|
||||||
|
```
|
||||||
|
|
||||||
|
### 场景内聚
|
||||||
|
- 每个 `.tscn` 配套一个 `.gd`
|
||||||
|
- 脚本紧邻场景文件
|
||||||
|
- 符合 Godot 原生习惯
|
||||||
|
|
||||||
|
### UI 独立化
|
||||||
|
```
|
||||||
|
UI/
|
||||||
|
├── Windows/ // 模态窗口(登录、设置)
|
||||||
|
├── HUD/ // 常驻界面(聊天框)
|
||||||
|
├── Dialog/ // 对话系统
|
||||||
|
└── Theme/ // 全局样式
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚠️ 后续步骤
|
||||||
|
|
||||||
|
### 必做事项
|
||||||
|
- [ ] 在 Godot 编辑器中打开项目,让编辑器重新索引文件
|
||||||
|
- [ ] 测试主场景加载: `Scenes/Maps/main_scene.tscn`
|
||||||
|
- [ ] 验证登录窗口: `UI/Windows/LoginWindow.tscn`
|
||||||
|
- [ ] 测试所有自动加载脚本
|
||||||
|
- [ ] 运行完整测试套件
|
||||||
|
|
||||||
|
### 建议优化
|
||||||
|
- [ ] 补充 `Scenes/Components/` 下的可复用组件
|
||||||
|
- [ ] 完善 `UI/HUD/` 和 `UI/Dialog/`
|
||||||
|
- [ ] 添加 `Scenes/Entities/Player/` 玩家实体
|
||||||
|
- [ ] 将硬编码数值移至 `Config/`
|
||||||
|
|
||||||
|
### 代码审查
|
||||||
|
- [ ] 检查是否还有硬编码的旧路径
|
||||||
|
- [ ] 验证所有 `.import` 文件正常
|
||||||
|
- [ ] 确认网络连接功能正常
|
||||||
|
- [ ] 验证 UI 主题显示正确
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎓 团队协作指南
|
||||||
|
|
||||||
|
### 工作目录划分
|
||||||
|
```
|
||||||
|
🎨 美术组 → Assets/Sprites/, Assets/Audio/
|
||||||
|
📋 策划组 → Config/
|
||||||
|
💻 前端程序 → UI/, Scenes/Entities/
|
||||||
|
⚙️ 后端程序 → _Core/, Utils/
|
||||||
|
🧪 测试组 → Tests/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Git 提交建议
|
||||||
|
```bash
|
||||||
|
# 按目录分类提交
|
||||||
|
git add _Core/
|
||||||
|
git commit -m "refactor: 迁移核心框架代码到 _Core/"
|
||||||
|
|
||||||
|
git add Scenes/
|
||||||
|
git commit -m "refactor: 重组场景文件到 Scenes/"
|
||||||
|
|
||||||
|
git add UI/
|
||||||
|
git commit -m "refactor: 独立 UI 界面到 UI/"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📈 预期收益
|
||||||
|
|
||||||
|
### 可维护性提升
|
||||||
|
- 🟢 目录职责清晰,降低认知负担
|
||||||
|
- 🟢 新人快速定位文件
|
||||||
|
- 🟢 减少代码冲突
|
||||||
|
|
||||||
|
### 开发效率提升
|
||||||
|
- 🟢 组件复用更容易
|
||||||
|
- 🟢 团队协作更流畅
|
||||||
|
- 🟢 代码审查更高效
|
||||||
|
|
||||||
|
### 符合最佳实践
|
||||||
|
- ✅ Godot 官方推荐结构
|
||||||
|
- ✅ 场景内聚原则
|
||||||
|
- ✅ 组件化设计思想
|
||||||
|
- ✅ 配置与代码分离
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎉 总结
|
||||||
|
|
||||||
|
**重构完成!** 项目现在拥有:
|
||||||
|
- ✅ 清晰的 6 层架构
|
||||||
|
- ✅ 符合 Godot 最佳实践
|
||||||
|
- ✅ 易于维护和扩展
|
||||||
|
- ✅ 团队协作友好
|
||||||
|
|
||||||
|
感谢您的耐心!如有问题,请查看详细文档:
|
||||||
|
- [REFACTORING.md](./REFACTORING.md) - 重构详情
|
||||||
|
- [STRUCTURE_COMPARISON.md](./STRUCTURE_COMPARISON.md) - 结构对比
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**下一步:在 Godot 编辑器中打开项目并测试!** 🚀
|
||||||
428
README.md
@@ -1,101 +1,363 @@
|
|||||||
# whaleTown
|
# 🐋 WhaleTown - 现代化像素游戏
|
||||||
|
|
||||||
一个使用 Godot 4.5 引擎开发的游戏项目。
|
> 一个基于 Godot 4.5 引擎开发的企业级 2D 像素风游戏,采用模块化架构设计,集成完整的用户认证系统和游戏核心功能。
|
||||||
|
|
||||||
## 项目信息
|
[](https://godotengine.org/)
|
||||||
|
[](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/index.html)
|
||||||
|
[](./docs/)
|
||||||
|
[](https://godotengine.org/download)
|
||||||
|
|
||||||
- **引擎版本**: Godot 4.5
|
## 🎯 项目简介
|
||||||
- **渲染器**: Forward Plus
|
|
||||||
- **项目类型**: 2D 游戏
|
|
||||||
|
|
||||||
## 项目结构
|
WhaleTown 是一个功能完整的现代化像素游戏,具有以下特色:
|
||||||
|
|
||||||
```
|
- 🏗️ **企业级架构** - 模块化设计,高度解耦,易于扩展
|
||||||
whaleTown/
|
- 🔐 **完整认证系统** - 登录、注册、邮箱验证、密码管理
|
||||||
├── addons/ # Godot 插件目录
|
- 🎮 **丰富游戏功能** - 角色系统、场景管理、事件通信
|
||||||
├── assets/ # 游戏资源文件(图片、音频等)
|
- 🌐 **网络通信** - RESTful API集成,支持实时数据交互
|
||||||
├── data/ # 游戏数据文件(配置、关卡数据等)
|
- 📚 **企业级文档** - 18个文档,覆盖开发全流程
|
||||||
├── docs/ # 项目文档
|
- 🧪 **完整测试体系** - API测试、UI测试、性能测试
|
||||||
├── scenes/ # 游戏场景文件
|
- 🚀 **一键部署** - 支持Web、桌面多平台发布
|
||||||
│ └── main_scene.tscn # 主场景
|
|
||||||
├── scripts/ # GDScript 脚本文件
|
|
||||||
├── tests/ # 测试文件
|
|
||||||
├── icon.svg # 项目图标
|
|
||||||
└── project.godot # Godot 项目配置文件
|
|
||||||
```
|
|
||||||
|
|
||||||
## 开始使用
|
---
|
||||||
|
|
||||||
### 前置要求
|
## 🚀 5分钟快速体验
|
||||||
|
|
||||||
- [Godot Engine 4.5](https://godotengine.org/download) 或更高版本
|
### 📋 准备工作
|
||||||
|
|
||||||
### 运行项目
|
**你需要安装:**
|
||||||
|
- [Godot Engine 4.5+](https://godotengine.org/download) - 游戏引擎
|
||||||
|
- [Git](https://git-scm.com/) - 版本控制工具
|
||||||
|
|
||||||
1. 克隆或下载此项目
|
### 🛠️ 启动项目
|
||||||
2. 使用 Godot 编辑器打开项目
|
|
||||||
3. 在编辑器中点击"运行"按钮或按 F5 键启动游戏
|
|
||||||
|
|
||||||
### 开发指南
|
|
||||||
|
|
||||||
- **场景文件**: 所有场景文件存放在 `scenes/` 目录
|
|
||||||
- **脚本文件**: 所有 GDScript 脚本存放在 `scripts/` 目录
|
|
||||||
- **资源文件**: 图片、音频等资源存放在 `assets/` 目录
|
|
||||||
- **游戏数据**: 配置文件、关卡数据等存放在 `data/` 目录
|
|
||||||
|
|
||||||
### 命名规范
|
|
||||||
|
|
||||||
本项目遵循统一的命名规范以保持代码一致性:
|
|
||||||
|
|
||||||
**核心规则**:
|
|
||||||
|
|
||||||
- **场景文件**:`下划线_scene.tscn` 或 `下划线_prefab.tscn`
|
|
||||||
- 示例:`main_scene.tscn`、`player_prefab.tscn`
|
|
||||||
- **脚本文件**:`PascalCase.gd`(大驼峰)
|
|
||||||
- 示例:`PlayerController.gd`、`UI_MainMenu.gd`
|
|
||||||
- **节点名称**:`camelCase`(小驼峰)
|
|
||||||
- 示例:`playerHpBar`、`startButton`
|
|
||||||
- **变量/函数**:`camelCase`(小驼峰)
|
|
||||||
- 示例:`var moveSpeed`、`func getPlayerPos()`
|
|
||||||
- **常量**:`UPPER_CASE`(全大写 + 下划线)
|
|
||||||
- 示例:`const MAX_HEALTH = 100`
|
|
||||||
- **资源文件**:`lower_case`(小写 + 下划线)
|
|
||||||
- 示例:`bg_main_menu.png`、`sound_jump.wav`
|
|
||||||
|
|
||||||
📖 查看完整的 [命名规范文档](docs/naming_convention.md)
|
|
||||||
|
|
||||||
### Git 提交规范
|
|
||||||
|
|
||||||
本项目遵循统一的 Git 提交信息格式:`<类型>:<描述>`
|
|
||||||
|
|
||||||
**常用提交类型**:
|
|
||||||
|
|
||||||
- `init`:项目初始化
|
|
||||||
- `feat`:新增功能
|
|
||||||
- `fix`:修复 Bug
|
|
||||||
- `docs`:文档更新
|
|
||||||
- `scene`:场景文件相关
|
|
||||||
- `asset`:资源文件相关
|
|
||||||
- `ui`:UI 界面相关
|
|
||||||
- `gameplay`:游戏玩法相关
|
|
||||||
- `refactor`:代码重构
|
|
||||||
- `perf`:性能优化
|
|
||||||
|
|
||||||
**提交示例**:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git commit -m "init:项目初始化,搭建Godot文件结构"
|
# 1️⃣ 获取项目
|
||||||
git commit -m "feat:实现玩家角色的移动和跳跃"
|
git clone <repository-url>
|
||||||
git commit -m "fix:修复敌人穿墙的碰撞问题"
|
cd whale-town
|
||||||
git commit -m "scene:创建战斗场景并配置相机"
|
|
||||||
|
# 2️⃣ 打开项目
|
||||||
|
# 双击 project.godot 文件,或在Godot编辑器中选择"导入项目"
|
||||||
|
|
||||||
|
# 3️⃣ 运行游戏
|
||||||
|
# 在Godot编辑器中按 F5 或点击"运行项目"按钮
|
||||||
```
|
```
|
||||||
|
|
||||||
📖 查看完整的 [Git 提交规范文档](docs/git_commit_guide.md)
|
🎉 **成功!** 你应该看到游戏的认证界面
|
||||||
|
|
||||||
## 贡献
|
### 🎮 体验功能
|
||||||
|
|
||||||
欢迎提交 Issue 和 Pull Request!
|
1. **注册新用户** - 体验完整的邮箱验证流程
|
||||||
|
2. **登录系统** - 尝试用户名/邮箱登录
|
||||||
|
3. **游戏界面** - 探索主游戏场景
|
||||||
|
|
||||||
## 许可证
|
### 🧪 测试API(可选)
|
||||||
|
|
||||||
[在此添加许可证信息]
|
```bash
|
||||||
|
# 安装Python依赖
|
||||||
|
pip install requests
|
||||||
|
|
||||||
|
# 快速API测试
|
||||||
|
python tests/api/quick_test.py
|
||||||
|
|
||||||
|
# 完整功能测试
|
||||||
|
python tests/api/api_client_test.py
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 新手开发指南
|
||||||
|
|
||||||
|
### 🎯 第一步:了解项目
|
||||||
|
|
||||||
|
**⚠️ 重要:开始开发前必读**
|
||||||
|
|
||||||
|
1. **[📖 项目入门总览](docs/01-项目入门/README.md)** - 5分钟了解项目
|
||||||
|
2. **[🏗️ 项目结构说明](docs/01-项目入门/项目结构说明.md)** - 理解架构设计
|
||||||
|
3. **[⚙️ 项目设置指南](docs/01-项目入门/项目设置指南.md)** - 配置开发环境
|
||||||
|
|
||||||
|
### 🎯 第二步:学习规范
|
||||||
|
|
||||||
|
**代码质量保证**
|
||||||
|
|
||||||
|
1. **[📝 命名规范](docs/02-开发规范/命名规范.md)** - 统一命名标准
|
||||||
|
2. **[🏛️ 架构与通信规范](docs/02-开发规范/架构与通信规范.md)** - 组件通信方式
|
||||||
|
3. **[💬 代码注释规范](docs/02-开发规范/代码注释规范.md)** - 注释标准
|
||||||
|
4. **[🔄 Git提交规范](docs/02-开发规范/Git提交规范.md)** - 版本控制规范
|
||||||
|
|
||||||
|
### 🎯 第三步:开始开发
|
||||||
|
|
||||||
|
**技术实现指导**
|
||||||
|
|
||||||
|
1. **[🔧 实现细节规范](docs/03-技术实现/实现细节规范.md)** - 游戏对象实现
|
||||||
|
2. **[🌐 API接口文档](docs/03-技术实现/API接口文档.md)** - 后端接口使用
|
||||||
|
3. **[🧪 测试指南](docs/03-技术实现/测试指南.md)** - 测试方法和工具
|
||||||
|
|
||||||
|
### 🎯 第四步:高级开发
|
||||||
|
|
||||||
|
**进阶技能**
|
||||||
|
|
||||||
|
1. **[🚀 性能优化指南](docs/04-高级开发/性能优化指南.md)** - 性能调优
|
||||||
|
2. **[🎬 场景设计规范](docs/04-高级开发/场景设计规范.md)** - 场景架构
|
||||||
|
3. **[🧩 模块开发指南](docs/04-高级开发/模块开发指南.md)** - 模块化开发
|
||||||
|
|
||||||
|
### 🎯 第五步:项目发布
|
||||||
|
|
||||||
|
**部署和运维**
|
||||||
|
|
||||||
|
1. **[🌐 Web部署指南](docs/05-部署运维/Web部署指南.md)** - 完整部署流程
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🏗️ 项目架构一览
|
||||||
|
|
||||||
|
### 📁 目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
WhaleTown/ # 🐋 项目根目录
|
||||||
|
├── 📚 docs/ # 📖 完整文档系统(18个文档)
|
||||||
|
│ ├── 01-项目入门/ # 👋 新人必读
|
||||||
|
│ ├── 02-开发规范/ # 📋 编码标准
|
||||||
|
│ ├── 03-技术实现/ # 🔧 开发指导
|
||||||
|
│ ├── 04-高级开发/ # 🚀 进阶技巧
|
||||||
|
│ ├── 05-部署运维/ # 🌐 发布部署
|
||||||
|
│ └── 06-功能模块/ # 🎮 功能文档
|
||||||
|
├── 🎬 scenes/ # 🎭 游戏场景
|
||||||
|
│ ├── Maps/ # 🗺️ 地图场景
|
||||||
|
│ └── Components/ # 🧩 组件预制体
|
||||||
|
├── 🔧 _Core/ # ⚙️ 核心系统
|
||||||
|
│ ├── managers/ # 🎯 全局管理器
|
||||||
|
│ ├── systems/ # 🔄 系统组件
|
||||||
|
│ ├── EventNames.gd # 📝 事件名称定义
|
||||||
|
│ └── ProjectPaths.gd # 📂 路径统一管理
|
||||||
|
├── 🎨 UI/ # 🖼️ 用户界面
|
||||||
|
│ └── Windows/ # 🪟 窗口界面
|
||||||
|
├── 🔨 Utils/ # 🔨 工具类
|
||||||
|
├── 🎮 module/ # 🧩 功能模块
|
||||||
|
├── 🎨 assets/ # 🖼️ 游戏资源
|
||||||
|
├── ⚙️ Config/ # 📋 配置文件
|
||||||
|
├── 🧪 tests/ # 🔬 测试文件
|
||||||
|
└── 🌐 web_assets/ # 🌍 Web部署资源
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🔧 核心组件
|
||||||
|
|
||||||
|
| 组件 | 作用 | 文档链接 |
|
||||||
|
|------|------|----------|
|
||||||
|
| **EventSystem** | 全局事件通信 | [架构规范](docs/02-开发规范/架构与通信规范.md) |
|
||||||
|
| **GameManager** | 游戏状态管理 | [实现细节](docs/03-技术实现/实现细节规范.md) |
|
||||||
|
| **SceneManager** | 场景切换管理 | [场景设计](docs/04-高级开发/场景设计规范.md) |
|
||||||
|
| **NetworkManager** | 网络请求管理 | [网络管理器](docs/03-技术实现/网络管理器设置.md) |
|
||||||
|
| **ProjectPaths** | 路径统一管理 | [项目结构](docs/01-项目入门/项目结构说明.md) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎮 核心功能
|
||||||
|
|
||||||
|
### 🔐 用户认证系统
|
||||||
|
|
||||||
|
**完整的用户管理功能**
|
||||||
|
- ✅ 用户注册(用户名+邮箱验证)
|
||||||
|
- ✅ 多方式登录(用户名/邮箱/验证码)
|
||||||
|
- ✅ 密码管理(修改/重置)
|
||||||
|
- ✅ 表单验证(实时验证+友好提示)
|
||||||
|
- ✅ 错误处理(网络异常+业务错误)
|
||||||
|
|
||||||
|
**技术特色**
|
||||||
|
- 📱 响应式UI设计
|
||||||
|
- 🔄 实时表单验证
|
||||||
|
- ⏰ 验证码冷却机制
|
||||||
|
- 🎨 流畅动画效果
|
||||||
|
|
||||||
|
### 🎮 游戏核心系统
|
||||||
|
|
||||||
|
**模块化游戏架构**
|
||||||
|
- 🎭 场景管理系统
|
||||||
|
- 🔄 事件通信系统
|
||||||
|
- 🎯 状态管理系统
|
||||||
|
- 🌐 网络通信系统
|
||||||
|
|
||||||
|
**开发友好特性**
|
||||||
|
- 🧩 高度模块化
|
||||||
|
- 📝 完整文档覆盖
|
||||||
|
- 🧪 测试用例齐全
|
||||||
|
- 🔧 开发工具完善
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧪 测试系统
|
||||||
|
|
||||||
|
### 🔬 测试类型
|
||||||
|
|
||||||
|
| 测试类型 | 工具 | 覆盖范围 | 文档 |
|
||||||
|
|----------|------|----------|------|
|
||||||
|
| **API测试** | Python脚本 | 17个接口全覆盖 | [测试指南](docs/03-技术实现/测试指南.md) |
|
||||||
|
| **UI测试** | Godot场景 | 认证流程完整测试 | [认证测试](docs/06-功能模块/auth/认证测试指南.md) |
|
||||||
|
| **单元测试** | GUT框架 | 核心组件测试 | [测试指南](docs/03-技术实现/测试指南.md) |
|
||||||
|
|
||||||
|
### 🚀 快速测试
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 🔌 API接口测试(30秒)
|
||||||
|
python tests/api/quick_test.py
|
||||||
|
|
||||||
|
# 🔍 完整功能测试(2-3分钟)
|
||||||
|
python tests/api/api_client_test.py
|
||||||
|
|
||||||
|
# 🎮 UI交互测试(在Godot中运行)
|
||||||
|
# 打开 tests/auth/auth_ui_test.tscn 场景
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 部署发布
|
||||||
|
|
||||||
|
### 🖥️ 桌面版本
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Windows
|
||||||
|
godot --export "Windows Desktop" build/WhaleTown.exe
|
||||||
|
|
||||||
|
# Linux
|
||||||
|
godot --export "Linux/X11" build/WhaleTown.x86_64
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
godot --export "macOS" build/WhaleTown.app
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🌐 Web版本
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用自动化脚本
|
||||||
|
scripts/build_web.bat # Windows
|
||||||
|
scripts/build_web.sh # Linux/macOS
|
||||||
|
|
||||||
|
# 本地测试
|
||||||
|
scripts/serve_web.bat # 启动本地服务器
|
||||||
|
```
|
||||||
|
|
||||||
|
**详细部署流程**: [Web部署指南](docs/05-部署运维/Web部署指南.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 项目统计
|
||||||
|
|
||||||
|
### 📚 文档系统
|
||||||
|
|
||||||
|
| 类别 | 文档数 | 完成度 |
|
||||||
|
|------|--------|--------|
|
||||||
|
| 项目入门 | 3 | 100% |
|
||||||
|
| 开发规范 | 5 | 100% |
|
||||||
|
| 技术实现 | 4 | 100% |
|
||||||
|
| 高级开发 | 3 | 100% |
|
||||||
|
| 部署运维 | 1 | 100% |
|
||||||
|
| 功能模块 | 2 | 100% |
|
||||||
|
| **总计** | **18** | **100%** |
|
||||||
|
|
||||||
|
### 🧪 测试覆盖
|
||||||
|
|
||||||
|
- **API接口**: 17个接口 ✅
|
||||||
|
- **认证流程**: 完整测试 ✅
|
||||||
|
- **错误处理**: 边界测试 ✅
|
||||||
|
- **性能监控**: 帧率/内存 ✅
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🤝 参与贡献
|
||||||
|
|
||||||
|
### 🌟 贡献方式
|
||||||
|
|
||||||
|
1. **🐛 Bug修复** - 发现并修复问题
|
||||||
|
2. **✨ 新功能** - 添加有价值的功能
|
||||||
|
3. **📚 文档改进** - 完善项目文档
|
||||||
|
4. **🧪 测试用例** - 提高代码覆盖率
|
||||||
|
5. **🎨 UI/UX改进** - 提升用户体验
|
||||||
|
|
||||||
|
### 📋 贡献流程
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1️⃣ Fork项目到你的账户
|
||||||
|
|
||||||
|
# 2️⃣ 克隆到本地
|
||||||
|
git clone <your-fork-url>
|
||||||
|
cd whale-town
|
||||||
|
|
||||||
|
# 3️⃣ 创建功能分支
|
||||||
|
git checkout -b feature/your-feature
|
||||||
|
|
||||||
|
# 4️⃣ 开发功能(遵循项目规范)
|
||||||
|
# 参考: docs/02-开发规范/
|
||||||
|
|
||||||
|
# 5️⃣ 添加测试用例
|
||||||
|
# 参考: docs/03-技术实现/测试指南.md
|
||||||
|
|
||||||
|
# 6️⃣ 提交代码
|
||||||
|
git commit -m "feat:添加新功能"
|
||||||
|
# 参考: docs/02-开发规范/Git提交规范.md
|
||||||
|
|
||||||
|
# 7️⃣ 推送分支
|
||||||
|
git push origin feature/your-feature
|
||||||
|
|
||||||
|
# 8️⃣ 创建Pull Request
|
||||||
|
```
|
||||||
|
|
||||||
|
### 📖 开发规范
|
||||||
|
|
||||||
|
**必读文档**:
|
||||||
|
- [命名规范](docs/02-开发规范/命名规范.md) - 代码命名标准
|
||||||
|
- [Git提交规范](docs/02-开发规范/Git提交规范.md) - 提交信息格式
|
||||||
|
- [代码注释规范](docs/02-开发规范/代码注释规范.md) - 注释标准
|
||||||
|
|
||||||
|
### 🙏 贡献者致谢
|
||||||
|
|
||||||
|
感谢所有为 WhaleTown 项目做出贡献的开发者们!详细的贡献者信息和统计请查看:
|
||||||
|
|
||||||
|
**[📖 贡献者详细信息](docs/CONTRIBUTORS.md)**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📞 获取帮助
|
||||||
|
|
||||||
|
### 🔍 问题解决
|
||||||
|
|
||||||
|
| 问题类型 | 解决方案 |
|
||||||
|
|----------|----------|
|
||||||
|
| **🤔 不知道从哪开始** | [项目入门总览](docs/01-项目入门/README.md) |
|
||||||
|
| **🏗️ 不理解项目架构** | [项目结构说明](docs/01-项目入门/项目结构说明.md) |
|
||||||
|
| **🔧 开发环境问题** | [项目设置指南](docs/01-项目入门/项目设置指南.md) |
|
||||||
|
| **📝 不知道怎么命名** | [命名规范](docs/02-开发规范/命名规范.md) |
|
||||||
|
| **🔄 组件通信问题** | [架构与通信规范](docs/02-开发规范/架构与通信规范.md) |
|
||||||
|
| **🌐 API调用问题** | [API接口文档](docs/03-技术实现/API接口文档.md) |
|
||||||
|
| **🧪 测试相关问题** | [测试指南](docs/03-技术实现/测试指南.md) |
|
||||||
|
| **🚀 部署发布问题** | [Web部署指南](docs/05-部署运维/Web部署指南.md) |
|
||||||
|
|
||||||
|
### 📚 文档导航
|
||||||
|
|
||||||
|
- **[📖 完整文档中心](docs/README.md)** - 所有文档的导航页面
|
||||||
|
- **[📋 文档更新日志](docs/CHANGELOG.md)** - 文档版本变更记录
|
||||||
|
|
||||||
|
### 💬 联系方式
|
||||||
|
|
||||||
|
- **项目地址**: [Gitea Repository](https://gitea.xinghangee.icu/datawhale/whale-town)
|
||||||
|
- **问题反馈**: [Issues](https://gitea.xinghangee.icu/datawhale/whale-town/issues)
|
||||||
|
- **功能建议**: [Discussions](https://gitea.xinghangee.icu/datawhale/whale-town/discussions)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📄 许可证
|
||||||
|
|
||||||
|
本项目采用 [MIT License](./LICENSE) 开源协议。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
**🐋 WhaleTown - 企业级像素游戏开发框架**
|
||||||
|
|
||||||
|
*让游戏开发更简单,让代码质量更优秀*
|
||||||
|
|
||||||
|
[⭐ Star](https://gitea.xinghangee.icu/datawhale/whale-town) | [🍴 Fork](https://gitea.xinghangee.icu/datawhale/whale-town/fork) | [📖 文档](./docs/) | [🐛 反馈](https://gitea.xinghangee.icu/datawhale/whale-town/issues)
|
||||||
|
|
||||||
|
**文档版本**: v1.2.0 | **最后更新**: 2025-12-31
|
||||||
|
|
||||||
|
</div>
|
||||||
222
REFACTORING.md
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
# 项目结构重构文档
|
||||||
|
|
||||||
|
## 📅 重构时间
|
||||||
|
2025-12-31
|
||||||
|
|
||||||
|
## 🎯 重构目标
|
||||||
|
将项目从混乱的文件结构重构为清晰、模块化的架构,采用 Godot 最佳实践。
|
||||||
|
|
||||||
|
## 📊 重构前后对比
|
||||||
|
|
||||||
|
### 旧结构问题
|
||||||
|
```
|
||||||
|
❌ core/ - 概念模糊,混合了框架和业务逻辑
|
||||||
|
❌ module/ - 空壳目录,设计未落地
|
||||||
|
❌ scripts/ - 与 scenes/ 重复,脚本分散
|
||||||
|
❌ scenes/ - 场景、预制体、脚本混在一起
|
||||||
|
❌ data/ - 配置和运行时数据不分
|
||||||
|
```
|
||||||
|
|
||||||
|
### 新结构优势
|
||||||
|
```
|
||||||
|
✅ _Core/ - 框架层:全局单例和系统
|
||||||
|
✅ Scenes/ - 玩法层:按游戏世界组织
|
||||||
|
✅ UI/ - 界面层:独立的UI管理
|
||||||
|
✅ Assets/ - 资源层:纯美术资源
|
||||||
|
✅ Config/ - 配置层:静态数据
|
||||||
|
✅ Utils/ - 工具层:通用函数库
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🏗️ 新的目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
res://
|
||||||
|
├── _Core/ # [框架层] 游戏的底层框架,单例,全局管理器
|
||||||
|
│ ├── managers/ # 游戏管理器
|
||||||
|
│ │ ├── GameManager.gd # 游戏状态管理
|
||||||
|
│ │ ├── SceneManager.gd # 场景管理(已更新路径)
|
||||||
|
│ │ ├── NetworkManager.gd # 网络通信
|
||||||
|
│ │ └── ResponseHandler.gd # API响应处理
|
||||||
|
│ ├── systems/ # 核心系统
|
||||||
|
│ │ └── EventSystem.gd # 事件系统
|
||||||
|
│ └── singletons/ # 其他单例(待扩展)
|
||||||
|
│
|
||||||
|
├── Scenes/ # [玩法层] 具体的游戏场景、实体、地图
|
||||||
|
│ ├── Maps/ # 地图场景
|
||||||
|
│ │ └── main_scene.tscn # 主游戏场景
|
||||||
|
│ ├── Entities/ # 游戏实体
|
||||||
|
│ │ ├── Player/ # 玩家实体
|
||||||
|
│ │ ├── NPC/ # NPC实体
|
||||||
|
│ │ └── Interactables/ # 交互物
|
||||||
|
│ └── Components/ # 可复用组件
|
||||||
|
│
|
||||||
|
├── UI/ # [界面层] 所有UI相关的预制体和逻辑
|
||||||
|
│ ├── HUD/ # 抬头显示(常驻)
|
||||||
|
│ ├── Windows/ # 模态窗口
|
||||||
|
│ │ └── LoginWindow.tscn # 登录窗口(原auth_scene.tscn)
|
||||||
|
│ ├── Dialog/ # 对话系统
|
||||||
|
│ └── Theme/ # 全局样式
|
||||||
|
│ ├── MainTheme.tres # 主主题
|
||||||
|
│ └── Fonts/ # 字体文件
|
||||||
|
│
|
||||||
|
├── Assets/ # [资源层] 美术、音频、字体
|
||||||
|
│ ├── Sprites/ # 精灵图
|
||||||
|
│ ├── Audio/ # 音频
|
||||||
|
│ └── Fonts/ # 字体
|
||||||
|
│
|
||||||
|
├── Config/ # [配置层] 游戏配置文件
|
||||||
|
│ ├── game_config.json # 游戏配置
|
||||||
|
│ └── zh_CN.json # 中文本地化
|
||||||
|
│
|
||||||
|
├── Utils/ # [工具层] 通用辅助脚本
|
||||||
|
│ └── StringUtils.gd # 字符串工具
|
||||||
|
│
|
||||||
|
└── Tests/ # [测试层] 单元测试脚本
|
||||||
|
├── api/ # API测试
|
||||||
|
├── auth/ # 认证测试
|
||||||
|
├── integration/ # 集成测试
|
||||||
|
├── performance/ # 性能测试
|
||||||
|
└── unit/ # 单元测试
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔄 迁移映射表
|
||||||
|
|
||||||
|
| 旧路径 | 新路径 | 说明 |
|
||||||
|
|--------|--------|------|
|
||||||
|
| `core/managers/*` | `_Core/managers/` | 框架层管理器 |
|
||||||
|
| `core/systems/*` | `_Core/systems/` | 框架层系统 |
|
||||||
|
| `core/utils/*` | `Utils/` | 工具类 |
|
||||||
|
| `scenes/main_scene.tscn` | `Scenes/Maps/main_scene.tscn` | 主游戏场景 |
|
||||||
|
| `scenes/auth_scene.tscn` | `UI/Windows/LoginWindow.tscn` | 登录窗口 |
|
||||||
|
| `data/configs/*.json` | `Config/` | 配置文件 |
|
||||||
|
| `data/localization/*.json` | `Config/` | 本地化配置 |
|
||||||
|
| `assets/ui/chinese_theme.tres` | `UI/Theme/MainTheme.tres` | UI主题 |
|
||||||
|
| `assets/fonts/*` | `UI/Theme/Fonts/` | 字体文件 |
|
||||||
|
|
||||||
|
## ✂️ 已删除的目录
|
||||||
|
|
||||||
|
- ❌ `core/` - 已迁移到 `_Core/`
|
||||||
|
- ❌ `module/` - 空目录,未使用
|
||||||
|
- ❌ `scripts/` - 脚本应内联到场景目录
|
||||||
|
- ❌ `scenes/` - 已迁移到 `Scenes/` 和 `UI/`
|
||||||
|
- ❌ `data/` - 配置已移至 `Config/`
|
||||||
|
|
||||||
|
## 🔧 已更新的配置文件
|
||||||
|
|
||||||
|
### project.godot
|
||||||
|
```ini
|
||||||
|
# 更新主场景路径
|
||||||
|
run/main_scene="res://Scenes/Maps/main_scene.tscn"
|
||||||
|
|
||||||
|
# 更新自动加载路径
|
||||||
|
GameManager="*res://_Core/managers/GameManager.gd"
|
||||||
|
SceneManager="*res://_Core/managers/SceneManager.gd"
|
||||||
|
EventSystem="*res://_Core/systems/EventSystem.gd"
|
||||||
|
NetworkManager="*res://_Core/managers/NetworkManager.gd"
|
||||||
|
ResponseHandler="*res://_Core/managers/ResponseHandler.gd"
|
||||||
|
```
|
||||||
|
|
||||||
|
### SceneManager.gd
|
||||||
|
```gdscript
|
||||||
|
# 更新场景路径映射
|
||||||
|
var scene_paths: Dictionary = {
|
||||||
|
"main": "res://Scenes/Maps/main_scene.tscn",
|
||||||
|
"auth": "res://UI/Windows/LoginWindow.tscn",
|
||||||
|
# ... 其他场景路径
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 测试文件
|
||||||
|
- `tests/auth/enhanced_toast_test.gd` - 已更新脚本路径
|
||||||
|
- `tests/auth/auth_ui_test.tscn` - 已更新场景路径
|
||||||
|
|
||||||
|
## 🎨 设计原则
|
||||||
|
|
||||||
|
### 1. 清晰的分层
|
||||||
|
- **_Core**: 框架代码,与具体游戏逻辑无关
|
||||||
|
- **Scenes**: 游戏世界,地图和实体
|
||||||
|
- **UI**: 所有界面,HUD和弹窗
|
||||||
|
- **Config**: 静态数据,策划可编辑
|
||||||
|
|
||||||
|
### 2. 组件化设计
|
||||||
|
```gdscript
|
||||||
|
# 可复用组件放在 Scenes/Components/
|
||||||
|
Scenes/Components/
|
||||||
|
├── InteractableArea.tscn # 让任何物体"可交互"
|
||||||
|
├── MovementSync.gd # 网络位置同步
|
||||||
|
└── NameTag3D.tscn # 头顶名字条
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 场景内聚
|
||||||
|
- 每个 .tscn 配套一个 .gd
|
||||||
|
- 脚本紧邻场景文件存放
|
||||||
|
- 符合 Godot 原生开发习惯
|
||||||
|
|
||||||
|
### 4. 职责单一
|
||||||
|
```
|
||||||
|
UI/Windows/ - 模态窗口(登录、设置、商店)
|
||||||
|
UI/HUD/ - 常驻界面(聊天框、状态栏)
|
||||||
|
UI/Dialog/ - 对话系统
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🚀 后续建议
|
||||||
|
|
||||||
|
### 待完善的功能
|
||||||
|
1. **组件化开发**
|
||||||
|
- 创建 `Scenes/Components/` 下的可复用组件
|
||||||
|
- 使用组合优于继承的设计模式
|
||||||
|
|
||||||
|
2. **UI 独立化**
|
||||||
|
- 补充 `UI/HUD/` 下的常驻界面
|
||||||
|
- 创建 `UI/Dialog/` 对话系统
|
||||||
|
|
||||||
|
3. **场景管理**
|
||||||
|
- 补充更多地图场景到 `Scenes/Maps/`
|
||||||
|
- 添加玩家实体到 `Scenes/Entities/Player/`
|
||||||
|
|
||||||
|
4. **配置驱动**
|
||||||
|
- 将硬编码的数值移到 `Config/`
|
||||||
|
- 使用 Resource 文件管理游戏数据
|
||||||
|
|
||||||
|
### 团队协作
|
||||||
|
- **美术组**: 主要在 `Assets/` 工作
|
||||||
|
- **策划组**: 主要在 `Config/` 工作
|
||||||
|
- **程序组**: 主要在 `_Core/`, `Scenes/`, `UI/` 工作
|
||||||
|
- **测试组**: 主要在 `Tests/` 工作
|
||||||
|
|
||||||
|
## 📝 迁移检查清单
|
||||||
|
|
||||||
|
- [x] 创建新的目录结构
|
||||||
|
- [x] 迁移核心管理器
|
||||||
|
- [x] 迁移工具类
|
||||||
|
- [x] 迁移场景文件
|
||||||
|
- [x] 分离 UI 界面
|
||||||
|
- [x] 迁移配置文件
|
||||||
|
- [x] 重组资源文件
|
||||||
|
- [x] 更新 project.godot
|
||||||
|
- [x] 更新路径引用
|
||||||
|
- [x] 清理旧目录
|
||||||
|
- [ ] 在 Godot 编辑器中测试场景加载
|
||||||
|
- [ ] 验证所有自动加载脚本正常工作
|
||||||
|
- [ ] 测试网络连接功能
|
||||||
|
- [ ] 验证 UI 主题显示
|
||||||
|
|
||||||
|
## ⚠️ 注意事项
|
||||||
|
|
||||||
|
1. **场景引用更新**: 所有旧场景的引用都已更新,但建议在 Godot 编辑器中重新打开项目,让编辑器重新索引文件
|
||||||
|
|
||||||
|
2. **.import 文件**: 移动资源文件后,Godot 可能会重新生成 .import 文件,这是正常的
|
||||||
|
|
||||||
|
3. **版本控制**: 如果使用 Git,旧文件的删除会在下次提交时体现
|
||||||
|
|
||||||
|
4. **测试覆盖**: 迁移后建议运行完整的测试套件确保功能正常
|
||||||
|
|
||||||
|
## 🎓 参考资料
|
||||||
|
|
||||||
|
- [Godot 官方项目组织建议](https://docs.godotengine.org/en/stable/tutorials/best_practices/project_organization.html)
|
||||||
|
- [GDScript 场景组织](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#scenes-and-scripts)
|
||||||
|
- [ECS 架构模式](https://github.com/SmitUS/Pine-Tree-ECS-For-Godot-4)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**重构完成!项目现在拥有清晰的架构,易于维护和扩展。** 🎉
|
||||||
213
STRUCTURE_COMPARISON.md
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
# 🏗️ 项目结构对比
|
||||||
|
|
||||||
|
## 旧结构 ❌
|
||||||
|
```
|
||||||
|
whale-town-front/
|
||||||
|
├── core/ # ❌ 概念模糊
|
||||||
|
│ ├── managers/ # - 框架代码?
|
||||||
|
│ ├── systems/ # - 还是业务逻辑?
|
||||||
|
│ └── utils/ # - 边界不清
|
||||||
|
├── module/ # ❌ 空壳目录(无 .gd 文件)
|
||||||
|
│ ├── Character/
|
||||||
|
│ ├── Combat/
|
||||||
|
│ ├── Dialogue/
|
||||||
|
│ ├── Inventory/
|
||||||
|
│ └── UI/
|
||||||
|
├── scenes/ # ❌ 混乱的组织
|
||||||
|
│ ├── auth_scene.tscn
|
||||||
|
│ ├── main_scene.tscn
|
||||||
|
│ ├── Components/
|
||||||
|
│ ├── Entities/
|
||||||
|
│ ├── Maps/
|
||||||
|
│ └── prefabs/
|
||||||
|
├── scripts/ # ❌ 与 scenes/ 重复
|
||||||
|
│ ├── characters/
|
||||||
|
│ ├── scenes/
|
||||||
|
│ ├── ui/
|
||||||
|
│ └── network/
|
||||||
|
├── data/ # ❌ 配置和数据混在一起
|
||||||
|
│ ├── configs/
|
||||||
|
│ ├── characters/
|
||||||
|
│ ├── dialogues/
|
||||||
|
│ └── localization/
|
||||||
|
├── assets/ # ✅ 相对清晰
|
||||||
|
│ ├── audio/
|
||||||
|
│ ├── fonts/
|
||||||
|
│ ├── icon/
|
||||||
|
│ ├── materials/
|
||||||
|
│ ├── shaders/
|
||||||
|
│ ├── sprites/
|
||||||
|
│ └── ui/
|
||||||
|
├── tests/ # ✅ 结构良好
|
||||||
|
│ ├── api/
|
||||||
|
│ ├── auth/
|
||||||
|
│ ├── integration/
|
||||||
|
│ ├── performance/
|
||||||
|
│ └── unit/
|
||||||
|
└── docs/
|
||||||
|
```
|
||||||
|
|
||||||
|
**问题总结:**
|
||||||
|
1. 🔴 脚本分散:`scripts/` 和 `scenes/` 都有脚本,职责不清
|
||||||
|
2. 🔴 空壳模块:`module/` 目录存在但无实际代码
|
||||||
|
3. 🔴 场景混乱:场景文件、预制体、脚本平级放置
|
||||||
|
4. 🔴 分层不明:`core/`, `module/`, `scripts/` 三层交叉
|
||||||
|
5. 🔴 数据混杂:`data/` 既包含配置也包含运行时数据
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 新结构 ✅
|
||||||
|
```
|
||||||
|
whale-town-front/
|
||||||
|
├── _Core/ # ✅ 框架层 - 清晰的单例和系统
|
||||||
|
│ ├── managers/ # - 全局管理器
|
||||||
|
│ ├── systems/ # - 核心系统
|
||||||
|
│ └── singletons/ # - 其他单例
|
||||||
|
│
|
||||||
|
├── Scenes/ # ✅ 玩法层 - 按游戏世界组织
|
||||||
|
│ ├── Maps/ # - 地图场景
|
||||||
|
│ │ └── main_scene.tscn
|
||||||
|
│ ├── Entities/ # - 游戏实体
|
||||||
|
│ │ ├── Player/ # - 玩家
|
||||||
|
│ │ ├── NPC/ # - NPC
|
||||||
|
│ │ └── Interactables/ # - 交互物
|
||||||
|
│ └── Components/ # - 可复用组件
|
||||||
|
│
|
||||||
|
├── UI/ # ✅ 界面层 - 独立的UI管理
|
||||||
|
│ ├── HUD/ # - 抬头显示(常驻)
|
||||||
|
│ ├── Windows/ # - 模态窗口
|
||||||
|
│ │ └── LoginWindow.tscn # (原 auth_scene)
|
||||||
|
│ ├── Dialog/ # - 对话系统
|
||||||
|
│ └── Theme/ # - 全局样式
|
||||||
|
│ ├── MainTheme.tres
|
||||||
|
│ └── Fonts/
|
||||||
|
│
|
||||||
|
├── Assets/ # ✅ 资源层 - 纯美术资源
|
||||||
|
│ ├── Sprites/ # - 精灵图
|
||||||
|
│ ├── Audio/ # - 音频
|
||||||
|
│ └── Fonts/ # - 字体
|
||||||
|
│
|
||||||
|
├── Config/ # ✅ 配置层 - 静态数据
|
||||||
|
│ ├── game_config.json
|
||||||
|
│ └── zh_CN.json
|
||||||
|
│
|
||||||
|
├── Utils/ # ✅ 工具层 - 通用函数库
|
||||||
|
│ └── StringUtils.gd
|
||||||
|
│
|
||||||
|
├── Tests/ # ✅ 测试层 - 完整的测试覆盖
|
||||||
|
│ ├── api/
|
||||||
|
│ ├── auth/
|
||||||
|
│ ├── integration/
|
||||||
|
│ ├── performance/
|
||||||
|
│ └── unit/
|
||||||
|
│
|
||||||
|
└── docs/ # 📄 项目文档
|
||||||
|
└── web_deployment_guide.md
|
||||||
|
```
|
||||||
|
|
||||||
|
**改进总结:**
|
||||||
|
1. 🟢 **分层清晰**: 框架、玩法、界面、资源、配置、工具各司其职
|
||||||
|
2. 🟢 **场景内聚**: .tscn 和 .gd 成对出现,逻辑紧耦合场景
|
||||||
|
3. 🟢 **UI 独立**: 所有界面统一管理,避免和游戏场景混淆
|
||||||
|
4. 🟢 **配置分离**: Config 只存放静态数据,策划可直接编辑
|
||||||
|
5. 🟢 **组件化**: Scenes/Components/ 提供可复用的逻辑组件
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 核心改进对比表
|
||||||
|
|
||||||
|
| 维度 | 旧结构 | 新结构 | 改进效果 |
|
||||||
|
|:---:|:---:|:---:|:---:|
|
||||||
|
| **目录层级** | 8层 | 6层 | ✅ 更扁平 |
|
||||||
|
| **脚本管理** | 分散在2处 | 集中在场景内 | ✅ 内聚性高 |
|
||||||
|
| **UI 组织** | 混在 scenes/ | 独立 UI/ | ✅ 职责清晰 |
|
||||||
|
| **框架代码** | core/ 概念模糊 | _Core/ 明确 | ✅ 边界清楚 |
|
||||||
|
| **配置管理** | data/ 混杂 | Config/ 专职 | ✅ 策划友好 |
|
||||||
|
| **可维护性** | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ✅ 提升67% |
|
||||||
|
| **学习曲线** | ⭐⭐ | ⭐⭐⭐⭐ | ✅ 新人友好 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎯 Godot 最佳实践对照
|
||||||
|
|
||||||
|
### ✅ 符合 Godot 规范
|
||||||
|
- [x] 场景脚本内聚(.tscn + .gd 相邻)
|
||||||
|
- [x] 使用 autoload 全局单例
|
||||||
|
- [x] 组件化设计(可复用的 Components/)
|
||||||
|
- [x] 资源独立管理(Assets/)
|
||||||
|
- [x] 配置与代码分离(Config/)
|
||||||
|
|
||||||
|
### 🔧 待完善项
|
||||||
|
- [ ] 补充 Scenes/Components/ 下的可复用组件
|
||||||
|
- [ ] 完善事件系统的使用
|
||||||
|
- [ ] 添加 SaveSystem 到 _Core/systems/
|
||||||
|
- [ ] 实现资源热重载机制
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📈 团队协作改进
|
||||||
|
|
||||||
|
### 角色与目录对应
|
||||||
|
```
|
||||||
|
┌─────────────────┬─────────────────────────────────┐
|
||||||
|
│ 角色 │ 主要工作目录 │
|
||||||
|
├─────────────────┼─────────────────────────────────┤
|
||||||
|
│ 🎨 美术组 │ Assets/Sprites/, Assets/Audio/ │
|
||||||
|
│ 📋 策划组 │ Config/ │
|
||||||
|
│ 💻 前端程序 │ UI/, Scenes/Entities/ │
|
||||||
|
│ ⚙️ 后端程序 │ _Core/, Utils/ │
|
||||||
|
│ 🧪 测试组 │ Tests/ │
|
||||||
|
└─────────────────┴─────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### 协作优势
|
||||||
|
1. **减少冲突**: 不同角色在不同目录工作
|
||||||
|
2. **职责清晰**: 每个目录有明确的负责人
|
||||||
|
3. **易于审查**: PR 可以按目录分类评审
|
||||||
|
4. **快速定位**: 新人快速找到相关文件
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 扩展性对比
|
||||||
|
|
||||||
|
### 旧结构的扩展问题
|
||||||
|
```gdscript
|
||||||
|
// 添加新功能时需要在多个地方修改
|
||||||
|
module/FeatureName/ // ❌ 需要创建
|
||||||
|
scenes/feature_scene/ // ❌ 需要创建
|
||||||
|
scripts/feature_logic/ // ❌ 需要创建
|
||||||
|
data/feature_config/ // ❌ 需要创建
|
||||||
|
```
|
||||||
|
|
||||||
|
### 新结构的扩展方式
|
||||||
|
```gdscript
|
||||||
|
// 添加新功能只需要:
|
||||||
|
Scenes/Entities/NewFeature/ // ✅ 场景+逻辑一体
|
||||||
|
Config/feature_config.json // ✅ 配置独立
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 参考架构
|
||||||
|
|
||||||
|
这个新结构参考了业界最佳实践:
|
||||||
|
- **Godot 官方**: [Project Organization](https://docs.godotengine.org/en/stable/tutorials/best_practices/project_organization.html)
|
||||||
|
- **Unity 模式**: Assets/Scenes/Scripts 分离
|
||||||
|
- **ECS 架构**: Entities + Components 思想
|
||||||
|
- **微服务思维**: 按功能域而非技术分层
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎓 学习资源
|
||||||
|
|
||||||
|
如果你是新人,这里有一些学习路径:
|
||||||
|
|
||||||
|
1. **先熟悉目录** → 查看 [REFACTORING.md](./REFACTORING.md)
|
||||||
|
2. **理解核心系统** → 阅读 `_Core/systems/EventSystem.gd`
|
||||||
|
3. **学习场景管理** → 查看 `_Core/managers/SceneManager.gd`
|
||||||
|
4. **研究 UI 结构** → 打开 `UI/Windows/LoginWindow.tscn`
|
||||||
|
5. **运行测试** → 执行 `Tests/` 下的测试用例
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**结论:新结构更加清晰、模块化、易于维护,符合 Godot 最佳实践!** 🎉
|
||||||
BIN
UI/Theme/Fonts/msyh.ttc
Normal file
41
UI/Theme/Fonts/msyh.ttc.import
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://ce7ujbeobblyr"
|
||||||
|
path="res://.godot/imported/msyh.ttc-ee5749038370cbe296598e3bc4218102.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://UI/Theme/Fonts/msyh.ttc"
|
||||||
|
dest_files=["res://.godot/imported/msyh.ttc-ee5749038370cbe296598e3bc4218102.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
modulate_color_glyphs=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=false
|
||||||
|
preload=[{
|
||||||
|
"chars": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=[]{}|;':\",./<>?`~一二三四五六七八九十百千万亿用户名密码登录注册验证码邮箱小镇鲸鱼欢迎来到开始你的之旅请输入不能为空获取发送忘记返回居民身份确认再次已被使用换个等待分钟后试稍后正在创建账户测试模式生成查看控制台网络连接失败系统维护中升级稍后再试频繁联系管理员禁用审核先邮箱后使用成功进入镇错误或过期未找到存在",
|
||||||
|
"glyphs": [],
|
||||||
|
"name": "Web预加载",
|
||||||
|
"size": Vector2i(16, 0)
|
||||||
|
}]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
||||||
7
UI/Theme/MainTheme.tres
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cp7t8tu7rmyad"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://ce7ujbeobblyr" path="res://assets/fonts/msyh.ttc" id="1_ftb5w"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
default_font = ExtResource("1_ftb5w")
|
||||||
1032
UI/Windows/AuthScene.gd
Normal file
1
UI/Windows/AuthScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bs1vy3ierj66t
|
||||||
561
UI/Windows/LoginWindow.tscn
Normal file
@@ -0,0 +1,561 @@
|
|||||||
|
[gd_scene load_steps=10 format=3 uid="uid://by7m8snb4xllf"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bx17oy8lvaca4" path="res://assets/ui/auth/bg_auth_scene.png" id="1_background"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://de4q4s1gxivtf" path="res://assets/ui/auth/login_frame_smart_transparent.png" id="2_frame"]
|
||||||
|
[ext_resource type="Script" uid="uid://nv8eitxieqtm" path="res://UI/Windows/AuthScene.gd" id="3_script"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hover"]
|
||||||
|
bg_color = Color(0.3, 0.6, 0.9, 1)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(0.2, 0.5, 0.8, 1)
|
||||||
|
corner_radius_top_left = 8
|
||||||
|
corner_radius_top_right = 8
|
||||||
|
corner_radius_bottom_right = 8
|
||||||
|
corner_radius_bottom_left = 8
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_normal"]
|
||||||
|
bg_color = Color(0.2, 0.5, 0.8, 1)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(0.15, 0.4, 0.7, 1)
|
||||||
|
corner_radius_top_left = 8
|
||||||
|
corner_radius_top_right = 8
|
||||||
|
corner_radius_bottom_right = 8
|
||||||
|
corner_radius_bottom_left = 8
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pressed"]
|
||||||
|
bg_color = Color(0.4, 0.7, 1, 1)
|
||||||
|
border_width_left = 2
|
||||||
|
border_width_top = 2
|
||||||
|
border_width_right = 2
|
||||||
|
border_width_bottom = 2
|
||||||
|
border_color = Color(0.3, 0.6, 0.9, 1)
|
||||||
|
corner_radius_top_left = 8
|
||||||
|
corner_radius_top_right = 8
|
||||||
|
corner_radius_bottom_right = 8
|
||||||
|
corner_radius_bottom_left = 8
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_main_button"]
|
||||||
|
Button/colors/font_color = Color(1, 1, 1, 1)
|
||||||
|
Button/colors/font_hover_color = Color(1, 1, 1, 1)
|
||||||
|
Button/colors/font_pressed_color = Color(1, 1, 1, 1)
|
||||||
|
Button/font_sizes/font_size = 18
|
||||||
|
Button/styles/hover = SubResource("StyleBoxFlat_hover")
|
||||||
|
Button/styles/normal = SubResource("StyleBoxFlat_normal")
|
||||||
|
Button/styles/pressed = SubResource("StyleBoxFlat_pressed")
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_button"]
|
||||||
|
Button/colors/font_color = Color(1, 1, 1, 1)
|
||||||
|
Button/colors/font_hover_color = Color(1, 1, 1, 1)
|
||||||
|
Button/colors/font_pressed_color = Color(1, 1, 1, 1)
|
||||||
|
Button/styles/hover = SubResource("StyleBoxFlat_hover")
|
||||||
|
Button/styles/normal = SubResource("StyleBoxFlat_normal")
|
||||||
|
Button/styles/pressed = SubResource("StyleBoxFlat_pressed")
|
||||||
|
|
||||||
|
[node name="AuthScene" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("3_script")
|
||||||
|
|
||||||
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
|
||||||
|
[node name="BackgroundImage" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("1_background")
|
||||||
|
expand_mode = 1
|
||||||
|
stretch_mode = 6
|
||||||
|
|
||||||
|
[node name="WhaleFrame" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -300.0
|
||||||
|
offset_top = -300.0
|
||||||
|
offset_right = 300.0
|
||||||
|
offset_bottom = 300.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = ExtResource("2_frame")
|
||||||
|
expand_mode = 1
|
||||||
|
stretch_mode = 5
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -175.0
|
||||||
|
offset_top = -184.0
|
||||||
|
offset_right = 175.0
|
||||||
|
offset_bottom = 236.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="LoginPanel" type="Panel" parent="CenterContainer"]
|
||||||
|
custom_minimum_size = Vector2(350, 400)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxEmpty_1")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 30.0
|
||||||
|
offset_top = 30.0
|
||||||
|
offset_right = -30.0
|
||||||
|
offset_bottom = -30.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="TitleLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
text = "Whaletown"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="SubtitleLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 14
|
||||||
|
text = "开始你的小镇之旅!"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="LoginForm" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="UsernameContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="UsernameLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="UsernameLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "用户名/手机/邮箱"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="UsernameError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "用户名不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="UsernameInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/UsernameContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "用户名/手机/邮箱"
|
||||||
|
|
||||||
|
[node name="PasswordContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="PasswordLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="PasswordLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "密码"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="PasswordError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "密码不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="PasswordInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/PasswordContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入密码"
|
||||||
|
secret = true
|
||||||
|
|
||||||
|
[node name="VerificationContainer" type="VBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationLabelContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationLabel" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "验证码"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="VerificationError" type="Label" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "请输入验证码"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="VerificationInputContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationInput" type="LineEdit" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationInputContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入6位验证码"
|
||||||
|
max_length = 6
|
||||||
|
|
||||||
|
[node name="GetCodeBtn" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/VerificationContainer/VerificationInputContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "获取验证码"
|
||||||
|
|
||||||
|
[node name="CheckboxContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="RememberPassword" type="CheckBox" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/CheckboxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "记住密码"
|
||||||
|
|
||||||
|
[node name="AutoLogin" type="CheckBox" parent="CenterContainer/LoginPanel/VBoxContainer/LoginForm/CheckboxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "自动登录"
|
||||||
|
|
||||||
|
[node name="HSeparator2" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="MainButton" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(280, 50)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_main_button")
|
||||||
|
text = "进入小镇"
|
||||||
|
|
||||||
|
[node name="HSeparator3" type="HSeparator" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ButtonContainer" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="LoginBtn" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/ButtonContainer"]
|
||||||
|
custom_minimum_size = Vector2(100, 35)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_button")
|
||||||
|
text = "密码登录"
|
||||||
|
|
||||||
|
[node name="BottomLinks" type="HBoxContainer" parent="CenterContainer/LoginPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="ForgotPassword" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/BottomLinks"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "忘记密码?"
|
||||||
|
flat = true
|
||||||
|
|
||||||
|
[node name="RegisterLink" type="Button" parent="CenterContainer/LoginPanel/VBoxContainer/BottomLinks"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "注册居民身份"
|
||||||
|
flat = true
|
||||||
|
|
||||||
|
[node name="RegisterPanel" type="Panel" parent="CenterContainer"]
|
||||||
|
visible = false
|
||||||
|
custom_minimum_size = Vector2(400, 570)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxEmpty_1")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 30.0
|
||||||
|
offset_top = 75.0
|
||||||
|
offset_right = -30.0
|
||||||
|
offset_bottom = -72.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="TitleLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_font_sizes/font_size = 20
|
||||||
|
text = "注册新居民"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="HSeparator" type="HSeparator" parent="CenterContainer/RegisterPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="RegisterForm" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="UsernameContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="UsernameLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="UsernameLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "用户名"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="UsernameError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer/UsernameLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "用户名不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="UsernameInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/UsernameContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入用户名"
|
||||||
|
|
||||||
|
[node name="EmailContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="EmailLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="EmailLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "邮箱"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="EmailError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer/EmailLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "邮箱不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="EmailInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/EmailContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入邮箱地址"
|
||||||
|
|
||||||
|
[node name="PasswordContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="PasswordLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="PasswordLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "密码"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="PasswordError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer/PasswordLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "密码不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="PasswordInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/PasswordContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入密码(至少8位)"
|
||||||
|
secret = true
|
||||||
|
|
||||||
|
[node name="ConfirmContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ConfirmLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ConfirmLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "确认密码"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="ConfirmError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer/ConfirmLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "确认密码不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="ConfirmInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/ConfirmContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请再次输入密码"
|
||||||
|
secret = true
|
||||||
|
|
||||||
|
[node name="VerificationContainer" type="VBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationLabelContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationLabel" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
text = "邮箱验证码"
|
||||||
|
|
||||||
|
[node name="RequiredStar" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
text = " *"
|
||||||
|
|
||||||
|
[node name="Spacer" type="Control" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="VerificationError" type="Label" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationLabelContainer"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 0.2, 0.2, 1)
|
||||||
|
theme_override_font_sizes/font_size = 12
|
||||||
|
text = "验证码不能为空"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="VerificationInputContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VerificationInput" type="LineEdit" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationInputContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_colors/font_placeholder_color = Color(0.5, 0.5, 0.5, 1)
|
||||||
|
placeholder_text = "请输入6位验证码"
|
||||||
|
max_length = 6
|
||||||
|
|
||||||
|
[node name="SendCodeBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/RegisterForm/VerificationContainer/VerificationInputContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "发送验证码"
|
||||||
|
|
||||||
|
[node name="HSeparator2" type="HSeparator" parent="CenterContainer/RegisterPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ButtonContainer" type="HBoxContainer" parent="CenterContainer/RegisterPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="RegisterBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/ButtonContainer"]
|
||||||
|
custom_minimum_size = Vector2(120, 45)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_button")
|
||||||
|
text = "注册"
|
||||||
|
|
||||||
|
[node name="ToLoginBtn" type="Button" parent="CenterContainer/RegisterPanel/VBoxContainer/ButtonContainer"]
|
||||||
|
custom_minimum_size = Vector2(120, 45)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_button")
|
||||||
|
text = "返回登录"
|
||||||
|
|
||||||
|
[node name="ToastContainer" type="Control" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
199
Utils/StringUtils.gd
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
class_name StringUtils
|
||||||
|
|
||||||
|
# 字符串工具类 - 提供常用的字符串处理功能
|
||||||
|
|
||||||
|
# 验证邮箱格式
|
||||||
|
static func is_valid_email(email: String) -> bool:
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")
|
||||||
|
return regex.search(email) != null
|
||||||
|
|
||||||
|
# 验证用户名格式(字母、数字、下划线)
|
||||||
|
static func is_valid_username(username: String) -> bool:
|
||||||
|
if username.is_empty() or username.length() > 50:
|
||||||
|
return false
|
||||||
|
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("^[a-zA-Z0-9_]+$")
|
||||||
|
return regex.search(username) != null
|
||||||
|
|
||||||
|
# 验证密码强度
|
||||||
|
static func validate_password_strength(password: String) -> Dictionary:
|
||||||
|
var result = {"valid": false, "message": "", "strength": 0}
|
||||||
|
|
||||||
|
if password.length() < 8:
|
||||||
|
result.message = "密码长度至少8位"
|
||||||
|
return result
|
||||||
|
|
||||||
|
if password.length() > 128:
|
||||||
|
result.message = "密码长度不能超过128位"
|
||||||
|
return result
|
||||||
|
|
||||||
|
var has_letter = false
|
||||||
|
var has_digit = false
|
||||||
|
var has_special = false
|
||||||
|
|
||||||
|
for i in range(password.length()):
|
||||||
|
var char = password[i]
|
||||||
|
if char >= 'a' and char <= 'z' or char >= 'A' and char <= 'Z':
|
||||||
|
has_letter = true
|
||||||
|
elif char >= '0' and char <= '9':
|
||||||
|
has_digit = true
|
||||||
|
elif char in "!@#$%^&*()_+-=[]{}|;:,.<>?":
|
||||||
|
has_special = true
|
||||||
|
|
||||||
|
var strength = 0
|
||||||
|
if has_letter:
|
||||||
|
strength += 1
|
||||||
|
if has_digit:
|
||||||
|
strength += 1
|
||||||
|
if has_special:
|
||||||
|
strength += 1
|
||||||
|
if password.length() >= 12:
|
||||||
|
strength += 1
|
||||||
|
|
||||||
|
result.strength = strength
|
||||||
|
|
||||||
|
if not (has_letter and has_digit):
|
||||||
|
result.message = "密码必须包含字母和数字"
|
||||||
|
return result
|
||||||
|
|
||||||
|
result.valid = true
|
||||||
|
result.message = "密码强度: " + ["弱", "中", "强", "很强"][min(strength - 1, 3)]
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 截断字符串
|
||||||
|
static func truncate(text: String, max_length: int, suffix: String = "...") -> String:
|
||||||
|
if text.length() <= max_length:
|
||||||
|
return text
|
||||||
|
return text.substr(0, max_length - suffix.length()) + suffix
|
||||||
|
|
||||||
|
# 首字母大写
|
||||||
|
static func capitalize_first(text: String) -> String:
|
||||||
|
if text.is_empty():
|
||||||
|
return text
|
||||||
|
return text[0].to_upper() + text.substr(1)
|
||||||
|
|
||||||
|
# 转换为标题格式(每个单词首字母大写)
|
||||||
|
static func to_title_case(text: String) -> String:
|
||||||
|
var words = text.split(" ")
|
||||||
|
var result = []
|
||||||
|
for word in words:
|
||||||
|
if not word.is_empty():
|
||||||
|
result.append(capitalize_first(word.to_lower()))
|
||||||
|
return " ".join(result)
|
||||||
|
|
||||||
|
# 移除HTML标签
|
||||||
|
static func strip_html_tags(html: String) -> String:
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("<[^>]*>")
|
||||||
|
return regex.sub(html, "", true)
|
||||||
|
|
||||||
|
# 格式化文件大小
|
||||||
|
static func format_file_size(bytes: int) -> String:
|
||||||
|
var units = ["B", "KB", "MB", "GB", "TB"]
|
||||||
|
var size = float(bytes)
|
||||||
|
var unit_index = 0
|
||||||
|
|
||||||
|
while size >= 1024.0 and unit_index < units.size() - 1:
|
||||||
|
size /= 1024.0
|
||||||
|
unit_index += 1
|
||||||
|
|
||||||
|
if unit_index == 0:
|
||||||
|
return str(int(size)) + " " + units[unit_index]
|
||||||
|
else:
|
||||||
|
return "%.1f %s" % [size, units[unit_index]]
|
||||||
|
|
||||||
|
# 将UTC时间字符串转换为本地时间显示
|
||||||
|
static func format_utc_to_local_time(utc_time_str: String) -> String:
|
||||||
|
# 解析UTC时间字符串 (格式: 2025-12-25T11:23:52.175Z)
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})")
|
||||||
|
var result = regex.search(utc_time_str)
|
||||||
|
|
||||||
|
if result == null:
|
||||||
|
return utc_time_str # 如果解析失败,返回原字符串
|
||||||
|
|
||||||
|
# 提取时间组件
|
||||||
|
var year = int(result.get_string(1))
|
||||||
|
var month = int(result.get_string(2))
|
||||||
|
var day = int(result.get_string(3))
|
||||||
|
var hour = int(result.get_string(4))
|
||||||
|
var minute = int(result.get_string(5))
|
||||||
|
var second = int(result.get_string(6))
|
||||||
|
|
||||||
|
# 创建UTC时间字典
|
||||||
|
var utc_dict = {
|
||||||
|
"year": year,
|
||||||
|
"month": month,
|
||||||
|
"day": day,
|
||||||
|
"hour": hour,
|
||||||
|
"minute": minute,
|
||||||
|
"second": second
|
||||||
|
}
|
||||||
|
|
||||||
|
# 转换为Unix时间戳(UTC)
|
||||||
|
var utc_timestamp = Time.get_unix_time_from_datetime_dict(utc_dict)
|
||||||
|
|
||||||
|
# 获取本地时间(Godot会自动处理时区转换)
|
||||||
|
var local_dict = Time.get_datetime_dict_from_unix_time(utc_timestamp)
|
||||||
|
|
||||||
|
# 格式化为易读的本地时间
|
||||||
|
return "%04d年%02d月%02d日 %02d:%02d:%02d" % [
|
||||||
|
local_dict.year,
|
||||||
|
local_dict.month,
|
||||||
|
local_dict.day,
|
||||||
|
local_dict.hour,
|
||||||
|
local_dict.minute,
|
||||||
|
local_dict.second
|
||||||
|
]
|
||||||
|
|
||||||
|
# 获取相对时间描述(多少分钟后)
|
||||||
|
static func get_relative_time_until(utc_time_str: String) -> String:
|
||||||
|
# 解析UTC时间字符串
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})")
|
||||||
|
var result = regex.search(utc_time_str)
|
||||||
|
|
||||||
|
if result == null:
|
||||||
|
return "时间格式错误"
|
||||||
|
|
||||||
|
# 提取时间组件
|
||||||
|
var year = int(result.get_string(1))
|
||||||
|
var month = int(result.get_string(2))
|
||||||
|
var day = int(result.get_string(3))
|
||||||
|
var hour = int(result.get_string(4))
|
||||||
|
var minute = int(result.get_string(5))
|
||||||
|
var second = int(result.get_string(6))
|
||||||
|
|
||||||
|
# 创建UTC时间字典
|
||||||
|
var utc_dict = {
|
||||||
|
"year": year,
|
||||||
|
"month": month,
|
||||||
|
"day": day,
|
||||||
|
"hour": hour,
|
||||||
|
"minute": minute,
|
||||||
|
"second": second
|
||||||
|
}
|
||||||
|
|
||||||
|
# 转换为Unix时间戳
|
||||||
|
var target_timestamp = Time.get_unix_time_from_datetime_dict(utc_dict)
|
||||||
|
var current_timestamp = Time.get_unix_time_from_system()
|
||||||
|
|
||||||
|
# 计算时间差(秒)
|
||||||
|
var diff_seconds = target_timestamp - current_timestamp
|
||||||
|
|
||||||
|
if diff_seconds <= 0:
|
||||||
|
return "现在可以重试"
|
||||||
|
elif diff_seconds < 60:
|
||||||
|
return "%d秒后" % diff_seconds
|
||||||
|
elif diff_seconds < 3600:
|
||||||
|
var minutes = int(diff_seconds / 60)
|
||||||
|
return "%d分钟后" % minutes
|
||||||
|
else:
|
||||||
|
var hours = int(diff_seconds / 3600)
|
||||||
|
var minutes = int((diff_seconds % 3600) / 60)
|
||||||
|
if minutes > 0:
|
||||||
|
return "%d小时%d分钟后" % [hours, minutes]
|
||||||
|
else:
|
||||||
|
return "%d小时后" % hours
|
||||||
1
Utils/StringUtils.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://csxag1y8yq57j
|
||||||
58
_Core/EventNames.gd
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# ============================================================================
|
||||||
|
# 事件名称定义 - EventNames.gd
|
||||||
|
#
|
||||||
|
# 定义项目中所有事件的名称常量,确保事件名称的一致性和可维护性
|
||||||
|
#
|
||||||
|
# 使用方式:
|
||||||
|
# EventSystem.emit_event(EventNames.PLAYER_MOVED, data)
|
||||||
|
# EventSystem.connect_event(EventNames.INTERACT_PRESSED, callback)
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
class_name EventNames
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 玩家相关事件
|
||||||
|
# ============================================================================
|
||||||
|
const PLAYER_MOVED = "player_moved"
|
||||||
|
const PLAYER_SPAWNED = "player_spawned"
|
||||||
|
const PLAYER_HEALTH_CHANGED = "player_health_changed"
|
||||||
|
const PLAYER_DIED = "player_died"
|
||||||
|
const PLAYER_RESPAWNED = "player_respawned"
|
||||||
|
const PLAYER_ATTACK = "player_attack"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 交互事件
|
||||||
|
# ============================================================================
|
||||||
|
const INTERACT_PRESSED = "interact_pressed"
|
||||||
|
const NPC_TALKED = "npc_talked"
|
||||||
|
const ITEM_COLLECTED = "item_collected"
|
||||||
|
const OBJECT_INTERACTED = "object_interacted"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# UI事件
|
||||||
|
# ============================================================================
|
||||||
|
const UI_BUTTON_CLICKED = "ui_button_clicked"
|
||||||
|
const DIALOG_OPENED = "dialog_opened"
|
||||||
|
const DIALOG_CLOSED = "dialog_closed"
|
||||||
|
const MENU_OPENED = "menu_opened"
|
||||||
|
const MENU_CLOSED = "menu_closed"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 游戏状态事件
|
||||||
|
# ============================================================================
|
||||||
|
const GAME_PAUSED = "game_paused"
|
||||||
|
const GAME_RESUMED = "game_resumed"
|
||||||
|
const SCENE_CHANGED = "scene_changed"
|
||||||
|
const SCENE_DATA_TRANSFER = "scene_data_transfer"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 系统事件
|
||||||
|
# ============================================================================
|
||||||
|
const TILEMAP_READY = "tilemap_ready"
|
||||||
|
const COMPONENT_MESSAGE = "component_message"
|
||||||
|
const POSITION_UPDATE = "position_update"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 测试事件
|
||||||
|
# ============================================================================
|
||||||
|
const TEST_EVENT = "test_event"
|
||||||
1
_Core/EventNames.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://qn0imbklx1m0
|
||||||
107
_Core/ProjectPaths.gd
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# ============================================================================
|
||||||
|
# 项目路径配置 - ProjectPaths.gd
|
||||||
|
#
|
||||||
|
# 统一管理项目中所有路径常量,确保路径的一致性和可维护性
|
||||||
|
#
|
||||||
|
# 使用方式:
|
||||||
|
# var scene_path = ProjectPaths.SCENES_COMPONENTS + "ui/Button.tscn"
|
||||||
|
# var config_path = ProjectPaths.DATA_CONFIG + "game_config.json"
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
class_name ProjectPaths
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 核心系统路径
|
||||||
|
# ============================================================================
|
||||||
|
const CORE_ROOT = "res://_Core/"
|
||||||
|
const CORE_MANAGERS = CORE_ROOT + "managers/"
|
||||||
|
const CORE_SYSTEMS = CORE_ROOT + "systems/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 场景路径
|
||||||
|
# ============================================================================
|
||||||
|
const SCENES_ROOT = "res://scenes/"
|
||||||
|
const SCENES_MAPS = SCENES_ROOT + "Maps/"
|
||||||
|
const SCENES_COMPONENTS = SCENES_ROOT + "Components/"
|
||||||
|
const SCENES_UI_COMPONENTS = SCENES_COMPONENTS + "ui/"
|
||||||
|
const SCENES_CHARACTER_COMPONENTS = SCENES_COMPONENTS + "characters/"
|
||||||
|
const SCENES_EFFECT_COMPONENTS = SCENES_COMPONENTS + "effects/"
|
||||||
|
const SCENES_ITEM_COMPONENTS = SCENES_COMPONENTS + "items/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# UI路径
|
||||||
|
# ============================================================================
|
||||||
|
const UI_ROOT = "res://UI/"
|
||||||
|
const UI_WINDOWS = UI_ROOT + "Windows/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 资源路径
|
||||||
|
# ============================================================================
|
||||||
|
const ASSETS_ROOT = "res://assets/"
|
||||||
|
const ASSETS_SPRITES = ASSETS_ROOT + "sprites/"
|
||||||
|
const ASSETS_AUDIO = ASSETS_ROOT + "audio/"
|
||||||
|
const ASSETS_FONTS = ASSETS_ROOT + "fonts/"
|
||||||
|
const ASSETS_MATERIALS = ASSETS_ROOT + "materials/"
|
||||||
|
const ASSETS_SHADERS = ASSETS_ROOT + "shaders/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 数据路径
|
||||||
|
# ============================================================================
|
||||||
|
const DATA_ROOT = "res://data/"
|
||||||
|
const DATA_CONFIG = "res://Config/"
|
||||||
|
const DATA_SCENES = DATA_ROOT + "scenes/"
|
||||||
|
const DATA_LEVELS = DATA_ROOT + "levels/"
|
||||||
|
const DATA_DIALOGUES = DATA_ROOT + "dialogues/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Web资源路径
|
||||||
|
# ============================================================================
|
||||||
|
const WEB_ASSETS = "res://web_assets/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 测试路径
|
||||||
|
# ============================================================================
|
||||||
|
const TESTS_ROOT = "res://tests/"
|
||||||
|
const TESTS_UNIT = TESTS_ROOT + "unit/"
|
||||||
|
const TESTS_INTEGRATION = TESTS_ROOT + "integration/"
|
||||||
|
const TESTS_AUTH = TESTS_ROOT + "auth/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 工具路径
|
||||||
|
# ============================================================================
|
||||||
|
const UTILS_ROOT = "res://Utils/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 模块路径
|
||||||
|
# ============================================================================
|
||||||
|
const MODULES_ROOT = "res://module/"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# 辅助方法
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
# 获取场景组件路径
|
||||||
|
static func get_component_path(category: String, component_name: String) -> String:
|
||||||
|
match category:
|
||||||
|
"ui":
|
||||||
|
return SCENES_UI_COMPONENTS + component_name + ".tscn"
|
||||||
|
"characters":
|
||||||
|
return SCENES_CHARACTER_COMPONENTS + component_name + ".tscn"
|
||||||
|
"effects":
|
||||||
|
return SCENES_EFFECT_COMPONENTS + component_name + ".tscn"
|
||||||
|
"items":
|
||||||
|
return SCENES_ITEM_COMPONENTS + component_name + ".tscn"
|
||||||
|
_:
|
||||||
|
return SCENES_COMPONENTS + component_name + ".tscn"
|
||||||
|
|
||||||
|
# 获取模块路径
|
||||||
|
static func get_module_path(module_name: String) -> String:
|
||||||
|
return MODULES_ROOT + module_name + "/"
|
||||||
|
|
||||||
|
# 获取模块配置路径
|
||||||
|
static func get_module_config_path(module_name: String) -> String:
|
||||||
|
return get_module_path(module_name) + "data/module_config.json"
|
||||||
|
|
||||||
|
# 获取场景数据路径
|
||||||
|
static func get_scene_data_path(scene_name: String) -> String:
|
||||||
|
return DATA_SCENES + scene_name.to_lower() + ".json"
|
||||||
1
_Core/ProjectPaths.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dybcuscku7tyl
|
||||||
50
_Core/managers/GameManager.gd
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# 游戏管理器 - 全局游戏状态管理
|
||||||
|
# 单例模式,管理游戏的整体状态和生命周期
|
||||||
|
|
||||||
|
signal game_state_changed(new_state: GameState)
|
||||||
|
|
||||||
|
enum GameState {
|
||||||
|
LOADING, # 加载中
|
||||||
|
AUTH, # 认证状态
|
||||||
|
MAIN_MENU, # 主菜单
|
||||||
|
IN_GAME, # 游戏中
|
||||||
|
PAUSED, # 暂停
|
||||||
|
SETTINGS # 设置
|
||||||
|
}
|
||||||
|
|
||||||
|
var current_state: GameState = GameState.LOADING
|
||||||
|
var previous_state: GameState = GameState.LOADING
|
||||||
|
var current_user: String = ""
|
||||||
|
var game_version: String = "1.0.0"
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("GameManager 初始化完成")
|
||||||
|
change_state(GameState.AUTH)
|
||||||
|
|
||||||
|
func change_state(new_state: GameState):
|
||||||
|
if current_state == new_state:
|
||||||
|
return
|
||||||
|
|
||||||
|
previous_state = current_state
|
||||||
|
current_state = new_state
|
||||||
|
|
||||||
|
print("游戏状态变更: ", GameState.keys()[previous_state], " -> ", GameState.keys()[current_state])
|
||||||
|
game_state_changed.emit(new_state)
|
||||||
|
|
||||||
|
func get_current_state() -> GameState:
|
||||||
|
return current_state
|
||||||
|
|
||||||
|
func get_previous_state() -> GameState:
|
||||||
|
return previous_state
|
||||||
|
|
||||||
|
func set_current_user(username: String):
|
||||||
|
current_user = username
|
||||||
|
print("当前用户设置为: ", username)
|
||||||
|
|
||||||
|
func get_current_user() -> String:
|
||||||
|
return current_user
|
||||||
|
|
||||||
|
func is_user_logged_in() -> bool:
|
||||||
|
return not current_user.is_empty()
|
||||||
1
_Core/managers/GameManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cd8fn73ysjxh8
|
||||||
443
_Core/managers/NetworkManager.gd
Normal file
@@ -0,0 +1,443 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# 网络请求管理器 - 统一处理所有HTTP请求
|
||||||
|
|
||||||
|
# 信号定义
|
||||||
|
signal request_completed(request_id: String, success: bool, data: Dictionary)
|
||||||
|
signal request_failed(request_id: String, error_type: String, message: String)
|
||||||
|
|
||||||
|
# API配置
|
||||||
|
const API_BASE_URL = "https://whaletownend.xinghangee.icu"
|
||||||
|
const DEFAULT_TIMEOUT = 30.0
|
||||||
|
|
||||||
|
# 请求类型枚举
|
||||||
|
enum RequestType {
|
||||||
|
GET,
|
||||||
|
POST,
|
||||||
|
PUT,
|
||||||
|
DELETE,
|
||||||
|
PATCH
|
||||||
|
}
|
||||||
|
|
||||||
|
# 错误类型枚举
|
||||||
|
enum ErrorType {
|
||||||
|
NETWORK_ERROR, # 网络连接错误
|
||||||
|
TIMEOUT_ERROR, # 请求超时
|
||||||
|
PARSE_ERROR, # JSON解析错误
|
||||||
|
HTTP_ERROR, # HTTP状态码错误
|
||||||
|
BUSINESS_ERROR # 业务逻辑错误
|
||||||
|
}
|
||||||
|
|
||||||
|
# 请求状态
|
||||||
|
class RequestInfo:
|
||||||
|
var id: String
|
||||||
|
var url: String
|
||||||
|
var method: RequestType
|
||||||
|
var headers: PackedStringArray
|
||||||
|
var body: String
|
||||||
|
var timeout: float
|
||||||
|
var start_time: float
|
||||||
|
var http_request: HTTPRequest
|
||||||
|
var callback: Callable
|
||||||
|
|
||||||
|
func _init(request_id: String, request_url: String, request_method: RequestType,
|
||||||
|
request_headers: PackedStringArray = [], request_body: String = "",
|
||||||
|
request_timeout: float = DEFAULT_TIMEOUT):
|
||||||
|
id = request_id
|
||||||
|
url = request_url
|
||||||
|
method = request_method
|
||||||
|
headers = request_headers
|
||||||
|
body = request_body
|
||||||
|
timeout = request_timeout
|
||||||
|
start_time = Time.get_time_dict_from_system().hour * 3600 + Time.get_time_dict_from_system().minute * 60 + Time.get_time_dict_from_system().second
|
||||||
|
|
||||||
|
# 活动请求管理
|
||||||
|
var active_requests: Dictionary = {}
|
||||||
|
var request_counter: int = 0
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("NetworkManager 已初始化")
|
||||||
|
|
||||||
|
# ============ 公共API接口 ============
|
||||||
|
|
||||||
|
# 发送GET请求
|
||||||
|
func get_request(endpoint: String, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
|
||||||
|
return send_request(endpoint, RequestType.GET, [], "", callback, timeout)
|
||||||
|
|
||||||
|
# 发送POST请求
|
||||||
|
func post_request(endpoint: String, data: Dictionary, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
|
||||||
|
var body = JSON.stringify(data)
|
||||||
|
var headers = ["Content-Type: application/json"]
|
||||||
|
return send_request(endpoint, RequestType.POST, headers, body, callback, timeout)
|
||||||
|
|
||||||
|
# 发送PUT请求
|
||||||
|
func put_request(endpoint: String, data: Dictionary, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
|
||||||
|
var body = JSON.stringify(data)
|
||||||
|
var headers = ["Content-Type: application/json"]
|
||||||
|
return send_request(endpoint, RequestType.PUT, headers, body, callback, timeout)
|
||||||
|
|
||||||
|
# 发送DELETE请求
|
||||||
|
func delete_request(endpoint: String, callback: Callable = Callable(), timeout: float = DEFAULT_TIMEOUT) -> String:
|
||||||
|
return send_request(endpoint, RequestType.DELETE, [], "", callback, timeout)
|
||||||
|
|
||||||
|
# ============ 认证相关API ============
|
||||||
|
|
||||||
|
# 用户登录
|
||||||
|
func login(identifier: String, password: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"identifier": identifier,
|
||||||
|
"password": password
|
||||||
|
}
|
||||||
|
return post_request("/auth/login", data, callback)
|
||||||
|
|
||||||
|
# 验证码登录
|
||||||
|
func verification_code_login(identifier: String, verification_code: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"identifier": identifier,
|
||||||
|
"verification_code": verification_code
|
||||||
|
}
|
||||||
|
return post_request("/auth/verification-code-login", data, callback)
|
||||||
|
|
||||||
|
# 发送登录验证码
|
||||||
|
func send_login_verification_code(identifier: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {"identifier": identifier}
|
||||||
|
return post_request("/auth/send-login-verification-code", data, callback)
|
||||||
|
|
||||||
|
# 用户注册
|
||||||
|
func register(username: String, password: String, nickname: String, email: String = "",
|
||||||
|
email_verification_code: String = "", callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"nickname": nickname
|
||||||
|
}
|
||||||
|
|
||||||
|
if email != "":
|
||||||
|
data["email"] = email
|
||||||
|
if email_verification_code != "":
|
||||||
|
data["email_verification_code"] = email_verification_code
|
||||||
|
|
||||||
|
return post_request("/auth/register", data, callback)
|
||||||
|
|
||||||
|
# 发送邮箱验证码
|
||||||
|
func send_email_verification(email: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {"email": email}
|
||||||
|
return post_request("/auth/send-email-verification", data, callback)
|
||||||
|
|
||||||
|
# 验证邮箱
|
||||||
|
func verify_email(email: String, verification_code: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"email": email,
|
||||||
|
"verification_code": verification_code
|
||||||
|
}
|
||||||
|
return post_request("/auth/verify-email", data, callback)
|
||||||
|
|
||||||
|
# 获取应用状态
|
||||||
|
func get_app_status(callback: Callable = Callable()) -> String:
|
||||||
|
return get_request("/", callback)
|
||||||
|
|
||||||
|
# 重新发送邮箱验证码
|
||||||
|
func resend_email_verification(email: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {"email": email}
|
||||||
|
return post_request("/auth/resend-email-verification", data, callback)
|
||||||
|
|
||||||
|
# 忘记密码 - 发送重置验证码
|
||||||
|
func forgot_password(identifier: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {"identifier": identifier}
|
||||||
|
return post_request("/auth/forgot-password", data, callback)
|
||||||
|
|
||||||
|
# 重置密码
|
||||||
|
func reset_password(identifier: String, verification_code: String, new_password: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"identifier": identifier,
|
||||||
|
"verification_code": verification_code,
|
||||||
|
"new_password": new_password
|
||||||
|
}
|
||||||
|
return post_request("/auth/reset-password", data, callback)
|
||||||
|
|
||||||
|
# 修改密码
|
||||||
|
func change_password(user_id: String, old_password: String, new_password: String, callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"user_id": user_id,
|
||||||
|
"old_password": old_password,
|
||||||
|
"new_password": new_password
|
||||||
|
}
|
||||||
|
return put_request("/auth/change-password", data, callback)
|
||||||
|
|
||||||
|
# GitHub OAuth登录
|
||||||
|
func github_login(github_id: String, username: String, nickname: String, email: String, avatar_url: String = "", callback: Callable = Callable()) -> String:
|
||||||
|
var data = {
|
||||||
|
"github_id": github_id,
|
||||||
|
"username": username,
|
||||||
|
"nickname": nickname,
|
||||||
|
"email": email
|
||||||
|
}
|
||||||
|
|
||||||
|
if avatar_url != "":
|
||||||
|
data["avatar_url"] = avatar_url
|
||||||
|
|
||||||
|
return post_request("/auth/github", data, callback)
|
||||||
|
|
||||||
|
# ============ 核心请求处理 ============
|
||||||
|
|
||||||
|
# 发送请求的核心方法
|
||||||
|
func send_request(endpoint: String, method: RequestType, headers: PackedStringArray,
|
||||||
|
body: String, callback: Callable, timeout: float) -> String:
|
||||||
|
# 生成请求ID
|
||||||
|
request_counter += 1
|
||||||
|
var request_id = "req_" + str(request_counter)
|
||||||
|
|
||||||
|
# 构建完整URL
|
||||||
|
var full_url = API_BASE_URL + endpoint
|
||||||
|
|
||||||
|
# 创建HTTPRequest节点
|
||||||
|
var http_request = HTTPRequest.new()
|
||||||
|
add_child(http_request)
|
||||||
|
|
||||||
|
# 设置超时
|
||||||
|
http_request.timeout = timeout
|
||||||
|
|
||||||
|
# 创建请求信息
|
||||||
|
var request_info = RequestInfo.new(request_id, full_url, method, headers, body, timeout)
|
||||||
|
request_info.http_request = http_request
|
||||||
|
request_info.callback = callback
|
||||||
|
|
||||||
|
# 存储请求信息
|
||||||
|
active_requests[request_id] = request_info
|
||||||
|
|
||||||
|
# 连接信号
|
||||||
|
http_request.request_completed.connect(func(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
|
||||||
|
_on_request_completed(request_id, result, response_code, headers, body)
|
||||||
|
)
|
||||||
|
|
||||||
|
# 发送请求
|
||||||
|
var godot_method = _convert_to_godot_method(method)
|
||||||
|
var error = http_request.request(full_url, headers, godot_method, body)
|
||||||
|
|
||||||
|
print("=== 发送网络请求 ===")
|
||||||
|
print("请求ID: ", request_id)
|
||||||
|
print("URL: ", full_url)
|
||||||
|
print("方法: ", RequestType.keys()[method])
|
||||||
|
print("Headers: ", headers)
|
||||||
|
print("Body: ", body if body.length() < 200 else body.substr(0, 200) + "...")
|
||||||
|
print("发送结果: ", error)
|
||||||
|
|
||||||
|
if error != OK:
|
||||||
|
print("请求发送失败,错误代码: ", error)
|
||||||
|
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络请求发送失败: " + str(error))
|
||||||
|
return ""
|
||||||
|
|
||||||
|
return request_id
|
||||||
|
|
||||||
|
# 请求完成回调
|
||||||
|
func _on_request_completed(request_id: String, result: int, response_code: int,
|
||||||
|
headers: PackedStringArray, body: PackedByteArray):
|
||||||
|
print("=== 网络请求完成 ===")
|
||||||
|
print("请求ID: ", request_id)
|
||||||
|
print("结果: ", result)
|
||||||
|
print("状态码: ", response_code)
|
||||||
|
print("响应头: ", headers)
|
||||||
|
|
||||||
|
# 获取请求信息
|
||||||
|
if not active_requests.has(request_id):
|
||||||
|
print("警告: 未找到请求ID ", request_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
var request_info = active_requests[request_id]
|
||||||
|
var response_text = body.get_string_from_utf8()
|
||||||
|
|
||||||
|
print("响应体长度: ", body.size(), " 字节")
|
||||||
|
print("响应内容: ", response_text if response_text.length() < 500 else response_text.substr(0, 500) + "...")
|
||||||
|
|
||||||
|
# 处理网络连接失败
|
||||||
|
if response_code == 0:
|
||||||
|
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络连接失败,请检查网络连接")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 解析JSON响应
|
||||||
|
var json = JSON.new()
|
||||||
|
var parse_result = json.parse(response_text)
|
||||||
|
if parse_result != OK:
|
||||||
|
_handle_request_error(request_id, ErrorType.PARSE_ERROR, "服务器响应格式错误")
|
||||||
|
return
|
||||||
|
|
||||||
|
var response_data = json.data
|
||||||
|
|
||||||
|
# 处理响应
|
||||||
|
_handle_response(request_id, response_code, response_data)
|
||||||
|
|
||||||
|
# 处理响应 - 支持API v1.1.1的状态码
|
||||||
|
func _handle_response(request_id: String, response_code: int, data: Dictionary):
|
||||||
|
var request_info = active_requests[request_id]
|
||||||
|
|
||||||
|
# 检查业务成功标志
|
||||||
|
var success = data.get("success", true) # 默认true保持向后兼容
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "")
|
||||||
|
|
||||||
|
# 判断请求是否成功
|
||||||
|
var is_success = false
|
||||||
|
|
||||||
|
# HTTP成功状态码且业务成功
|
||||||
|
if (response_code >= 200 and response_code < 300) and success:
|
||||||
|
is_success = true
|
||||||
|
# 特殊情况:206测试模式 - 根据API文档,这是成功的测试模式响应
|
||||||
|
elif response_code == 206 and error_code == "TEST_MODE_ONLY":
|
||||||
|
is_success = true
|
||||||
|
print("🧪 测试模式响应: ", message)
|
||||||
|
# 201创建成功
|
||||||
|
elif response_code == 201:
|
||||||
|
is_success = true
|
||||||
|
|
||||||
|
if is_success:
|
||||||
|
print("✅ 请求成功: ", request_id)
|
||||||
|
# 发送成功信号
|
||||||
|
request_completed.emit(request_id, true, data)
|
||||||
|
|
||||||
|
# 调用回调函数
|
||||||
|
if request_info.callback.is_valid():
|
||||||
|
request_info.callback.call(true, data, {})
|
||||||
|
else:
|
||||||
|
print("❌ 请求失败: ", request_id, " - HTTP:", response_code, " 错误码:", error_code, " 消息:", message)
|
||||||
|
|
||||||
|
# 确定错误类型
|
||||||
|
var error_type = _determine_error_type(response_code, error_code)
|
||||||
|
|
||||||
|
# 发送失败信号
|
||||||
|
request_failed.emit(request_id, ErrorType.keys()[error_type], message)
|
||||||
|
|
||||||
|
# 调用回调函数
|
||||||
|
if request_info.callback.is_valid():
|
||||||
|
var error_info = {
|
||||||
|
"response_code": response_code,
|
||||||
|
"error_code": error_code,
|
||||||
|
"message": message,
|
||||||
|
"error_type": error_type
|
||||||
|
}
|
||||||
|
request_info.callback.call(false, data, error_info)
|
||||||
|
|
||||||
|
# 清理请求
|
||||||
|
_cleanup_request(request_id)
|
||||||
|
|
||||||
|
# 处理请求错误
|
||||||
|
func _handle_request_error(request_id: String, error_type: ErrorType, message: String):
|
||||||
|
print("❌ 请求错误: ", request_id, " - ", message)
|
||||||
|
|
||||||
|
# 发送错误信号
|
||||||
|
request_failed.emit(request_id, ErrorType.keys()[error_type], message)
|
||||||
|
|
||||||
|
# 调用回调函数
|
||||||
|
if active_requests.has(request_id):
|
||||||
|
var request_info = active_requests[request_id]
|
||||||
|
if request_info.callback.is_valid():
|
||||||
|
var error_info = {
|
||||||
|
"error_type": error_type,
|
||||||
|
"message": message
|
||||||
|
}
|
||||||
|
request_info.callback.call(false, {}, error_info)
|
||||||
|
|
||||||
|
# 清理请求
|
||||||
|
_cleanup_request(request_id)
|
||||||
|
|
||||||
|
# 确定错误类型 - 支持更多状态码
|
||||||
|
func _determine_error_type(response_code: int, error_code: String) -> ErrorType:
|
||||||
|
# 根据错误码判断
|
||||||
|
match error_code:
|
||||||
|
"SERVICE_UNAVAILABLE":
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
"TOO_MANY_REQUESTS":
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
"TEST_MODE_ONLY":
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
"SEND_EMAIL_VERIFICATION_FAILED", "REGISTER_FAILED":
|
||||||
|
# 这些可能是409冲突或其他业务错误
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
_:
|
||||||
|
# 根据HTTP状态码判断
|
||||||
|
match response_code:
|
||||||
|
409: # 资源冲突
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
206: # 测试模式
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
429: # 频率限制
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
_:
|
||||||
|
if response_code >= 400 and response_code < 500:
|
||||||
|
return ErrorType.HTTP_ERROR
|
||||||
|
elif response_code >= 500:
|
||||||
|
return ErrorType.HTTP_ERROR
|
||||||
|
else:
|
||||||
|
return ErrorType.BUSINESS_ERROR
|
||||||
|
|
||||||
|
# 清理请求资源
|
||||||
|
func _cleanup_request(request_id: String):
|
||||||
|
if active_requests.has(request_id):
|
||||||
|
var request_info = active_requests[request_id]
|
||||||
|
|
||||||
|
# 移除HTTPRequest节点
|
||||||
|
if is_instance_valid(request_info.http_request):
|
||||||
|
request_info.http_request.queue_free()
|
||||||
|
|
||||||
|
# 从活动请求中移除
|
||||||
|
active_requests.erase(request_id)
|
||||||
|
|
||||||
|
print("🧹 清理请求: ", request_id)
|
||||||
|
|
||||||
|
# 转换请求方法
|
||||||
|
func _convert_to_godot_method(method: RequestType) -> HTTPClient.Method:
|
||||||
|
match method:
|
||||||
|
RequestType.GET:
|
||||||
|
return HTTPClient.METHOD_GET
|
||||||
|
RequestType.POST:
|
||||||
|
return HTTPClient.METHOD_POST
|
||||||
|
RequestType.PUT:
|
||||||
|
return HTTPClient.METHOD_PUT
|
||||||
|
RequestType.DELETE:
|
||||||
|
return HTTPClient.METHOD_DELETE
|
||||||
|
RequestType.PATCH:
|
||||||
|
return HTTPClient.METHOD_PATCH
|
||||||
|
_:
|
||||||
|
return HTTPClient.METHOD_GET
|
||||||
|
|
||||||
|
# ============ 工具方法 ============
|
||||||
|
|
||||||
|
# 取消请求
|
||||||
|
func cancel_request(request_id: String) -> bool:
|
||||||
|
if active_requests.has(request_id):
|
||||||
|
print("🚫 取消请求: ", request_id)
|
||||||
|
_cleanup_request(request_id)
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
# 取消所有请求
|
||||||
|
func cancel_all_requests():
|
||||||
|
print("🚫 取消所有请求")
|
||||||
|
var request_ids = active_requests.keys()
|
||||||
|
for request_id in request_ids:
|
||||||
|
cancel_request(request_id)
|
||||||
|
|
||||||
|
# 获取活动请求数量
|
||||||
|
func get_active_request_count() -> int:
|
||||||
|
return active_requests.size()
|
||||||
|
|
||||||
|
# 检查请求是否活动
|
||||||
|
func is_request_active(request_id: String) -> bool:
|
||||||
|
return active_requests.has(request_id)
|
||||||
|
|
||||||
|
# 获取请求信息
|
||||||
|
func get_request_info(request_id: String) -> Dictionary:
|
||||||
|
if active_requests.has(request_id):
|
||||||
|
var info = active_requests[request_id]
|
||||||
|
return {
|
||||||
|
"id": info.id,
|
||||||
|
"url": info.url,
|
||||||
|
"method": RequestType.keys()[info.method],
|
||||||
|
"start_time": info.start_time,
|
||||||
|
"timeout": info.timeout
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
func _notification(what):
|
||||||
|
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||||
|
# 应用关闭时取消所有请求
|
||||||
|
cancel_all_requests()
|
||||||
1
_Core/managers/NetworkManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dr7v30wheetca
|
||||||
590
_Core/managers/ResponseHandler.gd
Normal file
@@ -0,0 +1,590 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# 响应处理器 - 统一处理API响应和错误
|
||||||
|
|
||||||
|
# 响应处理结果
|
||||||
|
class ResponseResult:
|
||||||
|
var success: bool
|
||||||
|
var message: String
|
||||||
|
var toast_type: String # "success" 或 "error"
|
||||||
|
var data: Dictionary
|
||||||
|
var should_show_toast: bool
|
||||||
|
var custom_action: Callable
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
success = false
|
||||||
|
message = ""
|
||||||
|
toast_type = "error"
|
||||||
|
data = {}
|
||||||
|
should_show_toast = true
|
||||||
|
custom_action = Callable()
|
||||||
|
|
||||||
|
# 错误码映射表 - 根据API v1.1.1更新
|
||||||
|
const ERROR_CODE_MESSAGES = {
|
||||||
|
# 登录相关
|
||||||
|
"LOGIN_FAILED": "登录失败",
|
||||||
|
"VERIFICATION_CODE_LOGIN_FAILED": "验证码错误或已过期",
|
||||||
|
"EMAIL_NOT_VERIFIED": "请先验证邮箱",
|
||||||
|
|
||||||
|
# 注册相关
|
||||||
|
"REGISTER_FAILED": "注册失败",
|
||||||
|
|
||||||
|
# 验证码相关
|
||||||
|
"SEND_CODE_FAILED": "发送验证码失败",
|
||||||
|
"SEND_LOGIN_CODE_FAILED": "发送登录验证码失败",
|
||||||
|
"SEND_EMAIL_VERIFICATION_FAILED": "发送邮箱验证码失败",
|
||||||
|
"RESEND_EMAIL_VERIFICATION_FAILED": "重新发送验证码失败",
|
||||||
|
"EMAIL_VERIFICATION_FAILED": "邮箱验证失败",
|
||||||
|
"RESET_PASSWORD_FAILED": "重置密码失败",
|
||||||
|
"CHANGE_PASSWORD_FAILED": "修改密码失败",
|
||||||
|
"VERIFICATION_CODE_EXPIRED": "验证码已过期",
|
||||||
|
"VERIFICATION_CODE_INVALID": "验证码无效",
|
||||||
|
"VERIFICATION_CODE_ATTEMPTS_EXCEEDED": "验证码尝试次数过多",
|
||||||
|
"VERIFICATION_CODE_RATE_LIMITED": "验证码发送过于频繁",
|
||||||
|
"VERIFICATION_CODE_HOURLY_LIMIT": "验证码每小时发送次数已达上限",
|
||||||
|
|
||||||
|
# 用户状态相关
|
||||||
|
"USER_NOT_FOUND": "用户不存在",
|
||||||
|
"INVALID_IDENTIFIER": "请输入有效的邮箱或手机号",
|
||||||
|
"USER_STATUS_UPDATE_FAILED": "用户状态更新失败",
|
||||||
|
|
||||||
|
# 系统状态相关
|
||||||
|
"TEST_MODE_ONLY": "测试模式",
|
||||||
|
"TOO_MANY_REQUESTS": "请求过于频繁,请稍后再试",
|
||||||
|
"SERVICE_UNAVAILABLE": "系统维护中,请稍后再试",
|
||||||
|
|
||||||
|
# 权限相关
|
||||||
|
"UNAUTHORIZED": "未授权访问",
|
||||||
|
"FORBIDDEN": "权限不足",
|
||||||
|
"ADMIN_LOGIN_FAILED": "管理员登录失败",
|
||||||
|
|
||||||
|
# 其他
|
||||||
|
"VALIDATION_FAILED": "参数验证失败",
|
||||||
|
"UNSUPPORTED_MEDIA_TYPE": "不支持的请求格式",
|
||||||
|
"REQUEST_TIMEOUT": "请求超时"
|
||||||
|
}
|
||||||
|
|
||||||
|
# HTTP状态码消息映射 - 根据API v1.1.1更新
|
||||||
|
const HTTP_STATUS_MESSAGES = {
|
||||||
|
200: "请求成功",
|
||||||
|
201: "创建成功",
|
||||||
|
206: "测试模式",
|
||||||
|
400: "请求参数错误",
|
||||||
|
401: "认证失败",
|
||||||
|
403: "权限不足",
|
||||||
|
404: "资源不存在",
|
||||||
|
408: "请求超时",
|
||||||
|
409: "资源冲突",
|
||||||
|
415: "不支持的媒体类型",
|
||||||
|
429: "请求过于频繁",
|
||||||
|
500: "服务器内部错误",
|
||||||
|
503: "服务不可用"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============ 主要处理方法 ============
|
||||||
|
|
||||||
|
# 处理登录响应
|
||||||
|
static func handle_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "登录成功!正在进入鲸鱼镇..."
|
||||||
|
result.toast_type = "success"
|
||||||
|
result.data = data
|
||||||
|
|
||||||
|
# 自定义动作:延迟发送登录成功信号
|
||||||
|
result.custom_action = func():
|
||||||
|
await Engine.get_main_loop().create_timer(1.0).timeout
|
||||||
|
# 这里可以发送登录成功信号或执行其他逻辑
|
||||||
|
else:
|
||||||
|
result = _handle_login_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理验证码登录响应
|
||||||
|
static func handle_verification_code_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "验证码登录成功!正在进入鲸鱼镇..."
|
||||||
|
result.toast_type = "success"
|
||||||
|
result.data = data
|
||||||
|
|
||||||
|
result.custom_action = func():
|
||||||
|
await Engine.get_main_loop().create_timer(1.0).timeout
|
||||||
|
# 登录成功后的处理逻辑
|
||||||
|
else:
|
||||||
|
result = _handle_verification_code_login_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理发送验证码响应 - 支持邮箱冲突检测
|
||||||
|
static func handle_send_verification_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
if error_code == "TEST_MODE_ONLY":
|
||||||
|
result.success = true
|
||||||
|
result.message = "🧪 测试模式:验证码已生成,请查看控制台"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
# 在控制台显示验证码
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 测试模式验证码: ", data.data.verification_code)
|
||||||
|
result.message += "\n验证码: " + str(data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result.success = true
|
||||||
|
result.message = "📧 验证码已发送到您的邮箱,请查收"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
# 开发环境下显示验证码
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 开发环境验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result = _handle_send_code_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理发送登录验证码响应
|
||||||
|
static func handle_send_login_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
if error_code == "TEST_MODE_ONLY":
|
||||||
|
result.success = true
|
||||||
|
result.message = "测试模式:登录验证码已生成,请查看控制台"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("测试模式登录验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result.success = true
|
||||||
|
result.message = "登录验证码已发送,请查收"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("开发环境登录验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result = _handle_send_login_code_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理注册响应
|
||||||
|
static func handle_register_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "注册成功!欢迎加入鲸鱼镇"
|
||||||
|
result.toast_type = "success"
|
||||||
|
result.data = data
|
||||||
|
|
||||||
|
# 自定义动作:清空表单,切换到登录界面
|
||||||
|
result.custom_action = func():
|
||||||
|
# 这里可以执行清空表单、切换界面等操作
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
result = _handle_register_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理邮箱验证响应
|
||||||
|
static func handle_verify_email_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "邮箱验证成功,正在注册..."
|
||||||
|
result.toast_type = "success"
|
||||||
|
result.data = data
|
||||||
|
else:
|
||||||
|
result = _handle_verify_email_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理重新发送邮箱验证码响应
|
||||||
|
static func handle_resend_email_verification_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
if error_code == "TEST_MODE_ONLY":
|
||||||
|
result.success = true
|
||||||
|
result.message = "🧪 测试模式:验证码已重新生成,请查看控制台"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 测试模式重新发送验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result.success = true
|
||||||
|
result.message = "📧 验证码已重新发送到您的邮箱,请查收"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 开发环境重新发送验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result = _handle_resend_email_verification_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理忘记密码响应
|
||||||
|
static func handle_forgot_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
if error_code == "TEST_MODE_ONLY":
|
||||||
|
result.success = true
|
||||||
|
result.message = "🧪 测试模式:重置验证码已生成,请查看控制台"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 测试模式重置验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result.success = true
|
||||||
|
result.message = "📧 重置验证码已发送,请查收"
|
||||||
|
result.toast_type = "success"
|
||||||
|
|
||||||
|
if data.has("data") and data.data.has("verification_code"):
|
||||||
|
print("🔑 开发环境重置验证码: ", data.data.verification_code)
|
||||||
|
else:
|
||||||
|
result = _handle_forgot_password_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理重置密码响应
|
||||||
|
static func handle_reset_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "🔒 密码重置成功,请使用新密码登录"
|
||||||
|
result.toast_type = "success"
|
||||||
|
result.data = data
|
||||||
|
else:
|
||||||
|
result = _handle_reset_password_error(data, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# ============ 错误处理方法 ============
|
||||||
|
|
||||||
|
# 处理登录错误
|
||||||
|
static func _handle_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "登录失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"LOGIN_FAILED":
|
||||||
|
# 根据消息内容进一步判断用户状态
|
||||||
|
if "账户已锁定" in message or "locked" in message.to_lower():
|
||||||
|
result.message = "账户已被锁定,请联系管理员"
|
||||||
|
elif "账户已禁用" in message or "banned" in message.to_lower():
|
||||||
|
result.message = "账户已被禁用,请联系管理员"
|
||||||
|
elif "账户待审核" in message or "pending" in message.to_lower():
|
||||||
|
result.message = "账户待审核,请等待管理员审核"
|
||||||
|
elif "邮箱未验证" in message or "inactive" in message.to_lower():
|
||||||
|
result.message = "请先验证邮箱后再登录"
|
||||||
|
else:
|
||||||
|
result.message = "用户名或密码错误,请检查后重试"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理验证码登录错误
|
||||||
|
static func _handle_verification_code_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "验证码登录失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"VERIFICATION_CODE_LOGIN_FAILED":
|
||||||
|
result.message = "验证码错误或已过期"
|
||||||
|
"EMAIL_NOT_VERIFIED":
|
||||||
|
result.message = "邮箱未验证,请先验证邮箱后再使用验证码登录"
|
||||||
|
"USER_NOT_FOUND":
|
||||||
|
result.message = "用户不存在,请先注册"
|
||||||
|
"INVALID_IDENTIFIER":
|
||||||
|
result.message = "请输入有效的邮箱或手机号"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理发送验证码错误 - 支持邮箱冲突检测和频率限制
|
||||||
|
static func _handle_send_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "发送验证码失败")
|
||||||
|
var response_code = error_info.get("response_code", 0)
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"SEND_EMAIL_VERIFICATION_FAILED":
|
||||||
|
# 检查是否是邮箱冲突(409状态码)
|
||||||
|
if response_code == 409:
|
||||||
|
result.message = "⚠️ 邮箱已被注册,请使用其他邮箱或直接登录"
|
||||||
|
result.toast_type = "error"
|
||||||
|
elif "邮箱格式" in message:
|
||||||
|
result.message = "📧 请输入有效的邮箱地址"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
"TOO_MANY_REQUESTS":
|
||||||
|
# 处理频率限制,提供重试建议
|
||||||
|
result.toast_type = "error"
|
||||||
|
|
||||||
|
# 如果有throttle_info,显示更详细的信息
|
||||||
|
if data.has("throttle_info"):
|
||||||
|
var throttle_info = data.throttle_info
|
||||||
|
var reset_time = throttle_info.get("reset_time", "")
|
||||||
|
if reset_time != "":
|
||||||
|
var relative_time = StringUtils.get_relative_time_until(reset_time)
|
||||||
|
var local_time = StringUtils.format_utc_to_local_time(reset_time)
|
||||||
|
result.message = "⏰ 验证码发送过于频繁"
|
||||||
|
result.message += "\n请" + relative_time + "再试"
|
||||||
|
result.message += "\n重试时间: " + local_time
|
||||||
|
else:
|
||||||
|
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
|
||||||
|
else:
|
||||||
|
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
|
||||||
|
"VERIFICATION_CODE_RATE_LIMITED":
|
||||||
|
result.message = "⏰ 验证码发送过于频繁,请稍后再试"
|
||||||
|
"VERIFICATION_CODE_HOURLY_LIMIT":
|
||||||
|
result.message = "⏰ 每小时发送次数已达上限,请稍后再试"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理发送登录验证码错误
|
||||||
|
static func _handle_send_login_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "发送登录验证码失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"SEND_LOGIN_CODE_FAILED":
|
||||||
|
if "用户不存在" in message:
|
||||||
|
result.message = "用户不存在,请先注册"
|
||||||
|
else:
|
||||||
|
result.message = "发送登录验证码失败"
|
||||||
|
"USER_NOT_FOUND":
|
||||||
|
result.message = "用户不存在,请先注册"
|
||||||
|
"INVALID_IDENTIFIER":
|
||||||
|
result.message = "请输入有效的邮箱或手机号"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理注册错误 - 支持409冲突状态码
|
||||||
|
static func _handle_register_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "注册失败")
|
||||||
|
var response_code = error_info.get("response_code", 0)
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"REGISTER_FAILED":
|
||||||
|
# 检查409冲突状态码
|
||||||
|
if response_code == 409:
|
||||||
|
if "邮箱已存在" in message or "邮箱已被使用" in message:
|
||||||
|
result.message = "📧 邮箱已被注册,请使用其他邮箱或直接登录"
|
||||||
|
elif "用户名已存在" in message or "用户名已被使用" in message:
|
||||||
|
result.message = "👤 用户名已被使用,请换一个"
|
||||||
|
else:
|
||||||
|
result.message = "⚠️ 资源冲突:" + message
|
||||||
|
elif "邮箱验证码" in message or "verification_code" in message:
|
||||||
|
result.message = "🔑 请先获取并输入邮箱验证码"
|
||||||
|
elif "用户名" in message:
|
||||||
|
result.message = "👤 用户名格式不正确"
|
||||||
|
elif "邮箱" in message:
|
||||||
|
result.message = "📧 邮箱格式不正确"
|
||||||
|
elif "密码" in message:
|
||||||
|
result.message = "🔒 密码格式不符合要求"
|
||||||
|
elif "验证码" in message:
|
||||||
|
result.message = "🔑 验证码错误或已过期"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理邮箱验证错误
|
||||||
|
static func _handle_verify_email_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "邮箱验证失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"EMAIL_VERIFICATION_FAILED":
|
||||||
|
if "验证码错误" in message:
|
||||||
|
result.message = "🔑 验证码错误"
|
||||||
|
elif "验证码已过期" in message:
|
||||||
|
result.message = "🔑 验证码已过期,请重新获取"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
"VERIFICATION_CODE_INVALID":
|
||||||
|
result.message = "🔑 验证码错误或已过期"
|
||||||
|
"VERIFICATION_CODE_EXPIRED":
|
||||||
|
result.message = "🔑 验证码已过期,请重新获取"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理网络测试响应
|
||||||
|
static func handle_network_test_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "🌐 网络连接正常"
|
||||||
|
result.toast_type = "success"
|
||||||
|
else:
|
||||||
|
result.success = false
|
||||||
|
result.message = "🌐 网络连接异常"
|
||||||
|
result.toast_type = "error"
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理重新发送邮箱验证码错误
|
||||||
|
static func _handle_resend_email_verification_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "重新发送验证码失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"RESEND_EMAIL_VERIFICATION_FAILED":
|
||||||
|
if "邮箱已验证" in message:
|
||||||
|
result.message = "📧 邮箱已验证,无需重复验证"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理忘记密码错误
|
||||||
|
static func _handle_forgot_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "发送重置验证码失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"SEND_CODE_FAILED":
|
||||||
|
if "用户不存在" in message:
|
||||||
|
result.message = "👤 用户不存在,请检查邮箱或手机号"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
"USER_NOT_FOUND":
|
||||||
|
result.message = "👤 用户不存在,请检查邮箱或手机号"
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 处理重置密码错误
|
||||||
|
static func _handle_reset_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
var error_code = data.get("error_code", "")
|
||||||
|
var message = data.get("message", "重置密码失败")
|
||||||
|
|
||||||
|
match error_code:
|
||||||
|
"RESET_PASSWORD_FAILED":
|
||||||
|
if "验证码" in message:
|
||||||
|
result.message = "🔑 验证码错误或已过期"
|
||||||
|
else:
|
||||||
|
result.message = message
|
||||||
|
_:
|
||||||
|
result.message = _get_error_message(error_code, message, error_info)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# ============ 工具方法 ============
|
||||||
|
|
||||||
|
# 获取错误消息 - 支持更多状态码和错误处理
|
||||||
|
static func _get_error_message(error_code: String, original_message: String, error_info: Dictionary) -> String:
|
||||||
|
# 优先使用错误码映射
|
||||||
|
if ERROR_CODE_MESSAGES.has(error_code):
|
||||||
|
return ERROR_CODE_MESSAGES[error_code]
|
||||||
|
|
||||||
|
# 处理频率限制
|
||||||
|
if error_code == "TOO_MANY_REQUESTS":
|
||||||
|
return _handle_rate_limit_message(original_message, error_info)
|
||||||
|
|
||||||
|
# 处理维护模式
|
||||||
|
if error_code == "SERVICE_UNAVAILABLE":
|
||||||
|
return _handle_maintenance_message(original_message, error_info)
|
||||||
|
|
||||||
|
# 处理测试模式
|
||||||
|
if error_code == "TEST_MODE_ONLY":
|
||||||
|
return "🧪 测试模式:" + original_message
|
||||||
|
|
||||||
|
# 根据HTTP状态码处理
|
||||||
|
if error_info.has("response_code"):
|
||||||
|
var response_code = error_info.response_code
|
||||||
|
match response_code:
|
||||||
|
409:
|
||||||
|
return "⚠️ 资源冲突:" + original_message
|
||||||
|
206:
|
||||||
|
return "🧪 测试模式:" + original_message
|
||||||
|
429:
|
||||||
|
return "⏰ 请求过于频繁,请稍后再试"
|
||||||
|
_:
|
||||||
|
if HTTP_STATUS_MESSAGES.has(response_code):
|
||||||
|
return HTTP_STATUS_MESSAGES[response_code] + ":" + original_message
|
||||||
|
|
||||||
|
# 返回原始消息
|
||||||
|
return original_message if original_message != "" else "操作失败"
|
||||||
|
|
||||||
|
# 处理频率限制消息
|
||||||
|
static func _handle_rate_limit_message(message: String, error_info: Dictionary) -> String:
|
||||||
|
# 可以根据throttle_info提供更详细的信息
|
||||||
|
return message + ",请稍后再试"
|
||||||
|
|
||||||
|
# 处理维护模式消息
|
||||||
|
static func _handle_maintenance_message(message: String, error_info: Dictionary) -> String:
|
||||||
|
# 可以根据maintenance_info提供更详细的信息
|
||||||
|
return "系统维护中,请稍后再试"
|
||||||
|
|
||||||
|
# 通用响应处理器 - 支持更多操作类型
|
||||||
|
static func handle_response(operation_type: String, success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||||
|
match operation_type:
|
||||||
|
"login":
|
||||||
|
return handle_login_response(success, data, error_info)
|
||||||
|
"verification_code_login":
|
||||||
|
return handle_verification_code_login_response(success, data, error_info)
|
||||||
|
"send_code":
|
||||||
|
return handle_send_verification_code_response(success, data, error_info)
|
||||||
|
"send_login_code":
|
||||||
|
return handle_send_login_code_response(success, data, error_info)
|
||||||
|
"register":
|
||||||
|
return handle_register_response(success, data, error_info)
|
||||||
|
"verify_email":
|
||||||
|
return handle_verify_email_response(success, data, error_info)
|
||||||
|
"resend_email_verification":
|
||||||
|
return handle_resend_email_verification_response(success, data, error_info)
|
||||||
|
"forgot_password":
|
||||||
|
return handle_forgot_password_response(success, data, error_info)
|
||||||
|
"reset_password":
|
||||||
|
return handle_reset_password_response(success, data, error_info)
|
||||||
|
"network_test":
|
||||||
|
return handle_network_test_response(success, data, error_info)
|
||||||
|
_:
|
||||||
|
# 通用处理
|
||||||
|
var result = ResponseResult.new()
|
||||||
|
if success:
|
||||||
|
result.success = true
|
||||||
|
result.message = "✅ 操作成功"
|
||||||
|
result.toast_type = "success"
|
||||||
|
else:
|
||||||
|
result.success = false
|
||||||
|
result.message = _get_error_message(data.get("error_code", ""), data.get("message", "操作失败"), error_info)
|
||||||
|
result.toast_type = "error"
|
||||||
|
return result
|
||||||
1
_Core/managers/ResponseHandler.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://nseguk2ytiw6
|
||||||
75
_Core/managers/SceneManager.gd
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# 场景管理器 - 负责场景切换和管理
|
||||||
|
# 提供场景切换的统一接口
|
||||||
|
|
||||||
|
signal scene_changed(scene_name: String)
|
||||||
|
signal scene_change_started(scene_name: String)
|
||||||
|
|
||||||
|
var current_scene_name: String = ""
|
||||||
|
var is_changing_scene: bool = false
|
||||||
|
|
||||||
|
# 场景路径映射
|
||||||
|
var scene_paths: Dictionary = {
|
||||||
|
"main": "res://Scenes/Maps/main_scene.tscn",
|
||||||
|
"auth": "res://UI/Windows/LoginWindow.tscn",
|
||||||
|
"game": "res://Scenes/Maps/game_scene.tscn",
|
||||||
|
"battle": "res://Scenes/Maps/battle_scene.tscn",
|
||||||
|
"inventory": "res://UI/Windows/InventoryWindow.tscn",
|
||||||
|
"shop": "res://UI/Windows/ShopWindow.tscn",
|
||||||
|
"settings": "res://UI/Windows/SettingsWindow.tscn"
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("SceneManager 初始化完成")
|
||||||
|
|
||||||
|
func change_scene(scene_name: String, use_transition: bool = true):
|
||||||
|
if is_changing_scene:
|
||||||
|
print("场景切换中,忽略新的切换请求")
|
||||||
|
return false
|
||||||
|
|
||||||
|
if not scene_paths.has(scene_name):
|
||||||
|
print("错误: 未找到场景 ", scene_name)
|
||||||
|
return false
|
||||||
|
|
||||||
|
var scene_path = scene_paths[scene_name]
|
||||||
|
print("开始切换场景: ", current_scene_name, " -> ", scene_name)
|
||||||
|
|
||||||
|
is_changing_scene = true
|
||||||
|
scene_change_started.emit(scene_name)
|
||||||
|
|
||||||
|
if use_transition:
|
||||||
|
await show_transition()
|
||||||
|
|
||||||
|
var error = get_tree().change_scene_to_file(scene_path)
|
||||||
|
if error != OK:
|
||||||
|
print("场景切换失败: ", error)
|
||||||
|
is_changing_scene = false
|
||||||
|
return false
|
||||||
|
|
||||||
|
current_scene_name = scene_name
|
||||||
|
is_changing_scene = false
|
||||||
|
scene_changed.emit(scene_name)
|
||||||
|
|
||||||
|
if use_transition:
|
||||||
|
await hide_transition()
|
||||||
|
|
||||||
|
print("场景切换完成: ", scene_name)
|
||||||
|
return true
|
||||||
|
|
||||||
|
func get_current_scene_name() -> String:
|
||||||
|
return current_scene_name
|
||||||
|
|
||||||
|
func register_scene(scene_name: String, scene_path: String):
|
||||||
|
scene_paths[scene_name] = scene_path
|
||||||
|
print("注册场景: ", scene_name, " -> ", scene_path)
|
||||||
|
|
||||||
|
func show_transition():
|
||||||
|
# TODO: 实现场景切换过渡效果
|
||||||
|
print("显示场景切换过渡效果")
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
|
||||||
|
func hide_transition():
|
||||||
|
# TODO: 隐藏场景切换过渡效果
|
||||||
|
print("隐藏场景切换过渡效果")
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
1
_Core/managers/SceneManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://d3l286ti5gqhw
|
||||||
80
_Core/systems/EventSystem.gd
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# 全局事件系统 - 提供解耦的事件通信机制
|
||||||
|
# 允许不同模块之间通过事件进行通信,避免直接依赖
|
||||||
|
|
||||||
|
# 事件监听器存储
|
||||||
|
var event_listeners: Dictionary = {}
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("EventSystem 初始化完成")
|
||||||
|
|
||||||
|
# 注册事件监听器
|
||||||
|
func connect_event(event_name: String, callback: Callable, target: Node = null):
|
||||||
|
if not event_listeners.has(event_name):
|
||||||
|
event_listeners[event_name] = []
|
||||||
|
|
||||||
|
var listener_info = {
|
||||||
|
"callback": callback,
|
||||||
|
"target": target
|
||||||
|
}
|
||||||
|
|
||||||
|
event_listeners[event_name].append(listener_info)
|
||||||
|
print("注册事件监听器: ", event_name, " -> ", callback)
|
||||||
|
|
||||||
|
# 移除事件监听器
|
||||||
|
func disconnect_event(event_name: String, callback: Callable, target: Node = null):
|
||||||
|
if not event_listeners.has(event_name):
|
||||||
|
return
|
||||||
|
|
||||||
|
var listeners = event_listeners[event_name]
|
||||||
|
for i in range(listeners.size() - 1, -1, -1):
|
||||||
|
var listener = listeners[i]
|
||||||
|
if listener.callback == callback and listener.target == target:
|
||||||
|
listeners.remove_at(i)
|
||||||
|
print("移除事件监听器: ", event_name, " -> ", callback)
|
||||||
|
break
|
||||||
|
|
||||||
|
# 发送事件
|
||||||
|
func emit_event(event_name: String, data: Variant = null):
|
||||||
|
print("发送事件: ", event_name, " 数据: ", data)
|
||||||
|
|
||||||
|
if not event_listeners.has(event_name):
|
||||||
|
return
|
||||||
|
|
||||||
|
var listeners = event_listeners[event_name]
|
||||||
|
for listener_info in listeners:
|
||||||
|
var target = listener_info.target
|
||||||
|
var callback = listener_info.callback
|
||||||
|
|
||||||
|
# 检查目标节点是否仍然有效
|
||||||
|
if target != null and not is_instance_valid(target):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 调用回调函数
|
||||||
|
if data != null:
|
||||||
|
callback.call(data)
|
||||||
|
else:
|
||||||
|
callback.call()
|
||||||
|
|
||||||
|
# 清理无效的监听器
|
||||||
|
func cleanup_invalid_listeners():
|
||||||
|
for event_name in event_listeners.keys():
|
||||||
|
var listeners = event_listeners[event_name]
|
||||||
|
for i in range(listeners.size() - 1, -1, -1):
|
||||||
|
var listener = listeners[i]
|
||||||
|
var target = listener.target
|
||||||
|
if target != null and not is_instance_valid(target):
|
||||||
|
listeners.remove_at(i)
|
||||||
|
print("清理无效监听器: ", event_name)
|
||||||
|
|
||||||
|
# 获取事件监听器数量
|
||||||
|
func get_listener_count(event_name: String) -> int:
|
||||||
|
if not event_listeners.has(event_name):
|
||||||
|
return 0
|
||||||
|
return event_listeners[event_name].size()
|
||||||
|
|
||||||
|
# 清空所有事件监听器
|
||||||
|
func clear_all_listeners():
|
||||||
|
event_listeners.clear()
|
||||||
|
print("清空所有事件监听器")
|
||||||
1
_Core/systems/EventSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bfheblucmti24
|
||||||
1
assets/audio/audio/music/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 音乐资源目录
|
||||||
1
assets/audio/audio/sounds/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 音效资源目录
|
||||||
1
assets/audio/audio/voice/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 语音资源目录
|
||||||
1
assets/audio/music/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 音乐资源目录
|
||||||
1
assets/audio/sounds/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 音效资源目录
|
||||||
1
assets/audio/voice/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 语音资源目录
|
||||||
1
assets/fonts/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 字体资源目录
|
||||||
BIN
assets/fonts/msyh.ttc
Normal file
41
assets/fonts/msyh.ttc.import
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://ce7ujbeobblyr"
|
||||||
|
path="res://.godot/imported/msyh.ttc-1f7944f6d1cff8092894a3525ec5156c.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/fonts/msyh.ttc"
|
||||||
|
dest_files=["res://.godot/imported/msyh.ttc-1f7944f6d1cff8092894a3525ec5156c.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
modulate_color_glyphs=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=false
|
||||||
|
preload=[{
|
||||||
|
"chars": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=[]{}|;':\",./<>?`~一二三四五六七八九十百千万亿用户名密码登录注册验证码邮箱小镇鲸鱼欢迎来到开始你的之旅请输入不能为空获取发送忘记返回居民身份确认再次已被使用换个等待分钟后试稍后正在创建账户测试模式生成查看控制台网络连接失败系统维护中升级稍后再试频繁联系管理员禁用审核先邮箱后使用成功进入镇错误或过期未找到存在",
|
||||||
|
"glyphs": [],
|
||||||
|
"name": "Web预加载",
|
||||||
|
"size": Vector2i(16, 0)
|
||||||
|
}]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
||||||
BIN
assets/icon/icon144.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
40
assets/icon/icon144.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bwy5r7soxi76a"
|
||||||
|
path="res://.godot/imported/icon144.png-ae9d1f30a88beaab449c2cad89283dd3.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon144.png"
|
||||||
|
dest_files=["res://.godot/imported/icon144.png-ae9d1f30a88beaab449c2cad89283dd3.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/icon16.png
Normal file
|
After Width: | Height: | Size: 644 B |
40
assets/icon/icon16.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bqg5e8qn1j74u"
|
||||||
|
path="res://.godot/imported/icon16.png-3099ad8a609f90c382508b9c073ffd76.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon16.png"
|
||||||
|
dest_files=["res://.godot/imported/icon16.png-3099ad8a609f90c382508b9c073ffd76.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/icon180.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
40
assets/icon/icon180.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://drpllpsjdiaex"
|
||||||
|
path="res://.godot/imported/icon180.png-20a9d7b98bfb315dd470e3635f315a17.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon180.png"
|
||||||
|
dest_files=["res://.godot/imported/icon180.png-20a9d7b98bfb315dd470e3635f315a17.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/icon32.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
40
assets/icon/icon32.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dt24j6p0cijqo"
|
||||||
|
path="res://.godot/imported/icon32.png-9a0aceb23d191139c34540a188bf8c91.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon32.png"
|
||||||
|
dest_files=["res://.godot/imported/icon32.png-9a0aceb23d191139c34540a188bf8c91.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/icon512.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
40
assets/icon/icon512.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dt817lem3dwee"
|
||||||
|
path="res://.godot/imported/icon512.png-1c1c4b424489de87a542c89bec6eb15b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon512.png"
|
||||||
|
dest_files=["res://.godot/imported/icon512.png-1c1c4b424489de87a542c89bec6eb15b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/icon64.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
40
assets/icon/icon64.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ci42rd5qe6icl"
|
||||||
|
path="res://.godot/imported/icon64.png-da8a1a20e3bf4dcf06c8ff6c558caaff.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/icon64.png"
|
||||||
|
dest_files=["res://.godot/imported/icon64.png-da8a1a20e3bf4dcf06c8ff6c558caaff.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/image(1).png
Normal file
|
After Width: | Height: | Size: 150 KiB |
40
assets/icon/image(1).png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cnw6e3wmy0ea4"
|
||||||
|
path="res://.godot/imported/image(1).png-c89cc92103e50aaba40bf38c797be77f.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/image(1).png"
|
||||||
|
dest_files=["res://.godot/imported/image(1).png-c89cc92103e50aaba40bf38c797be77f.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/icon/image.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
40
assets/icon/image.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c7v22i1hgo1x6"
|
||||||
|
path="res://.godot/imported/image.png-3f16548595ba9fb08c5e50ef3251d148.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/icon/image.png"
|
||||||
|
dest_files=["res://.godot/imported/image.png-3f16548595ba9fb08c5e50ef3251d148.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
1
assets/materials/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 材质资源目录
|
||||||
1
assets/shaders/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 着色器资源目录
|
||||||
1
assets/sprites/characters/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 角色精灵资源目录
|
||||||
1
assets/sprites/effects/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 特效精灵资源目录
|
||||||
1
assets/sprites/environment/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 环境精灵资源目录
|
||||||
BIN
assets/sprites/icon/icon144.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
40
assets/sprites/icon/icon144.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bwy5r7soxi76a"
|
||||||
|
path="res://.godot/imported/icon144.png-27a33b914815b6d4af200572bfdaa6ff.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon144.png"
|
||||||
|
dest_files=["res://.godot/imported/icon144.png-27a33b914815b6d4af200572bfdaa6ff.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/icon16.png
Normal file
|
After Width: | Height: | Size: 644 B |
40
assets/sprites/icon/icon16.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bqg5e8qn1j74u"
|
||||||
|
path="res://.godot/imported/icon16.png-7cdae0838b274bb32361bfaa80a42a0f.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon16.png"
|
||||||
|
dest_files=["res://.godot/imported/icon16.png-7cdae0838b274bb32361bfaa80a42a0f.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/icon180.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
40
assets/sprites/icon/icon180.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://drpllpsjdiaex"
|
||||||
|
path="res://.godot/imported/icon180.png-1d6fc41d452b1d5b5b66c12dbeb9a657.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon180.png"
|
||||||
|
dest_files=["res://.godot/imported/icon180.png-1d6fc41d452b1d5b5b66c12dbeb9a657.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/icon32.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
40
assets/sprites/icon/icon32.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dt24j6p0cijqo"
|
||||||
|
path="res://.godot/imported/icon32.png-d677605f61a2a3a87d4018004b1f6aa4.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon32.png"
|
||||||
|
dest_files=["res://.godot/imported/icon32.png-d677605f61a2a3a87d4018004b1f6aa4.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/icon512.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
40
assets/sprites/icon/icon512.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dt817lem3dwee"
|
||||||
|
path="res://.godot/imported/icon512.png-5f7b6d37423049879d2db9cc5a9126f5.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon512.png"
|
||||||
|
dest_files=["res://.godot/imported/icon512.png-5f7b6d37423049879d2db9cc5a9126f5.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/icon64.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
40
assets/sprites/icon/icon64.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ci42rd5qe6icl"
|
||||||
|
path="res://.godot/imported/icon64.png-e3684ecc6e07cbb7b0527f9c18c4431a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/icon64.png"
|
||||||
|
dest_files=["res://.godot/imported/icon64.png-e3684ecc6e07cbb7b0527f9c18c4431a.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/image(1).png
Normal file
|
After Width: | Height: | Size: 150 KiB |
40
assets/sprites/icon/image(1).png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cnw6e3wmy0ea4"
|
||||||
|
path="res://.godot/imported/image(1).png-14ccba2bcca2f261c1c009e0a9e237f6.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/image(1).png"
|
||||||
|
dest_files=["res://.godot/imported/image(1).png-14ccba2bcca2f261c1c009e0a9e237f6.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/sprites/icon/image.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
40
assets/sprites/icon/image.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c7v22i1hgo1x6"
|
||||||
|
path="res://.godot/imported/image.png-409a48a8fb5774839179f1fee74603d2.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/sprites/icon/image.png"
|
||||||
|
dest_files=["res://.godot/imported/image.png-409a48a8fb5774839179f1fee74603d2.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
1
assets/sprites/materials/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 材质资源目录
|
||||||
1
assets/sprites/shaders/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 着色器资源目录
|
||||||
1
assets/sprites/sprites/characters/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 角色精灵资源目录
|
||||||
1
assets/sprites/sprites/effects/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 特效精灵资源目录
|
||||||
1
assets/sprites/sprites/environment/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# 保持目录结构 - 环境精灵资源目录
|
||||||
BIN
assets/ui/auth/bg_auth_scene.png
Normal file
|
After Width: | Height: | Size: 5.7 MiB |
40
assets/ui/auth/bg_auth_scene.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bx17oy8lvaca4"
|
||||||
|
path="res://.godot/imported/bg_auth_scene.png-818065fcc20397e855c75507c1313623.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/ui/auth/bg_auth_scene.png"
|
||||||
|
dest_files=["res://.godot/imported/bg_auth_scene.png-818065fcc20397e855c75507c1313623.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
assets/ui/auth/login_frame_smart_transparent.png
Normal file
|
After Width: | Height: | Size: 587 KiB |
40
assets/ui/auth/login_frame_smart_transparent.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://de4q4s1gxivtf"
|
||||||
|
path="res://.godot/imported/login_frame_smart_transparent.png-e5d0fd05b4713ddd3beae8223f2abb80.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/ui/auth/login_frame_smart_transparent.png"
|
||||||
|
dest_files=["res://.godot/imported/login_frame_smart_transparent.png-e5d0fd05b4713ddd3beae8223f2abb80.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
7
assets/ui/chinese_theme.tres
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cp7t8tu7rmyad"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://ce7ujbeobblyr" path="res://UI/Theme/Fonts/msyh.ttc" id="1_ftb5w"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
default_font = ExtResource("1_ftb5w")
|
||||||
BIN
assets/ui/datawhale_logo.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
40
assets/ui/datawhale_logo.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://gr7vud1lee4m"
|
||||||
|
path="res://.godot/imported/datawhale_logo.png-ddb5e2c04419eb84cfa8605bcbf64fbd.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/ui/datawhale_logo.png"
|
||||||
|
dest_files=["res://.godot/imported/datawhale_logo.png-ddb5e2c04419eb84cfa8605bcbf64fbd.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
123
cloude.md
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
# 🎯 WhaleTown 项目开发规范
|
||||||
|
|
||||||
|
## 1. 项目愿景与背景
|
||||||
|
- **项目名称**: "WhaleTown" - 一个2D俯视角像素风RPG游戏
|
||||||
|
- **引擎**: Godot 4.2+ (严格禁止使用Godot 3.x语法)
|
||||||
|
- **架构**: 严格分层架构:`_Core`(框架层)、`Scenes`(游戏层)、`UI`(界面层)
|
||||||
|
- **核心原则**: "信号向上,调用向下"。通过`EventSystem`实现高度解耦
|
||||||
|
|
||||||
|
## 2. 🛠 命令参考与设置
|
||||||
|
- **输入映射 (必需配置)**:
|
||||||
|
- `move_left`, `move_right`, `move_up`, `move_down` (WASD / 方向键)
|
||||||
|
- `interact` (E键 / 空格键)
|
||||||
|
- `pause` (ESC键)
|
||||||
|
- **运行游戏**: `godot --path .`
|
||||||
|
- **运行测试 (GUT)**: `godot --headless -s addons/gut/gut_cmdline.gd -gdir=res://tests/ -ginclude_subdirs`
|
||||||
|
- **初始化结构**: `mkdir -p _Core/managers _Core/systems Scenes/Maps Scenes/Entities Scenes/Components UI/Windows UI/HUD Assets/Sprites tests/unit tests/integration`
|
||||||
|
|
||||||
|
## 3. 📂 文件路径规则 (严格小写)
|
||||||
|
*注意:根目录文件夹必须小写。脚本和场景必须放在一起。*
|
||||||
|
- **核心管理器**: `_Core/managers/[Name].gd`
|
||||||
|
- **核心系统**: `_Core/systems/[Name].gd`
|
||||||
|
- **实体**: `Scenes/Entities/[EntityName]/[EntityName].tscn` (脚本`.gd`放在同一文件夹)
|
||||||
|
- **地图**: `Scenes/Maps/[map_name].tscn`
|
||||||
|
- **组件**: `Scenes/Components/[ComponentName].gd` (可复用逻辑节点)
|
||||||
|
- **UI窗口**: `UI/Windows/[WindowName].tscn`
|
||||||
|
- **测试**: `tests/[unit|integration]/test_[name].gd` (文件夹名为小写`tests`)
|
||||||
|
|
||||||
|
## 4. 📋 编码标准 (必须遵守)
|
||||||
|
- **类型安全**: 始终使用严格静态类型:`var speed: float = 100.0`, `func _ready() -> void`
|
||||||
|
- **命名约定**:
|
||||||
|
- 每个脚本顶部必须有`class_name PascalCase`
|
||||||
|
- 变量/函数:`snake_case`。常量:`SCREAMING_SNAKE_CASE`
|
||||||
|
- 私有成员:使用下划线前缀`_` (例如:`var _health: int`)
|
||||||
|
- **节点访问**: 对UI和内部场景组件使用`%UniqueName`
|
||||||
|
- **信号**: 使用"信号向上,调用向下"原则。父节点调用子节点方法;子节点发出信号
|
||||||
|
- **禁止模式**:
|
||||||
|
- ❌ 禁止使用`yield()` -> 使用`await`
|
||||||
|
- ❌ 禁止在`_process`中使用`get_node()` -> 使用`@onready`缓存
|
||||||
|
- ❌ 禁止线性过滤 -> 所有Sprite2D/TileMap资源必须使用**最近邻**过滤
|
||||||
|
|
||||||
|
## 5. 🏛 架构与通信
|
||||||
|
- **事件系统**: 使用`_Core/systems/EventSystem.gd`进行跨模块消息传递
|
||||||
|
- **事件注册**: 在`_Core/EventNames.gd`中使用`class_name EventNames`
|
||||||
|
```gdscript
|
||||||
|
class_name EventNames
|
||||||
|
const PLAYER_MOVED = "player_moved"
|
||||||
|
const INTERACT_PRESSED = "interact_pressed"
|
||||||
|
const NPC_TALKED = "npc_talked"
|
||||||
|
```
|
||||||
|
- **单例**: 只允许GameManager、SceneManager、EventSystem作为自动加载
|
||||||
|
- **解耦**: 底层实体不得直接引用GameManager。使用事件系统
|
||||||
|
|
||||||
|
## 6. 🏗 实现细节
|
||||||
|
- **玩家**: 使用CharacterBody2D。必须包含Camera2D,设置`position_smoothing_enabled = true`
|
||||||
|
- **NPC/交互物**: 使用名为InteractionArea的Area2D。通过EventSystem触发
|
||||||
|
- **TileMap图层**:
|
||||||
|
- 图层0:地面 (无碰撞)
|
||||||
|
- 图层1:障碍物 (启用物理层)
|
||||||
|
- 图层2:装饰 (启用Y排序)
|
||||||
|
- **相机**: 必须通过`TileMap.get_used_rect()`自动计算边界
|
||||||
|
|
||||||
|
## 7. 🧪 测试要求 (强制性)
|
||||||
|
- **覆盖率**: `_Core/`中的每个管理器/系统都必须有GUT测试
|
||||||
|
- **命名**: 测试文件必须以`test_`开头并继承`GutTest`
|
||||||
|
- **示例**:
|
||||||
|
```gdscript
|
||||||
|
extends GutTest
|
||||||
|
func test_event_emission():
|
||||||
|
var sender = Node.new()
|
||||||
|
watch_signals(EventSystem)
|
||||||
|
EventSystem.emit_event(EventNames.PLAYER_MOVED, {})
|
||||||
|
assert_signal_emitted(EventSystem, "event_raised")
|
||||||
|
```
|
||||||
|
|
||||||
|
## 8. 🧘 开发哲学
|
||||||
|
- **流畅体验**: 每个交互(UI弹窗、NPC对话)都必须有Tween动画占位符
|
||||||
|
- **零魔法数字**: 所有速度/计时器必须使用`@export`或在`Config/`中定义
|
||||||
|
- **简洁性**: 如果一个函数做两件事,就拆分它
|
||||||
|
- **隐藏逻辑**: 隐藏的逻辑(如ResponseHandler.gd)必须和HUD一样干净
|
||||||
|
|
||||||
|
## 9. 📝 代码模板 (实体模式)
|
||||||
|
```gdscript
|
||||||
|
extends CharacterBody2D
|
||||||
|
class_name Player
|
||||||
|
|
||||||
|
# 1. 导出变量与常量
|
||||||
|
@export var move_speed: float = 200.0
|
||||||
|
|
||||||
|
# 2. 节点引用
|
||||||
|
@onready var sprite: Sprite2D = %Sprite2D
|
||||||
|
|
||||||
|
# 3. 生命周期
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
_move(delta)
|
||||||
|
|
||||||
|
# 4. 私有方法
|
||||||
|
func _move(_delta: float) -> void:
|
||||||
|
var dir := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||||
|
velocity = dir * move_speed
|
||||||
|
move_and_slide()
|
||||||
|
```
|
||||||
|
|
||||||
|
## 10. 🎨 UI设计规范
|
||||||
|
- **响应式布局**: 使用Anchor和Margin实现自适应
|
||||||
|
- **主题统一**: 所有UI组件使用统一主题资源
|
||||||
|
- **动画效果**: 界面切换必须有过渡动画
|
||||||
|
- **无障碍支持**: 支持键盘导航
|
||||||
|
|
||||||
|
## 11. 🔧 性能优化
|
||||||
|
- **对象池**: 频繁创建销毁的对象使用对象池
|
||||||
|
- **视锥剔除**: 只渲染可见区域的对象
|
||||||
|
- **批量处理**: 合并相似的渲染调用
|
||||||
|
- **内存管理**: 及时释放不需要的资源
|
||||||
|
|
||||||
|
## 12. 📚 最佳实践
|
||||||
|
- **模块化**: 功能拆分为独立模块
|
||||||
|
- **可测试**: 设计易于测试的代码结构
|
||||||
|
- **文档化**: 为复杂逻辑添加详细注释
|
||||||
|
- **版本控制**: 遵循Git提交规范
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**记住:代码质量是游戏成功的基础!**
|
||||||
85
docs/01-项目入门/README.md
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
# 📖 项目入门
|
||||||
|
|
||||||
|
> **适用人群**: 新加入项目的开发者
|
||||||
|
> **使用时机**: 项目开始前,环境搭建阶段
|
||||||
|
> **质量等级**: A级 ⭐⭐⭐⭐⭐
|
||||||
|
|
||||||
|
这个目录包含了新人入门必读的基础文档,帮助你快速了解项目并搭建开发环境。
|
||||||
|
|
||||||
|
## 📋 阅读顺序
|
||||||
|
|
||||||
|
### 第一步:了解项目 🏗️
|
||||||
|
**[项目结构说明.md](项目结构说明.md)**
|
||||||
|
- 项目整体架构设计
|
||||||
|
- 目录组织规则和命名规范
|
||||||
|
- 各层级职责说明
|
||||||
|
- 核心组件介绍
|
||||||
|
|
||||||
|
### 第二步:配置环境 ⚙️
|
||||||
|
**[项目设置指南.md](项目设置指南.md)**
|
||||||
|
- Godot编辑器配置
|
||||||
|
- AutoLoad单例设置
|
||||||
|
- 输入映射配置(已预配置)
|
||||||
|
- 开发环境验证
|
||||||
|
|
||||||
|
## ✅ 完成检查
|
||||||
|
|
||||||
|
阅读完本目录的文档后,你应该能够:
|
||||||
|
- [ ] 理解项目的整体架构和设计理念
|
||||||
|
- [ ] 成功配置Godot开发环境
|
||||||
|
- [ ] 了解核心组件的作用和使用方式
|
||||||
|
- [ ] 运行项目并进行基本测试
|
||||||
|
- [ ] 验证所有AutoLoad单例正常工作
|
||||||
|
- [ ] 确认游戏输入控制正常响应
|
||||||
|
|
||||||
|
## 🎮 输入控制说明
|
||||||
|
|
||||||
|
项目已预配置以下输入映射:
|
||||||
|
- **移动控制**: `move_left` (A/←), `move_right` (D/→), `move_up` (W/↑), `move_down` (S/↓)
|
||||||
|
- **交互控制**: `interact` (E键), `jump` (空格键)
|
||||||
|
|
||||||
|
这些输入映射已经在 `project.godot` 中配置完成,无需额外设置。
|
||||||
|
|
||||||
|
## 🚨 常见启动问题
|
||||||
|
|
||||||
|
### 问题1: 游戏无法响应输入
|
||||||
|
**原因**: 项目文件损坏或配置丢失
|
||||||
|
**解决**: 重新克隆项目,确保 `project.godot` 文件完整
|
||||||
|
|
||||||
|
### 问题2: 控制台出现"Invalid action"错误
|
||||||
|
**原因**: 输入映射配置丢失
|
||||||
|
**解决**: 检查 `project.godot` 文件中的 `[input]` 部分是否完整
|
||||||
|
|
||||||
|
### 问题3: AutoLoad单例报错
|
||||||
|
**原因**: AutoLoad配置不正确或文件路径错误
|
||||||
|
**解决**: 参考 [项目设置指南.md](项目设置指南.md) 验证配置
|
||||||
|
|
||||||
|
### 问题4: EventSystem相关错误
|
||||||
|
**原因**: 缺少 `_Core/EventNames.gd` 文件
|
||||||
|
**解决**: 确保项目包含完整的 `_Core` 目录结构
|
||||||
|
|
||||||
|
## 🔗 下一步
|
||||||
|
|
||||||
|
完成项目入门后,建议继续阅读:
|
||||||
|
- [02-开发规范](../02-开发规范/) - 学习编码标准和架构规范
|
||||||
|
- [03-技术实现](../03-技术实现/) - 开始具体功能开发
|
||||||
|
|
||||||
|
## 💡 小贴士
|
||||||
|
|
||||||
|
- **项目已预配置完成** - 输入映射和核心组件都已设置好
|
||||||
|
- 遇到问题时,先查看对应文档的"常见问题"部分
|
||||||
|
- 建议在实际操作中边读边做,加深理解
|
||||||
|
- 可以将重要的配置信息做笔记备用
|
||||||
|
- 完成每个步骤后,建议运行项目验证配置是否正确
|
||||||
|
- 重点关注 `_Core` 目录中的核心组件,它们是项目的基础
|
||||||
|
|
||||||
|
## 🛠️ 核心组件预览
|
||||||
|
|
||||||
|
项目包含以下核心组件,在后续开发中会频繁使用:
|
||||||
|
- **EventSystem** - 全局事件通信系统
|
||||||
|
- **GameManager** - 游戏状态管理
|
||||||
|
- **SceneManager** - 场景切换管理
|
||||||
|
- **NetworkManager** - 网络请求管理
|
||||||
|
- **ProjectPaths** - 统一路径管理
|
||||||
|
|
||||||
|
详细使用方法请参考 [架构与通信规范](../02-开发规范/架构与通信规范.md)。
|
||||||
157
docs/01-项目入门/输入映射配置.md
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
# 输入映射配置指南
|
||||||
|
|
||||||
|
本文档说明了WhaleTown项目的输入映射配置要求和设置方法。
|
||||||
|
|
||||||
|
## 🎮 必需的输入映射
|
||||||
|
|
||||||
|
### 基础移动控制
|
||||||
|
- **`move_left`** - 向左移动
|
||||||
|
- 推荐按键:A键、左方向键
|
||||||
|
- **`move_right`** - 向右移动
|
||||||
|
- 推荐按键:D键、右方向键
|
||||||
|
- **`move_up`** - 向上移动
|
||||||
|
- 推荐按键:W键、上方向键
|
||||||
|
- **`move_down`** - 向下移动
|
||||||
|
- 推荐按键:S键、下方向键
|
||||||
|
|
||||||
|
### 交互控制
|
||||||
|
- **`interact`** - 交互动作
|
||||||
|
- 推荐按键:E键、空格键
|
||||||
|
- **`pause`** - 暂停游戏
|
||||||
|
- 推荐按键:ESC键
|
||||||
|
|
||||||
|
## ⚙️ Godot编辑器配置步骤
|
||||||
|
|
||||||
|
### 1. 打开输入映射设置
|
||||||
|
1. 在Godot编辑器中打开 `Project` → `Project Settings`
|
||||||
|
2. 切换到 `Input Map` 标签
|
||||||
|
|
||||||
|
### 2. 添加输入动作
|
||||||
|
对于每个必需的输入动作:
|
||||||
|
|
||||||
|
1. 在 `Action` 输入框中输入动作名称(如 `move_left`)
|
||||||
|
2. 点击 `Add` 按钮
|
||||||
|
3. 点击新添加动作右侧的 `+` 按钮
|
||||||
|
4. 按下对应的按键进行绑定
|
||||||
|
5. 重复步骤3-4添加备用按键
|
||||||
|
|
||||||
|
### 3. 配置示例
|
||||||
|
|
||||||
|
```
|
||||||
|
move_left:
|
||||||
|
- Key: A
|
||||||
|
- Key: Left Arrow
|
||||||
|
|
||||||
|
move_right:
|
||||||
|
- Key: D
|
||||||
|
- Key: Right Arrow
|
||||||
|
|
||||||
|
move_up:
|
||||||
|
- Key: W
|
||||||
|
- Key: Up Arrow
|
||||||
|
|
||||||
|
move_down:
|
||||||
|
- Key: S
|
||||||
|
- Key: Down Arrow
|
||||||
|
|
||||||
|
interact:
|
||||||
|
- Key: E
|
||||||
|
- Key: Space
|
||||||
|
|
||||||
|
pause:
|
||||||
|
- Key: Escape
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 代码中的使用方法
|
||||||
|
|
||||||
|
### 移动输入检测
|
||||||
|
```gdscript
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
# 获取移动向量
|
||||||
|
var direction := Input.get_vector(
|
||||||
|
"move_left", "move_right",
|
||||||
|
"move_up", "move_down"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 应用移动
|
||||||
|
velocity = direction * move_speed
|
||||||
|
move_and_slide()
|
||||||
|
```
|
||||||
|
|
||||||
|
### 交互输入检测
|
||||||
|
```gdscript
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("interact"):
|
||||||
|
_handle_interaction()
|
||||||
|
|
||||||
|
if event.is_action_pressed("pause"):
|
||||||
|
_toggle_pause()
|
||||||
|
```
|
||||||
|
|
||||||
|
### 连续输入检测
|
||||||
|
```gdscript
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
# 检测持续按下的按键
|
||||||
|
if Input.is_action_pressed("interact"):
|
||||||
|
_continuous_interaction(delta)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📱 手柄支持(可选)
|
||||||
|
|
||||||
|
### 推荐手柄映射
|
||||||
|
- **左摇杆** - 移动控制
|
||||||
|
- **A按钮/X按钮** - 交互
|
||||||
|
- **Start按钮** - 暂停
|
||||||
|
|
||||||
|
### 配置方法
|
||||||
|
1. 在Input Map中为每个动作添加手柄输入
|
||||||
|
2. 使用 `Joypad Button` 或 `Joypad Axis` 进行绑定
|
||||||
|
|
||||||
|
## ✅ 验证配置
|
||||||
|
|
||||||
|
### 测试脚本
|
||||||
|
创建一个简单的测试脚本验证输入配置:
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
print("输入映射测试开始...")
|
||||||
|
_test_input_actions()
|
||||||
|
|
||||||
|
func _test_input_actions() -> void:
|
||||||
|
var required_actions = [
|
||||||
|
"move_left", "move_right", "move_up", "move_down",
|
||||||
|
"interact", "pause"
|
||||||
|
]
|
||||||
|
|
||||||
|
for action in required_actions:
|
||||||
|
if InputMap.has_action(action):
|
||||||
|
print("✅ ", action, " - 已配置")
|
||||||
|
else:
|
||||||
|
print("❌ ", action, " - 未配置")
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
# 实时显示输入事件
|
||||||
|
for action in InputMap.get_actions():
|
||||||
|
if event.is_action_pressed(action):
|
||||||
|
print("按下: ", action)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🚨 常见问题
|
||||||
|
|
||||||
|
### Q: 输入没有响应怎么办?
|
||||||
|
A: 检查以下几点:
|
||||||
|
1. 确认输入动作名称拼写正确
|
||||||
|
2. 验证按键是否正确绑定
|
||||||
|
3. 检查代码中是否正确使用了动作名称
|
||||||
|
|
||||||
|
### Q: 如何添加自定义输入?
|
||||||
|
A: 按照相同步骤在Input Map中添加新的动作,并在代码中使用对应的动作名称。
|
||||||
|
|
||||||
|
### Q: 手柄不工作怎么办?
|
||||||
|
A: 确保手柄已连接,并在Input Map中正确配置了手柄按钮映射。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**注意:输入映射配置是游戏正常运行的基础,请确保所有必需的输入动作都已正确配置!**
|
||||||
334
docs/01-项目入门/项目结构说明.md
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
# WhaleTown 项目结构说明
|
||||||
|
|
||||||
|
本文档详细说明了 WhaleTown 项目的文件结构设计,采用分层架构模式,确保团队协作高效且代码结构清晰。
|
||||||
|
|
||||||
|
## 🎯 设计理念
|
||||||
|
|
||||||
|
### 核心原则
|
||||||
|
- **分层架构**:框架层、游戏层、界面层明确分离
|
||||||
|
- **团队协作**:策划、美术、开发三类角色各司其职
|
||||||
|
- **高度解耦**:通过事件系统实现组件间通信
|
||||||
|
- **组件复用**:可复用组件统一管理
|
||||||
|
- **标准化**:统一的命名规范和目录结构
|
||||||
|
|
||||||
|
### 团队协作模式
|
||||||
|
- **🎮 开发团队** - 主要工作在 `_Core/`、`scenes/`、`UI/`、`Utils/`
|
||||||
|
- **🎨 美术团队** - 主要工作在 `assets/`
|
||||||
|
- **📋 策划团队** - 主要工作在 `Config/`
|
||||||
|
|
||||||
|
## 🏗️ 项目架构概览
|
||||||
|
|
||||||
|
```
|
||||||
|
WhaleTown/
|
||||||
|
├── 🔧 _Core/ # [框架层] 核心系统和管理器
|
||||||
|
├── 🎬 scenes/ # [游戏层] 游戏场景和组件
|
||||||
|
├── 🎨 UI/ # [界面层] 用户界面
|
||||||
|
├── 🖼️ assets/ # [资源层] 美术资源
|
||||||
|
├── ⚙️ Config/ # [配置层] 游戏配置和数据
|
||||||
|
├── 🛠️ Utils/ # [工具层] 通用工具脚本
|
||||||
|
├── 🧪 tests/ # [测试层] 测试文件
|
||||||
|
├── 🚀 tools/ # [构建层] 构建和部署工具
|
||||||
|
├── 🌐 web_assets/ # [发布层] Web版本资源
|
||||||
|
└── 📚 docs/ # [文档层] 项目文档
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📁 详细目录结构
|
||||||
|
|
||||||
|
### 1. 🔧 框架层 (_Core/)
|
||||||
|
> **负责团队**: 开发团队
|
||||||
|
> **职责**: 游戏底层框架,全局管理器和核心系统
|
||||||
|
|
||||||
|
```
|
||||||
|
_Core/
|
||||||
|
├── managers/ # 全局管理器
|
||||||
|
│ ├── GameManager.gd # 游戏状态管理
|
||||||
|
│ ├── SceneManager.gd # 场景切换管理
|
||||||
|
│ ├── NetworkManager.gd # 网络通信管理
|
||||||
|
│ └── ResponseHandler.gd # API响应处理
|
||||||
|
└── systems/ # 核心系统
|
||||||
|
└── EventSystem.gd # 全局事件系统
|
||||||
|
```
|
||||||
|
|
||||||
|
**特点**:
|
||||||
|
- 自动加载 (AutoLoad) 单例
|
||||||
|
- 全局可访问
|
||||||
|
- 与具体游戏逻辑无关
|
||||||
|
- 提供基础服务
|
||||||
|
|
||||||
|
**使用示例**:
|
||||||
|
```gdscript
|
||||||
|
# 游戏状态管理
|
||||||
|
GameManager.change_state(GameManager.GameState.IN_GAME)
|
||||||
|
|
||||||
|
# 场景切换
|
||||||
|
SceneManager.change_scene("main")
|
||||||
|
|
||||||
|
# 事件通信
|
||||||
|
EventSystem.emit_event("player_moved", {"position": Vector2(100, 200)})
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 🎬 游戏层 (scenes/)
|
||||||
|
> **负责团队**: 开发团队
|
||||||
|
> **职责**: 游戏场景、实体和可复用组件
|
||||||
|
|
||||||
|
```
|
||||||
|
scenes/
|
||||||
|
├── Maps/ # 游戏地图场景
|
||||||
|
│ ├── main_scene.tscn # 主游戏场景
|
||||||
|
│ └── MainScene.gd # 主场景脚本
|
||||||
|
└── Components/ # 可复用组件
|
||||||
|
├── characters/ # 角色组件
|
||||||
|
├── effects/ # 特效组件
|
||||||
|
├── items/ # 物品组件
|
||||||
|
└── ui/ # UI组件
|
||||||
|
```
|
||||||
|
|
||||||
|
**设计原则**:
|
||||||
|
- **场景内聚**: 脚本紧邻场景文件存放
|
||||||
|
- **组件化**: 可复用组件统一管理
|
||||||
|
- **模块化**: 按功能类型分类组织
|
||||||
|
|
||||||
|
### 3. 🎨 界面层 (UI/)
|
||||||
|
> **负责团队**: 开发团队 + 美术团队协作
|
||||||
|
> **职责**: 用户界面和主题管理
|
||||||
|
|
||||||
|
```
|
||||||
|
UI/
|
||||||
|
├── Windows/ # 模态窗口
|
||||||
|
│ ├── LoginWindow.tscn # 登录窗口
|
||||||
|
│ └── AuthScene.gd # 认证场景脚本
|
||||||
|
└── Theme/ # 全局主题
|
||||||
|
├── MainTheme.tres # 主题资源
|
||||||
|
└── Fonts/ # 字体文件
|
||||||
|
└── msyh.ttc # 微软雅黑字体
|
||||||
|
```
|
||||||
|
|
||||||
|
**组织方式**:
|
||||||
|
- **Windows/**: 模态窗口和对话框
|
||||||
|
- **Theme/**: 统一的UI主题和样式
|
||||||
|
- **Fonts/**: 字体资源管理
|
||||||
|
|
||||||
|
### 4. 🖼️ 资源层 (assets/)
|
||||||
|
> **负责团队**: 美术团队
|
||||||
|
> **职责**: 所有美术资源和素材
|
||||||
|
|
||||||
|
```
|
||||||
|
assets/
|
||||||
|
├── sprites/ # 精灵图资源
|
||||||
|
│ ├── characters/ # 角色精灵
|
||||||
|
│ ├── effects/ # 特效精灵
|
||||||
|
│ ├── environment/ # 环境精灵
|
||||||
|
│ └── icon/ # 图标资源
|
||||||
|
├── audio/ # 音频资源
|
||||||
|
│ ├── music/ # 背景音乐
|
||||||
|
│ ├── sounds/ # 音效
|
||||||
|
│ └── voice/ # 语音
|
||||||
|
├── ui/ # UI专用资源
|
||||||
|
│ ├── auth/ # 认证界面资源
|
||||||
|
│ │ ├── bg_auth_scene.png # 认证背景
|
||||||
|
│ │ └── login_frame_smart_transparent.png
|
||||||
|
│ ├── chinese_theme.tres # 中文主题
|
||||||
|
│ └── datawhale_logo.png # 项目Logo
|
||||||
|
├── fonts/ # 字体文件
|
||||||
|
├── materials/ # 材质资源
|
||||||
|
└── shaders/ # 着色器
|
||||||
|
```
|
||||||
|
|
||||||
|
**美术团队工作流程**:
|
||||||
|
1. 按分类将资源放入对应目录
|
||||||
|
2. 遵循命名规范 (snake_case)
|
||||||
|
3. 确保资源格式符合Godot要求
|
||||||
|
4. 配置正确的导入设置 (像素艺术使用最近邻过滤)
|
||||||
|
|
||||||
|
### 5. ⚙️ 配置层 (Config/)
|
||||||
|
> **负责团队**: 策划团队
|
||||||
|
> **职责**: 游戏配置、数据和本地化
|
||||||
|
|
||||||
|
```
|
||||||
|
Config/
|
||||||
|
├── game_config.json # 游戏主配置
|
||||||
|
└── zh_CN.json # 中文本地化
|
||||||
|
```
|
||||||
|
|
||||||
|
**策划团队工作内容**:
|
||||||
|
- **游戏数值配置**: 角色属性、物品数据、关卡参数
|
||||||
|
- **本地化文本**: 多语言文本翻译和管理
|
||||||
|
- **游戏平衡**: 数值平衡和游戏性调整
|
||||||
|
|
||||||
|
**配置文件示例**:
|
||||||
|
```json
|
||||||
|
// game_config.json
|
||||||
|
{
|
||||||
|
"player": {
|
||||||
|
"move_speed": 200.0,
|
||||||
|
"max_health": 100,
|
||||||
|
"jump_height": 400.0
|
||||||
|
},
|
||||||
|
"game": {
|
||||||
|
"target_fps": 60,
|
||||||
|
"auto_save_interval": 300
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. 🛠️ 工具层 (Utils/)
|
||||||
|
> **负责团队**: 开发团队
|
||||||
|
> **职责**: 通用工具和辅助脚本
|
||||||
|
|
||||||
|
```
|
||||||
|
Utils/
|
||||||
|
└── StringUtils.gd # 字符串处理工具
|
||||||
|
```
|
||||||
|
|
||||||
|
**特点**:
|
||||||
|
- 纯函数,无依赖
|
||||||
|
- 可被任何层调用
|
||||||
|
- 提供通用功能
|
||||||
|
|
||||||
|
### 7. 🧪 测试层 (tests/)
|
||||||
|
> **负责团队**: 开发团队
|
||||||
|
> **职责**: 质量保证和自动化测试
|
||||||
|
|
||||||
|
```
|
||||||
|
tests/
|
||||||
|
├── api/ # API接口测试
|
||||||
|
├── auth/ # 认证功能测试
|
||||||
|
├── unit/ # 单元测试
|
||||||
|
├── integration/ # 集成测试
|
||||||
|
└── performance/ # 性能测试
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8. 🚀 构建层 (tools/)
|
||||||
|
> **负责团队**: 开发团队/DevOps
|
||||||
|
> **职责**: 构建脚本和部署工具
|
||||||
|
|
||||||
|
```
|
||||||
|
tools/
|
||||||
|
├── build_web.bat # Windows Web构建脚本
|
||||||
|
├── build_web.sh # Linux/macOS Web构建脚本
|
||||||
|
├── serve_web.bat # Windows 本地服务器
|
||||||
|
├── serve_web.sh # Linux/macOS 本地服务器
|
||||||
|
└── README.md # 工具使用说明
|
||||||
|
```
|
||||||
|
|
||||||
|
### 9. 🌐 发布层 (web_assets/)
|
||||||
|
> **负责团队**: 自动生成
|
||||||
|
> **职责**: Web版本发布资源
|
||||||
|
|
||||||
|
```
|
||||||
|
web_assets/
|
||||||
|
├── index.html # Web版本入口
|
||||||
|
├── index.js # Godot Web导出JS
|
||||||
|
├── index.wasm # WebAssembly文件
|
||||||
|
├── index.pck # 游戏资源包
|
||||||
|
└── [其他Web资源] # 图标、配置等
|
||||||
|
```
|
||||||
|
|
||||||
|
### 10. 📚 文档层 (docs/)
|
||||||
|
> **负责团队**: 全体团队
|
||||||
|
> **职责**: 项目文档和开发指南
|
||||||
|
|
||||||
|
```
|
||||||
|
docs/
|
||||||
|
├── 01-项目入门/ # 新人必读
|
||||||
|
├── 02-开发规范/ # 编码标准
|
||||||
|
├── 03-技术实现/ # 开发指导
|
||||||
|
├── 04-高级开发/ # 进阶技巧
|
||||||
|
├── 05-部署运维/ # 发布部署
|
||||||
|
└── 06-功能模块/ # 功能文档
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🤝 团队协作指南
|
||||||
|
|
||||||
|
### 开发团队 🎮
|
||||||
|
**主要工作区域**: `_Core/`, `scenes/`, `UI/`, `Utils/`, `tests/`
|
||||||
|
|
||||||
|
**日常工作流程**:
|
||||||
|
1. 在 `_Core/` 中开发核心系统和管理器
|
||||||
|
2. 在 `scenes/` 中创建游戏场景和组件
|
||||||
|
3. 在 `UI/` 中实现用户界面
|
||||||
|
4. 在 `Utils/` 中编写通用工具
|
||||||
|
5. 在 `tests/` 中编写测试用例
|
||||||
|
|
||||||
|
**协作要点**:
|
||||||
|
- 遵循架构设计原则,使用事件系统通信
|
||||||
|
- 保持代码模块化和可复用性
|
||||||
|
- 及时编写测试和文档
|
||||||
|
|
||||||
|
### 美术团队 🎨
|
||||||
|
**主要工作区域**: `assets/`
|
||||||
|
|
||||||
|
**日常工作流程**:
|
||||||
|
1. 按分类整理美术资源到 `assets/` 对应目录
|
||||||
|
2. 遵循命名规范,使用 snake_case 命名
|
||||||
|
3. 配置正确的Godot导入设置
|
||||||
|
4. 与开发团队协作调整UI资源
|
||||||
|
|
||||||
|
**协作要点**:
|
||||||
|
- 严格按照目录结构组织资源
|
||||||
|
- 确保资源格式和质量符合要求
|
||||||
|
- 及时与开发团队沟通资源需求
|
||||||
|
|
||||||
|
### 策划团队 📋
|
||||||
|
**主要工作区域**: `Config/`
|
||||||
|
|
||||||
|
**日常工作流程**:
|
||||||
|
1. 在 `Config/` 中维护游戏配置文件
|
||||||
|
2. 管理游戏数值和平衡性调整
|
||||||
|
3. 负责本地化文本的翻译和维护
|
||||||
|
4. 与开发团队协作实现游戏功能
|
||||||
|
|
||||||
|
**协作要点**:
|
||||||
|
- 使用JSON格式编写配置文件
|
||||||
|
- 保持配置文件的结构清晰
|
||||||
|
- 及时更新本地化文本
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔄 开发工作流
|
||||||
|
|
||||||
|
### 新功能开发流程
|
||||||
|
1. **需求分析** - 明确功能需求和设计方案
|
||||||
|
2. **架构设计** - 确定涉及的模块和接口
|
||||||
|
3. **资源准备** - 美术团队准备相关资源
|
||||||
|
4. **配置设置** - 策划团队配置相关数据
|
||||||
|
5. **代码实现** - 开发团队实现功能逻辑
|
||||||
|
6. **测试验证** - 编写测试用例验证功能
|
||||||
|
7. **文档更新** - 更新相关文档说明
|
||||||
|
|
||||||
|
### 版本发布流程
|
||||||
|
1. **功能完成** - 所有计划功能开发完成
|
||||||
|
2. **测试通过** - 所有测试用例通过
|
||||||
|
3. **资源整理** - 美术资源整理完成
|
||||||
|
4. **配置确认** - 策划配置确认无误
|
||||||
|
5. **构建发布** - 使用 `tools/` 中的脚本构建
|
||||||
|
6. **部署上线** - 部署到目标环境
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 最佳实践
|
||||||
|
|
||||||
|
### 目录命名规范
|
||||||
|
- **文件夹**: 使用 PascalCase (如: `Config/`, `Utils/`)
|
||||||
|
- **文件**: 使用 snake_case (如: `main_scene.tscn`, `game_config.json`)
|
||||||
|
- **脚本类**: 使用 PascalCase (如: `GameManager.gd`)
|
||||||
|
|
||||||
|
### 资源管理规范
|
||||||
|
- 所有资源必须放在 `assets/` 对应分类目录下
|
||||||
|
- 使用描述性的文件名,避免使用数字编号
|
||||||
|
- 像素艺术资源必须关闭过滤 (Filter: Off)
|
||||||
|
- 及时清理不使用的资源文件
|
||||||
|
|
||||||
|
### 代码组织规范
|
||||||
|
- 脚本文件与场景文件放在同一目录
|
||||||
|
- 使用事件系统实现模块间通信
|
||||||
|
- 保持单一职责原则,避免过度耦合
|
||||||
|
- 及时编写注释和文档
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**记住:良好的项目结构是团队协作成功的基础!**
|
||||||
142
docs/01-项目入门/项目设置指南.md
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# 项目设置指南
|
||||||
|
|
||||||
|
本文档指导你完成WhaleTown项目的Godot编辑器配置,确保开发环境正确设置。
|
||||||
|
|
||||||
|
## 🎯 AutoLoad 配置
|
||||||
|
|
||||||
|
项目已经预配置了以下AutoLoad单例,你可以验证配置是否正确:
|
||||||
|
|
||||||
|
### 1. 打开项目设置
|
||||||
|
1. 在Godot编辑器中打开 `Project` → `Project Settings`
|
||||||
|
2. 切换到 `AutoLoad` 标签
|
||||||
|
|
||||||
|
### 2. 验证AutoLoad配置
|
||||||
|
确认以下单例已正确配置:
|
||||||
|
|
||||||
|
| 名称 | 路径 | 单例 |
|
||||||
|
|------|------|------|
|
||||||
|
| GameManager | `res://_Core/managers/GameManager.gd` | ✅ |
|
||||||
|
| SceneManager | `res://_Core/managers/SceneManager.gd` | ✅ |
|
||||||
|
| EventSystem | `res://_Core/systems/EventSystem.gd` | ✅ |
|
||||||
|
| NetworkManager | `res://_Core/managers/NetworkManager.gd` | ✅ |
|
||||||
|
| ResponseHandler | `res://_Core/managers/ResponseHandler.gd` | ✅ |
|
||||||
|
|
||||||
|
### 3. 如果需要手动添加AutoLoad
|
||||||
|
如果某个AutoLoad缺失,可以手动添加:
|
||||||
|
|
||||||
|
1. 点击 `Add` 按钮
|
||||||
|
2. 设置以下信息:
|
||||||
|
- **Path**: 对应的脚本路径
|
||||||
|
- **Name**: 单例名称
|
||||||
|
- **Singleton**: ✅ 勾选
|
||||||
|
3. 点击 `Add` 确认
|
||||||
|
|
||||||
|
## ⚙️ 其他重要设置
|
||||||
|
|
||||||
|
### 主题配置
|
||||||
|
项目使用自定义中文主题:
|
||||||
|
- **路径**: `UI/Theme/MainTheme.tres`
|
||||||
|
- **字体**: 微软雅黑 (`UI/Theme/Fonts/msyh.ttc`)
|
||||||
|
|
||||||
|
### 主场景设置
|
||||||
|
- **主场景**: `res://Scenes/Maps/main_scene.tscn`
|
||||||
|
- **窗口大小**: 1376x768
|
||||||
|
- **窗口模式**: 全屏模式
|
||||||
|
|
||||||
|
### 渲染设置
|
||||||
|
- **渲染器**: GL Compatibility (兼容性优先)
|
||||||
|
- **拉伸模式**: Canvas Items
|
||||||
|
- **拉伸比例**: Expand
|
||||||
|
|
||||||
|
## 🧪 验证设置
|
||||||
|
|
||||||
|
### 1. 测试AutoLoad单例
|
||||||
|
在任何脚本中可以直接使用:
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func _ready():
|
||||||
|
# 测试GameManager
|
||||||
|
print("游戏状态: ", GameManager.get_current_state())
|
||||||
|
|
||||||
|
# 测试SceneManager
|
||||||
|
print("当前场景: ", SceneManager.get_current_scene_name())
|
||||||
|
|
||||||
|
# 测试EventSystem
|
||||||
|
EventSystem.emit_event("test_event", {"message": "Hello World"})
|
||||||
|
|
||||||
|
# 测试NetworkManager
|
||||||
|
var request_id = NetworkManager.login("test_user", "test_password")
|
||||||
|
print("网络请求ID: ", request_id)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 检查控制台输出
|
||||||
|
运行项目后,检查控制台是否有以下信息:
|
||||||
|
- ✅ 没有AutoLoad相关错误
|
||||||
|
- ✅ 各个管理器初始化成功
|
||||||
|
- ✅ 主题和字体加载正常
|
||||||
|
|
||||||
|
### 3. 测试场景切换
|
||||||
|
```gdscript
|
||||||
|
# 测试场景管理器
|
||||||
|
func test_scene_manager():
|
||||||
|
# 切换到主场景
|
||||||
|
SceneManager.change_scene("main")
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔧 常见问题排查
|
||||||
|
|
||||||
|
### 问题1: AutoLoad脚本找不到
|
||||||
|
**症状**: 控制台显示"Cannot load script"错误
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. 检查脚本文件是否存在于指定路径
|
||||||
|
2. 确认脚本文件没有语法错误
|
||||||
|
3. 重新导入项目 (`Project` → `Reload Current Project`)
|
||||||
|
|
||||||
|
### 问题2: 单例无法访问
|
||||||
|
**症状**: 代码中无法访问GameManager等单例
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. 确认AutoLoad配置中勾选了"Singleton"
|
||||||
|
2. 重启Godot编辑器
|
||||||
|
3. 检查脚本中是否有拼写错误
|
||||||
|
|
||||||
|
### 问题3: 主题显示异常
|
||||||
|
**症状**: 界面字体或样式显示不正确
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. 检查 `UI/Theme/MainTheme.tres` 文件是否存在
|
||||||
|
2. 确认字体文件 `UI/Theme/Fonts/msyh.ttc` 已正确导入
|
||||||
|
3. 在项目设置中重新设置自定义主题
|
||||||
|
|
||||||
|
### 问题4: 网络请求失败
|
||||||
|
**症状**: NetworkManager调用失败
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. 检查网络连接
|
||||||
|
2. 确认API地址配置正确
|
||||||
|
3. 查看ResponseHandler是否正常工作
|
||||||
|
|
||||||
|
## 📋 配置检查清单
|
||||||
|
|
||||||
|
完成设置后,请检查以下项目:
|
||||||
|
|
||||||
|
- [ ] 所有AutoLoad单例配置正确
|
||||||
|
- [ ] 主场景可以正常启动
|
||||||
|
- [ ] 控制台没有错误信息
|
||||||
|
- [ ] 自定义主题加载正常
|
||||||
|
- [ ] 中文字体显示正确
|
||||||
|
- [ ] 网络管理器可以正常调用
|
||||||
|
- [ ] 事件系统工作正常
|
||||||
|
- [ ] 场景管理器可以切换场景
|
||||||
|
|
||||||
|
## 🚀 下一步
|
||||||
|
|
||||||
|
配置完成后,建议继续阅读:
|
||||||
|
- [输入映射配置](输入映射配置.md) - 设置游戏控制
|
||||||
|
- [命名规范](../02-开发规范/命名规范.md) - 学习编码规范
|
||||||
|
- [架构与通信规范](../02-开发规范/架构与通信规范.md) - 理解项目架构
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**💡 提示**: 如果遇到问题,可以参考 [测试指南](../03-技术实现/测试指南.md) 进行更详细的功能验证。
|
||||||
105
docs/02-开发规范/README.md
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# 📋 开发规范
|
||||||
|
|
||||||
|
> **适用人群**: 所有开发者
|
||||||
|
> **使用时机**: 编码过程中,代码审查时
|
||||||
|
|
||||||
|
这个目录包含了项目的所有编码标准和开发规范,确保团队代码风格一致,架构设计统一。
|
||||||
|
|
||||||
|
## 📚 规范文档
|
||||||
|
|
||||||
|
### 基础规范 📝
|
||||||
|
**[命名规范.md](命名规范.md)**
|
||||||
|
- 文件、类、变量、函数命名标准
|
||||||
|
- 资源文件命名规则
|
||||||
|
- 目录结构命名约定
|
||||||
|
|
||||||
|
**[代码注释规范.md](代码注释规范.md)**
|
||||||
|
- 注释格式和标准
|
||||||
|
- 文档生成规范
|
||||||
|
- AI辅助开发指南
|
||||||
|
|
||||||
|
**[Git提交规范.md](Git提交规范.md)**
|
||||||
|
- 提交信息格式标准
|
||||||
|
- 分支管理策略
|
||||||
|
- 代码审查流程
|
||||||
|
|
||||||
|
### 架构规范 🏗️
|
||||||
|
**[架构与通信规范.md](架构与通信规范.md)**
|
||||||
|
- 分层架构设计原则
|
||||||
|
- EventSystem事件系统使用
|
||||||
|
- 组件间通信标准
|
||||||
|
- 单例管理规范
|
||||||
|
|
||||||
|
### 质量标准 ⭐
|
||||||
|
**[开发哲学与最佳实践.md](开发哲学与最佳实践.md)**
|
||||||
|
- 项目开发理念
|
||||||
|
- 代码质量标准
|
||||||
|
- 最佳实践指导
|
||||||
|
- 代码审查清单
|
||||||
|
|
||||||
|
## 🎯 使用指南
|
||||||
|
|
||||||
|
### 新人学习路径
|
||||||
|
1. **命名规范** - 学会正确命名
|
||||||
|
2. **架构与通信规范** - 理解项目架构
|
||||||
|
3. **开发哲学与最佳实践** - 掌握质量标准
|
||||||
|
4. **代码注释规范** - 学会写好注释
|
||||||
|
5. **Git提交规范** - 规范版本控制
|
||||||
|
|
||||||
|
### 日常开发参考
|
||||||
|
- 编码时参考 **命名规范** 和 **架构规范**
|
||||||
|
- 提交代码前检查 **最佳实践** 清单
|
||||||
|
- 写注释时遵循 **注释规范**
|
||||||
|
- 提交时遵循 **Git规范**
|
||||||
|
|
||||||
|
### 代码审查要点
|
||||||
|
- [ ] 命名是否符合规范
|
||||||
|
- [ ] 架构设计是否合理
|
||||||
|
- [ ] 代码质量是否达标
|
||||||
|
- [ ] 注释是否完整清晰
|
||||||
|
- [ ] 提交信息是否规范
|
||||||
|
|
||||||
|
## ⚠️ 重要提醒
|
||||||
|
|
||||||
|
### 强制性规范
|
||||||
|
以下规范是**强制性**的,必须严格遵守:
|
||||||
|
- 文件和目录命名规范
|
||||||
|
- EventSystem通信规范
|
||||||
|
- 类型安全要求
|
||||||
|
- Git提交格式
|
||||||
|
|
||||||
|
### 建议性规范
|
||||||
|
以下规范是**建议性**的,推荐遵循:
|
||||||
|
- 代码注释的详细程度
|
||||||
|
- 函数长度和复杂度
|
||||||
|
- 性能优化建议
|
||||||
|
|
||||||
|
## 🔄 规范更新
|
||||||
|
|
||||||
|
### 更新原则
|
||||||
|
- 规范变更需要团队讨论
|
||||||
|
- 重大变更需要文档化说明
|
||||||
|
- 保持向后兼容性
|
||||||
|
|
||||||
|
### 更新流程
|
||||||
|
1. 提出规范变更建议
|
||||||
|
2. 团队讨论和评审
|
||||||
|
3. 更新相关文档
|
||||||
|
4. 通知所有开发者
|
||||||
|
|
||||||
|
## 🤝 团队协作
|
||||||
|
|
||||||
|
### 规范执行
|
||||||
|
- 代码审查时严格检查规范遵循情况
|
||||||
|
- 定期进行规范培训和分享
|
||||||
|
- 鼓励团队成员提出改进建议
|
||||||
|
|
||||||
|
### 问题反馈
|
||||||
|
如果发现规范问题或有改进建议:
|
||||||
|
- 创建Issue讨论
|
||||||
|
- 在团队会议中提出
|
||||||
|
- 通过PR提交改进方案
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**记住:规范不是束缚,而是团队协作的基础!**
|
||||||
433
docs/02-开发规范/代码注释规范.md
Normal file
@@ -0,0 +1,433 @@
|
|||||||
|
# GDScript 代码注释规范
|
||||||
|
|
||||||
|
本文档详细说明了 whaleTown 项目中 GDScript 代码的注释规范,旨在提高代码可读性和维护性。
|
||||||
|
|
||||||
|
## 目录
|
||||||
|
|
||||||
|
- [基本原则](#基本原则)
|
||||||
|
- [文件头注释](#文件头注释)
|
||||||
|
- [类和函数注释](#类和函数注释)
|
||||||
|
- [变量注释](#变量注释)
|
||||||
|
- [行内注释](#行内注释)
|
||||||
|
- [特殊注释标记](#特殊注释标记)
|
||||||
|
- [AI辅助注释指南](#ai辅助注释指南)
|
||||||
|
|
||||||
|
## 基本原则
|
||||||
|
|
||||||
|
### 注释的目的
|
||||||
|
- **解释为什么**,而不是解释做什么
|
||||||
|
- **提供上下文**,帮助理解代码意图
|
||||||
|
- **记录重要决策**和设计考虑
|
||||||
|
- **警告潜在问题**和注意事项
|
||||||
|
|
||||||
|
### 注释质量标准
|
||||||
|
- 简洁明了,避免冗余
|
||||||
|
- 使用中文,保持一致性
|
||||||
|
- 及时更新,与代码同步
|
||||||
|
- 避免显而易见的注释
|
||||||
|
|
||||||
|
## 文件头注释
|
||||||
|
|
||||||
|
每个 GDScript 文件都应该包含文件头注释,说明文件的用途和基本信息。
|
||||||
|
|
||||||
|
### 标准格式
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# ============================================================================
|
||||||
|
# 文件名: PlayerController.gd
|
||||||
|
# 作用: 玩家角色控制器,处理玩家输入和移动逻辑
|
||||||
|
#
|
||||||
|
# 主要功能:
|
||||||
|
# - 处理键盘和手柄输入
|
||||||
|
# - 控制角色移动和跳跃
|
||||||
|
# - 管理角色状态切换
|
||||||
|
# - 处理碰撞检测
|
||||||
|
#
|
||||||
|
# 依赖: MovementComponent, AnimationComponent
|
||||||
|
# 作者: [开发者名称]
|
||||||
|
# 创建时间: 2024-12-24
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
extends CharacterBody2D
|
||||||
|
```
|
||||||
|
|
||||||
|
### 管理器类文件头
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# ============================================================================
|
||||||
|
# 游戏管理器 - GameManager.gd
|
||||||
|
#
|
||||||
|
# 全局单例管理器,负责游戏状态管理和生命周期控制
|
||||||
|
#
|
||||||
|
# 核心职责:
|
||||||
|
# - 游戏状态切换 (加载、认证、游戏中、暂停等)
|
||||||
|
# - 用户信息管理
|
||||||
|
# - 全局配置访问
|
||||||
|
# - 系统初始化和清理
|
||||||
|
#
|
||||||
|
# 使用方式:
|
||||||
|
# GameManager.change_state(GameManager.GameState.IN_GAME)
|
||||||
|
# GameManager.set_current_user("player123")
|
||||||
|
#
|
||||||
|
# 注意事项:
|
||||||
|
# - 作为自动加载单例,全局可访问
|
||||||
|
# - 状态变更会触发 game_state_changed 信号
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
extends Node
|
||||||
|
```
|
||||||
|
## 类和函数注释
|
||||||
|
|
||||||
|
### 类注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# 玩家数据类
|
||||||
|
#
|
||||||
|
# 存储和管理玩家的基本属性和状态信息
|
||||||
|
# 支持数据序列化和反序列化,用于存档系统
|
||||||
|
class_name PlayerData
|
||||||
|
|
||||||
|
# 武器组件类
|
||||||
|
#
|
||||||
|
# 为角色提供武器功能,包括攻击、换弹、特殊技能等
|
||||||
|
# 可以挂载到任何具有攻击能力的角色上
|
||||||
|
#
|
||||||
|
# 使用示例:
|
||||||
|
# var weapon = WeaponComponent.new()
|
||||||
|
# weapon.setup_weapon("sword", 50)
|
||||||
|
# add_child(weapon)
|
||||||
|
class_name WeaponComponent
|
||||||
|
```
|
||||||
|
|
||||||
|
### 函数注释格式
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# 处理玩家输入并更新移动状态
|
||||||
|
#
|
||||||
|
# 参数:
|
||||||
|
# delta: float - 帧时间间隔
|
||||||
|
#
|
||||||
|
# 返回值: 无
|
||||||
|
#
|
||||||
|
# 注意事项:
|
||||||
|
# - 需要在 _physics_process 中调用
|
||||||
|
# - 会自动处理重力和碰撞
|
||||||
|
func handle_movement(delta: float) -> void:
|
||||||
|
|
||||||
|
# 验证用户输入的邮箱格式
|
||||||
|
#
|
||||||
|
# 参数:
|
||||||
|
# email: String - 待验证的邮箱地址
|
||||||
|
#
|
||||||
|
# 返回值:
|
||||||
|
# Dictionary - 包含验证结果和错误信息
|
||||||
|
# {
|
||||||
|
# "valid": bool, # 是否有效
|
||||||
|
# "message": String # 错误信息(如果无效)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# 使用示例:
|
||||||
|
# var result = validate_email("test@example.com")
|
||||||
|
# if result.valid:
|
||||||
|
# print("邮箱格式正确")
|
||||||
|
static func validate_email(email: String) -> Dictionary:
|
||||||
|
```
|
||||||
|
## 变量注释
|
||||||
|
|
||||||
|
### 成员变量注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# 玩家基础属性
|
||||||
|
@export var max_health: int = 100 # 最大生命值
|
||||||
|
@export var move_speed: float = 200.0 # 移动速度 (像素/秒)
|
||||||
|
@export var jump_force: float = -400.0 # 跳跃力度 (负值向上)
|
||||||
|
|
||||||
|
# 状态管理
|
||||||
|
var current_health: int # 当前生命值
|
||||||
|
var is_grounded: bool = false # 是否在地面上
|
||||||
|
var can_double_jump: bool = true # 是否可以二段跳
|
||||||
|
|
||||||
|
# 节点引用 - 在 _ready() 中初始化
|
||||||
|
@onready var sprite: Sprite2D = $Sprite2D
|
||||||
|
@onready var collision: CollisionShape2D = $CollisionShape2D
|
||||||
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||||
|
|
||||||
|
# 私有变量 - 内部使用
|
||||||
|
var _velocity: Vector2 = Vector2.ZERO # 当前速度向量
|
||||||
|
var _last_direction: int = 1 # 最后面向方向 (1=右, -1=左)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 常量注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# 游戏配置常量
|
||||||
|
const GRAVITY: float = 980.0 # 重力加速度 (像素/秒²)
|
||||||
|
const MAX_FALL_SPEED: float = 1000.0 # 最大下落速度
|
||||||
|
const COYOTE_TIME: float = 0.1 # 土狼时间 (离开平台后仍可跳跃的时间)
|
||||||
|
|
||||||
|
# 输入动作名称
|
||||||
|
const ACTION_MOVE_LEFT: String = "move_left"
|
||||||
|
const ACTION_MOVE_RIGHT: String = "move_right"
|
||||||
|
const ACTION_JUMP: String = "jump"
|
||||||
|
|
||||||
|
# 动画名称常量
|
||||||
|
const ANIM_IDLE: String = "idle"
|
||||||
|
const ANIM_WALK: String = "walk"
|
||||||
|
const ANIM_JUMP: String = "jump"
|
||||||
|
const ANIM_FALL: String = "fall"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 行内注释
|
||||||
|
|
||||||
|
### 复杂逻辑注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func update_movement(delta: float):
|
||||||
|
# 处理水平移动输入
|
||||||
|
var input_direction = Input.get_axis("move_left", "move_right")
|
||||||
|
|
||||||
|
if input_direction != 0:
|
||||||
|
velocity.x = input_direction * move_speed
|
||||||
|
_last_direction = sign(input_direction) # 记录面向方向
|
||||||
|
else:
|
||||||
|
# 应用摩擦力,逐渐停止
|
||||||
|
velocity.x = move_toward(velocity.x, 0, friction * delta)
|
||||||
|
|
||||||
|
# 应用重力 (只在空中时)
|
||||||
|
if not is_on_floor():
|
||||||
|
velocity.y += gravity * delta
|
||||||
|
velocity.y = min(velocity.y, max_fall_speed) # 限制最大下落速度
|
||||||
|
|
||||||
|
# 处理跳跃输入
|
||||||
|
if Input.is_action_just_pressed("jump"):
|
||||||
|
if is_on_floor():
|
||||||
|
velocity.y = jump_force # 普通跳跃
|
||||||
|
elif can_double_jump:
|
||||||
|
velocity.y = jump_force * 0.8 # 二段跳 (力度稍小)
|
||||||
|
can_double_jump = false
|
||||||
|
|
||||||
|
# 重置二段跳能力
|
||||||
|
if is_on_floor() and not can_double_jump:
|
||||||
|
can_double_jump = true
|
||||||
|
```
|
||||||
|
|
||||||
|
### 临时解决方案注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func handle_collision(body: Node2D):
|
||||||
|
# TODO: 重构碰撞处理逻辑,当前实现过于复杂
|
||||||
|
# FIXME: 在某些情况下会出现重复碰撞检测
|
||||||
|
# HACK: 临时解决方案,等待 Godot 4.6 修复相关 bug
|
||||||
|
|
||||||
|
if body.has_method("take_damage"):
|
||||||
|
# NOTE: 伤害计算需要考虑护甲和抗性
|
||||||
|
var damage = calculate_damage(base_damage)
|
||||||
|
body.take_damage(damage)
|
||||||
|
```
|
||||||
|
## 特殊注释标记
|
||||||
|
|
||||||
|
使用标准化的标记来标识不同类型的注释:
|
||||||
|
|
||||||
|
### 标记类型
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# TODO: 待实现的功能
|
||||||
|
# TODO: 添加音效播放功能
|
||||||
|
# TODO: 实现存档系统
|
||||||
|
|
||||||
|
# FIXME: 需要修复的问题
|
||||||
|
# FIXME: 内存泄漏问题,需要及时释放资源
|
||||||
|
# FIXME: 在低帧率下移动不流畅
|
||||||
|
|
||||||
|
# HACK: 临时解决方案
|
||||||
|
# HACK: 绕过 Godot 引擎的已知 bug
|
||||||
|
# HACK: 临时方案,等待更好的实现
|
||||||
|
|
||||||
|
# NOTE: 重要说明
|
||||||
|
# NOTE: 此函数会修改全局状态,谨慎使用
|
||||||
|
# NOTE: 性能敏感代码,避免频繁调用
|
||||||
|
|
||||||
|
# WARNING: 警告信息
|
||||||
|
# WARNING: 不要在 _ready() 之前调用此函数
|
||||||
|
# WARNING: 此操作不可逆,请确认后执行
|
||||||
|
|
||||||
|
# OPTIMIZE: 性能优化点
|
||||||
|
# OPTIMIZE: 可以使用对象池优化内存分配
|
||||||
|
# OPTIMIZE: 考虑使用缓存提高查询效率
|
||||||
|
```
|
||||||
|
|
||||||
|
### 版本和兼容性标记
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# @since 1.0.0 - 添加基础移动功能
|
||||||
|
# @deprecated 使用 new_movement_system() 替代
|
||||||
|
# @godot_version 4.5+ - 需要 Godot 4.5 或更高版本
|
||||||
|
# @platform_specific Windows/Linux - 仅在桌面平台可用
|
||||||
|
```
|
||||||
|
|
||||||
|
## AI辅助注释指南
|
||||||
|
|
||||||
|
### 为AI提供的注释模板
|
||||||
|
|
||||||
|
当需要AI帮助补充注释时,请使用以下模板:
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# [AI_COMMENT_REQUEST]
|
||||||
|
# 请为以下函数添加详细注释,包括:
|
||||||
|
# - 功能描述
|
||||||
|
# - 参数说明
|
||||||
|
# - 返回值说明
|
||||||
|
# - 使用示例
|
||||||
|
# - 注意事项
|
||||||
|
func complex_function(param1: String, param2: int) -> Dictionary:
|
||||||
|
# 复杂的业务逻辑...
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
### AI注释补充规则
|
||||||
|
|
||||||
|
1. **保持一致性** - 遵循项目现有的注释风格
|
||||||
|
2. **关注业务逻辑** - 重点解释业务含义,而非语法
|
||||||
|
3. **提供上下文** - 说明函数在整个系统中的作用
|
||||||
|
4. **标注复杂度** - 对复杂算法提供额外说明
|
||||||
|
|
||||||
|
### 示例:AI补充前后对比
|
||||||
|
|
||||||
|
**补充前:**
|
||||||
|
```gdscript
|
||||||
|
func calculate_damage(base_damage: int, armor: int, resistance: float) -> int:
|
||||||
|
var final_damage = base_damage
|
||||||
|
final_damage -= armor
|
||||||
|
final_damage *= (1.0 - resistance)
|
||||||
|
return max(1, final_damage)
|
||||||
|
```
|
||||||
|
|
||||||
|
**AI补充后:**
|
||||||
|
```gdscript
|
||||||
|
# 计算最终伤害值
|
||||||
|
#
|
||||||
|
# 根据基础伤害、护甲值和抗性计算实际造成的伤害
|
||||||
|
# 伤害计算公式: (基础伤害 - 护甲) × (1 - 抗性)
|
||||||
|
#
|
||||||
|
# 参数:
|
||||||
|
# base_damage: int - 基础伤害值
|
||||||
|
# armor: int - 目标护甲值 (减少固定伤害)
|
||||||
|
# resistance: float - 目标抗性 (0.0-1.0, 减少百分比伤害)
|
||||||
|
#
|
||||||
|
# 返回值:
|
||||||
|
# int - 最终伤害值 (最小为1,确保至少造成1点伤害)
|
||||||
|
#
|
||||||
|
# 使用示例:
|
||||||
|
# var damage = calculate_damage(100, 20, 0.3) # 结果: 56
|
||||||
|
#
|
||||||
|
# 注意事项:
|
||||||
|
# - 护甲为负值时会增加伤害
|
||||||
|
# - 抗性超过1.0时可能导致负伤害,但会被限制为1
|
||||||
|
func calculate_damage(base_damage: int, armor: int, resistance: float) -> int:
|
||||||
|
var final_damage = base_damage
|
||||||
|
final_damage -= armor # 减去护甲值
|
||||||
|
final_damage *= (1.0 - resistance) # 应用抗性
|
||||||
|
return max(1, final_damage) # 确保最小伤害为1
|
||||||
|
```
|
||||||
|
## 注释最佳实践
|
||||||
|
|
||||||
|
### 什么时候需要注释
|
||||||
|
|
||||||
|
**必须添加注释的情况:**
|
||||||
|
- 复杂的算法和业务逻辑
|
||||||
|
- 非显而易见的设计决策
|
||||||
|
- 临时解决方案和已知问题
|
||||||
|
- 公共API和接口函数
|
||||||
|
- 性能敏感的代码段
|
||||||
|
- 平台特定或版本特定的代码
|
||||||
|
|
||||||
|
**不需要注释的情况:**
|
||||||
|
- 显而易见的代码 (`var count = 0 # 计数器` ❌)
|
||||||
|
- 重复函数名的注释 (`func get_name() -> String: # 获取名称` ❌)
|
||||||
|
- 过时或错误的注释
|
||||||
|
|
||||||
|
### 注释维护原则
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# ✅ 好的注释 - 解释为什么这样做
|
||||||
|
# 使用二分查找提高大数组的查询效率
|
||||||
|
# 当数组长度超过100时,线性查找性能会显著下降
|
||||||
|
func binary_search(array: Array, target: Variant) -> int:
|
||||||
|
|
||||||
|
# ❌ 坏的注释 - 重复代码内容
|
||||||
|
# 遍历数组查找目标值
|
||||||
|
func linear_search(array: Array, target: Variant) -> int:
|
||||||
|
```
|
||||||
|
|
||||||
|
### 团队协作注释
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
# 多人协作时的注释规范
|
||||||
|
class_name NetworkManager
|
||||||
|
|
||||||
|
# @author: 张三 - 网络连接模块
|
||||||
|
# @author: 李四 - 数据同步模块
|
||||||
|
# @reviewer: 王五 - 代码审查
|
||||||
|
# @last_modified: 2024-12-24
|
||||||
|
|
||||||
|
# 网络连接状态枚举
|
||||||
|
#
|
||||||
|
# 定义了客户端与服务器的连接状态
|
||||||
|
# 状态转换: DISCONNECTED -> CONNECTING -> CONNECTED -> DISCONNECTED
|
||||||
|
enum ConnectionState {
|
||||||
|
DISCONNECTED, # 未连接
|
||||||
|
CONNECTING, # 连接中
|
||||||
|
CONNECTED, # 已连接
|
||||||
|
RECONNECTING # 重连中 - @added by 李四 2024-12-20
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注释检查清单
|
||||||
|
|
||||||
|
在提交代码前,请检查以下项目:
|
||||||
|
|
||||||
|
### 文件级别检查
|
||||||
|
- [ ] 文件头注释完整(文件名、作用、主要功能)
|
||||||
|
- [ ] 依赖关系说明清楚
|
||||||
|
- [ ] 作者和创建时间已填写
|
||||||
|
|
||||||
|
### 函数级别检查
|
||||||
|
- [ ] 公共函数有完整的参数和返回值说明
|
||||||
|
- [ ] 复杂函数有使用示例
|
||||||
|
- [ ] 特殊情况和注意事项已标注
|
||||||
|
|
||||||
|
### 代码级别检查
|
||||||
|
- [ ] 复杂逻辑有行内注释说明
|
||||||
|
- [ ] 魔法数字有常量定义和注释
|
||||||
|
- [ ] TODO/FIXME 标记有明确的处理计划
|
||||||
|
|
||||||
|
### 质量检查
|
||||||
|
- [ ] 注释内容准确,与代码一致
|
||||||
|
- [ ] 中文表达清晰,无错别字
|
||||||
|
- [ ] 注释格式符合项目规范
|
||||||
|
|
||||||
|
## 注释工具和插件
|
||||||
|
|
||||||
|
### Godot编辑器设置
|
||||||
|
```
|
||||||
|
# 在 Godot 编辑器中设置注释快捷键
|
||||||
|
# 编辑器设置 -> 快捷键 -> 注释/取消注释: Ctrl+/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 推荐的注释插件
|
||||||
|
- **GDScript Language Server** - 提供注释语法高亮
|
||||||
|
- **Code Formatter** - 自动格式化注释
|
||||||
|
- **Documentation Generator** - 自动生成API文档
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 总结
|
||||||
|
|
||||||
|
良好的注释是代码质量的重要组成部分。遵循本规范可以:
|
||||||
|
|
||||||
|
1. **提高代码可读性** - 帮助团队成员快速理解代码
|
||||||
|
2. **降低维护成本** - 减少后期修改和调试时间
|
||||||
|
3. **促进知识传承** - 保留设计思路和业务逻辑
|
||||||
|
4. **支持AI辅助开发** - 为AI提供更好的上下文信息
|
||||||
|
|
||||||
|
记住:**好的注释解释为什么,而不是做什么。**
|
||||||
@@ -404,6 +404,37 @@ FONT_MAIN.ttf
|
|||||||
- 全部使用小写字母
|
- 全部使用小写字母
|
||||||
- 同系列资源使用数字后缀,如 `tile_01.png`、`tile_02.png`
|
- 同系列资源使用数字后缀,如 `tile_01.png`、`tile_02.png`
|
||||||
|
|
||||||
|
### 扩展资源类型
|
||||||
|
|
||||||
|
```
|
||||||
|
✅ 正确
|
||||||
|
# 材质资源
|
||||||
|
material_metal.tres # 金属材质
|
||||||
|
material_wood.tres # 木材材质
|
||||||
|
material_water.tres # 水材质
|
||||||
|
|
||||||
|
# 着色器资源
|
||||||
|
shader_water.gdshader # 水着色器
|
||||||
|
shader_fire.gdshader # 火焰着色器
|
||||||
|
shader_outline.gdshader # 轮廓着色器
|
||||||
|
|
||||||
|
# 特效资源
|
||||||
|
fx_explosion.png # 爆炸特效
|
||||||
|
fx_magic_circle.png # 魔法阵特效
|
||||||
|
fx_damage_numbers.png # 伤害数字特效
|
||||||
|
|
||||||
|
# 环境资源
|
||||||
|
obj_tree.png # 树木对象
|
||||||
|
obj_rock.png # 岩石对象
|
||||||
|
tile_grass_01.png # 草地瓦片
|
||||||
|
tile_stone_01.png # 石头瓦片
|
||||||
|
|
||||||
|
❌ 错误
|
||||||
|
MetalMaterial.tres # 不使用大驼峰
|
||||||
|
material-wood.tres # 不使用连字符
|
||||||
|
SHADER_WATER.gdshader # 不使用全大写
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 目录结构
|
## 目录结构
|
||||||
@@ -421,11 +452,33 @@ assets/ # 资源目录
|
|||||||
sounds/ # 音效
|
sounds/ # 音效
|
||||||
music/ # 音乐
|
music/ # 音乐
|
||||||
fonts/ # 字体
|
fonts/ # 字体
|
||||||
|
materials/ # 材质
|
||||||
|
shaders/ # 着色器
|
||||||
data/ # 数据目录
|
data/ # 数据目录
|
||||||
levels/ # 关卡数据
|
levels/ # 关卡数据
|
||||||
configs/ # 配置文件
|
configs/ # 配置文件
|
||||||
|
dialogues/ # 对话数据
|
||||||
|
localization/ # 本地化数据
|
||||||
|
core/ # 核心系统目录
|
||||||
|
managers/ # 管理器
|
||||||
|
systems/ # 系统组件
|
||||||
|
utils/ # 工具类
|
||||||
|
components/ # 通用组件
|
||||||
|
interfaces/ # 接口定义
|
||||||
|
module/ # 模块目录
|
||||||
|
UI/ # UI模块
|
||||||
|
Character/ # 角色模块
|
||||||
|
Inventory/ # 背包模块
|
||||||
|
Combat/ # 战斗模块
|
||||||
|
Dialogue/ # 对话模块
|
||||||
addons/ # 插件目录
|
addons/ # 插件目录
|
||||||
tests/ # 测试目录
|
tests/ # 测试目录
|
||||||
|
unit/ # 单元测试
|
||||||
|
integration/ # 集成测试
|
||||||
|
ui/ # UI测试
|
||||||
|
performance/ # 性能测试
|
||||||
|
docs/ # 文档目录
|
||||||
|
auth/ # 认证相关文档
|
||||||
|
|
||||||
❌ 错误
|
❌ 错误
|
||||||
Scenes/ # 不使用大写
|
Scenes/ # 不使用大写
|
||||||