chore:完善项目目录结构和基础框架
- 添加核心系统框架目录结构 - 创建游戏模块化组织架构 - 添加数据配置和本地化支持 - 建立脚本分类管理体系 - 创建场景预制件管理目录
This commit is contained in:
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