合并主场景和个人小屋

This commit is contained in:
王浩
2026-02-07 14:11:00 +08:00
parent 603e7d9fc6
commit 326ab7ce5c
360 changed files with 4913 additions and 21701 deletions

View File

@@ -76,7 +76,6 @@ func show_main_game():
main_game_ui.visible = true
user_label.text = "当前用户: " + current_user
update_player_status()
print("进入主游戏界面")
func update_player_status():
level_label.text = "等级: " + str(player_level)
@@ -87,48 +86,66 @@ func update_player_status():
func _on_login_success(username: String):
# 登录成功后的处理
current_user = username
print("用户 ", username, " 登录成功!")
# 连接到聊天服务器(在进入游戏界面之前)
# 注意token 已在 AuthScene._on_controller_login_success 中设置
print("🔌 开始连接聊天服务器...")
ChatManager.connect_to_chat_server()
show_main_game()
# 连接到位置同步服务器
LocationManager.connect_to_server()
# 登录成功后隐藏聊天框需要按Enter才显示
chat_ui.hide_chat()
# 直接进入游戏地图不显示MainGameUI
_setup_game_environment()
func _on_logout_pressed():
# 登出处理
current_user = ""
# 断开聊天服务器连接
print("🔌 断开聊天服务器...")
ChatManager.disconnect_from_chat_server()
show_auth_scene()
# 游戏功能按钮处理
func _on_explore_pressed():
print("探索小镇功能")
show_game_message("🗺️ 探索功能开发中...")
func _on_inventory_pressed():
print("背包功能")
show_game_message("🎒 背包功能开发中...")
func _on_shop_pressed():
print("商店功能")
show_game_message("🏪 商店功能开发中...")
func _on_friends_pressed():
print("好友功能")
show_game_message("👥 好友功能开发中...")
func show_game_message(message: String):
print("游戏消息: ", message)
# 这里可以添加UI提示框显示消息
func show_game_message(_message: String):
# TODO: 用 Toast 或游戏内提示框替代占位实现
pass
# 设置游戏环境(登录后直接加载地图)
func _setup_game_environment():
# 防止登录切场景时输入状态残留导致角色“卡移动键”
_release_movement_actions()
# 1. 隐藏UI
current_state = GameState.MAIN_GAME
auth_scene.visible = false
main_game_ui.visible = false
# 2. 隐藏聊天框需要按Enter才显示
if is_instance_valid(chat_ui) and chat_ui.has_method("hide_chat"):
chat_ui.hide_chat()
# 3. 使用 SceneManager 切换到广场地图
SceneManager.change_scene("square", false) # false = 不使用过渡效果
func _release_movement_actions() -> void:
Input.action_release("move_left")
Input.action_release("move_right")
Input.action_release("move_up")
Input.action_release("move_down")
Input.flush_buffered_events()
# 处理全局输入
func _input(event):