forked from moyin/whale-town-front
## 🏗️ 主要变更 ### 目录结构重构 - 将 core/ 迁移到 _Core/(框架层) - 将 scenes/ 重构为 Scenes/(玩法层)和 UI/(界面层) - 将 data/ 迁移到 Config/(配置层) - 添加 Assets/ 资源层和 Utils/ 工具层 - 将 scripts/ 迁移到 tools/(开发工具) ### 架构分层 - **_Core/**: 框架层 - 全局单例和管理器 - **Scenes/**: 玩法层 - 游戏场景和实体 - **UI/**: 界面层 - HUD、窗口、对话系统 - **Assets/**: 资源层 - 精灵图、音频、字体 - **Config/**: 配置层 - 游戏配置和本地化 - **Utils/**: 工具层 - 通用辅助脚本 ### 文件更新 - 更新 project.godot 中的所有路径引用 - 更新自动加载脚本路径 - 更新测试文件的引用路径 - 添加 REFACTORING.md 详细说明 - 添加 MIGRATION_COMPLETE.md 迁移完成标记 - 更新 README.md 反映新架构 ### 设计原则 - ✅ 清晰的分层(框架/玩法/界面) - ✅ 场景内聚(脚本紧邻场景文件) - ✅ 组件化设计(可复用组件) - ✅ 职责单一(每个目录职责明确) ## 📋 详细信息 查看 REFACTORING.md 了解完整的重构说明和迁移映射表 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
51 lines
1.2 KiB
GDScript
51 lines
1.2 KiB
GDScript
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()
|