fix/verification-code-button-state #1
1
core/components/.gitkeep
Normal file
1
core/components/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 组件脚本目录
|
||||
1
core/input_box/.gitkeep
Normal file
1
core/input_box/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 输入框组件目录
|
||||
1
core/interfaces/.gitkeep
Normal file
1
core/interfaces/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 接口定义目录
|
||||
50
core/managers/GameManager.gd
Normal file
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
1
core/managers/GameManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c6bl6k5kkfah6
|
||||
75
core/managers/SceneManager.gd
Normal file
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/main_scene.tscn",
|
||||
"auth": "res://scenes/auth_scene.tscn",
|
||||
"game": "res://scenes/game_scene.tscn",
|
||||
"battle": "res://scenes/battle_scene.tscn",
|
||||
"inventory": "res://scenes/inventory_scene.tscn",
|
||||
"shop": "res://scenes/shop_scene.tscn",
|
||||
"settings": "res://scenes/settings_scene.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
1
core/managers/SceneManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bf5bmaqwstpuq
|
||||
80
core/systems/EventSystem.gd
Normal file
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
1
core/systems/EventSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://csuxtwgni1dmf
|
||||
105
core/utils/StringUtils.gd
Normal file
105
core/utils/StringUtils.gd
Normal file
@@ -0,0 +1,105 @@
|
||||
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]]
|
||||
1
core/utils/StringUtils.gd.uid
Normal file
1
core/utils/StringUtils.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bturviv4bm4yk
|
||||
1
data/characters/.gitkeep
Normal file
1
data/characters/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 角色数据目录
|
||||
29
data/configs/game_config.json
Normal file
29
data/configs/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
|
||||
}
|
||||
}
|
||||
}
|
||||
1
data/dialogues/.gitkeep
Normal file
1
data/dialogues/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 对话数据目录
|
||||
1
data/items/.gitkeep
Normal file
1
data/items/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 物品数据目录
|
||||
1
data/levels/.gitkeep
Normal file
1
data/levels/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 关卡数据目录
|
||||
36
data/localization/zh_CN.json
Normal file
36
data/localization/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": "设置"
|
||||
}
|
||||
}
|
||||
1
module/Character/.gitkeep
Normal file
1
module/Character/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 角色模块目录
|
||||
1
module/Combat/.gitkeep
Normal file
1
module/Combat/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 战斗模块目录
|
||||
1
module/Dialogue/.gitkeep
Normal file
1
module/Dialogue/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 对话模块目录
|
||||
1
module/Inventory/.gitkeep
Normal file
1
module/Inventory/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 背包模块目录
|
||||
1
module/UI/animations/.gitkeep
Normal file
1
module/UI/animations/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - UI动画目录
|
||||
1
module/UI/components/.gitkeep
Normal file
1
module/UI/components/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - UI组件目录
|
||||
1
module/UI/layouts/.gitkeep
Normal file
1
module/UI/layouts/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - UI布局目录
|
||||
1
scenes/prefabs/characters/.gitkeep
Normal file
1
scenes/prefabs/characters/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 角色预制体目录
|
||||
1
scenes/prefabs/effects/.gitkeep
Normal file
1
scenes/prefabs/effects/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 特效预制体目录
|
||||
1
scenes/prefabs/items/.gitkeep
Normal file
1
scenes/prefabs/items/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 物品预制体目录
|
||||
1
scenes/prefabs/ui/.gitkeep
Normal file
1
scenes/prefabs/ui/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - UI预制体目录
|
||||
1
scripts/characters/.gitkeep
Normal file
1
scripts/characters/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 角色脚本目录
|
||||
1
scripts/data/.gitkeep
Normal file
1
scripts/data/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 数据脚本目录
|
||||
1
scripts/gameplay/.gitkeep
Normal file
1
scripts/gameplay/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - 游戏玩法脚本目录
|
||||
31
scripts/network/NetworkTest.gd
Normal file
31
scripts/network/NetworkTest.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends Node
|
||||
|
||||
# 简单的API测试脚本
|
||||
const API_BASE_URL = "https://whaletownend.xinghangee.icu"
|
||||
|
||||
func _ready():
|
||||
print("API测试脚本已加载")
|
||||
print("服务器地址: ", API_BASE_URL)
|
||||
|
||||
# 测试服务器连接
|
||||
test_server_status()
|
||||
|
||||
func test_server_status():
|
||||
var http_request = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.request_completed.connect(_on_status_request_completed)
|
||||
|
||||
print("正在测试服务器连接...")
|
||||
var error = http_request.request(API_BASE_URL)
|
||||
if error != OK:
|
||||
print("请求失败: ", error)
|
||||
|
||||
func _on_status_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
|
||||
var response_text = body.get_string_from_utf8()
|
||||
print("服务器状态响应: ", response_code)
|
||||
print("响应内容: ", response_text)
|
||||
|
||||
if response_code == 200:
|
||||
print("✅ 服务器连接正常")
|
||||
else:
|
||||
print("❌ 服务器连接失败")
|
||||
1
scripts/network/NetworkTest.gd.uid
Normal file
1
scripts/network/NetworkTest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bsfrdqpsvwgtb
|
||||
1
scripts/scenes/AuthScene.gd.uid
Normal file
1
scripts/scenes/AuthScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://nv8eitxieqtm
|
||||
116
scripts/scenes/MainScene.gd
Normal file
116
scripts/scenes/MainScene.gd
Normal file
@@ -0,0 +1,116 @@
|
||||
extends Control
|
||||
|
||||
# 场景节点引用
|
||||
@onready var auth_scene: Control = $AuthScene
|
||||
@onready var main_game_ui: Control = $MainGameUI
|
||||
@onready var user_label: Label = $MainGameUI/TopBar/HBoxContainer/UserLabel
|
||||
@onready var logout_button: Button = $MainGameUI/TopBar/HBoxContainer/LogoutButton
|
||||
|
||||
# 游戏功能按钮
|
||||
@onready var explore_button: Button = $MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid/ExploreButton
|
||||
@onready var inventory_button: Button = $MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid/InventoryButton
|
||||
@onready var shop_button: Button = $MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid/ShopButton
|
||||
@onready var friends_button: Button = $MainGameUI/MainContent/CenterContainer/VBoxContainer/GameMenuGrid/FriendsButton
|
||||
|
||||
# 状态标签
|
||||
@onready var level_label: Label = $MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel/StatusContainer/StatusGrid/LevelLabel
|
||||
@onready var coins_label: Label = $MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel/StatusContainer/StatusGrid/CoinsLabel
|
||||
@onready var exp_label: Label = $MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel/StatusContainer/StatusGrid/ExpLabel
|
||||
@onready var energy_label: Label = $MainGameUI/MainContent/CenterContainer/VBoxContainer/StatusPanel/StatusContainer/StatusGrid/EnergyLabel
|
||||
|
||||
# 游戏状态
|
||||
enum GameState {
|
||||
AUTH, # 登录/注册状态
|
||||
MAIN_GAME # 主游戏状态
|
||||
}
|
||||
|
||||
var current_state: GameState = GameState.AUTH
|
||||
var current_user: String = ""
|
||||
|
||||
# 玩家数据
|
||||
var player_level: int = 1
|
||||
var player_coins: int = 100
|
||||
var player_exp: int = 0
|
||||
var player_max_exp: int = 100
|
||||
var player_energy: int = 100
|
||||
var player_max_energy: int = 100
|
||||
|
||||
func _ready():
|
||||
# 初始化游戏状态
|
||||
setup_game()
|
||||
|
||||
# 连接登录成功信号
|
||||
auth_scene.login_success.connect(_on_login_success)
|
||||
|
||||
# 连接按钮信号
|
||||
logout_button.pressed.connect(_on_logout_pressed)
|
||||
explore_button.pressed.connect(_on_explore_pressed)
|
||||
inventory_button.pressed.connect(_on_inventory_pressed)
|
||||
shop_button.pressed.connect(_on_shop_pressed)
|
||||
friends_button.pressed.connect(_on_friends_pressed)
|
||||
|
||||
func setup_game():
|
||||
# 设置初始状态为登录界面
|
||||
show_auth_scene()
|
||||
|
||||
func show_auth_scene():
|
||||
current_state = GameState.AUTH
|
||||
auth_scene.visible = true
|
||||
main_game_ui.visible = false
|
||||
|
||||
func show_main_game():
|
||||
current_state = GameState.MAIN_GAME
|
||||
auth_scene.visible = false
|
||||
main_game_ui.visible = true
|
||||
user_label.text = "当前用户: " + current_user
|
||||
update_player_status()
|
||||
print("进入主游戏界面")
|
||||
|
||||
func update_player_status():
|
||||
level_label.text = "等级: " + str(player_level)
|
||||
coins_label.text = "金币: " + str(player_coins)
|
||||
exp_label.text = "经验: " + str(player_exp) + "/" + str(player_max_exp)
|
||||
energy_label.text = "体力: " + str(player_energy) + "/" + str(player_max_energy)
|
||||
|
||||
func _on_login_success(username: String):
|
||||
# 登录成功后的处理
|
||||
current_user = username
|
||||
print("用户 ", username, " 登录成功!")
|
||||
show_main_game()
|
||||
|
||||
func _on_logout_pressed():
|
||||
# 登出处理
|
||||
current_user = ""
|
||||
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 _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
match current_state:
|
||||
GameState.AUTH:
|
||||
# 在登录界面按ESC退出游戏
|
||||
get_tree().quit()
|
||||
GameState.MAIN_GAME:
|
||||
# 在游戏中按ESC可能显示菜单或返回登录
|
||||
show_auth_scene()
|
||||
1
scripts/scenes/MainScene.gd.uid
Normal file
1
scripts/scenes/MainScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cejrxy23ldhug
|
||||
1
scripts/ui/.gitkeep
Normal file
1
scripts/ui/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# 保持目录结构 - UI脚本目录
|
||||
Reference in New Issue
Block a user