Compare commits

..

21 Commits

Author SHA1 Message Date
Tiger db110e479f Merge branch 'develop' into 'master'
更新引擎版本

See merge request paper-chemis-community/game!6
2026-04-02 09:16:17 +08:00
Tiger 46d5c98b4e feat: 优化项目结构,更新引擎版本 2026-04-02 09:15:43 +08:00
Tiger 2fbc3c80cf feat: 修复bug 2026-04-01 13:29:48 +08:00
Tiger 4b1664f9e9 Merge branch 'develop' into 'master'
修复本地化bug

See merge request paper-chemis-community/game!5
2026-04-01 13:09:04 +08:00
Tiger 40b2476e63 feat: 修复本地化bug 2026-04-01 12:32:04 +08:00
Tiger 443b701bc9 Merge branch 'develop' into 'master'
UI优化,增加本地化功能

See merge request paper-chemis-community/game!4
2026-04-01 09:34:32 +08:00
Tiger 42f36a142e feat: 完成对游戏当前内容的翻译 2026-04-01 09:33:43 +08:00
Tiger feb5d4b030 feat: 完成本地化代码并部分翻译 2026-04-01 09:25:22 +08:00
Tiger 3258c22b18 feat: 初步实现卡牌位置相关函数 2026-03-31 20:02:46 +08:00
Tiger 588d812939 feat: 优化UI操作逻辑,增加退出游戏按钮 2026-03-31 19:54:11 +08:00
Tiger 94fb054be3 Merge branch 'develop' into 'master'
基本完成多人游戏框架

See merge request paper-chemis-community/game!3
2026-03-05 21:12:00 +08:00
Tiger 92a2ec38e0 feat: 基本完成多人游戏框架 2026-03-05 21:10:25 +08:00
Tiger 6980dd44b1 feat: 优化了代码逻辑 2026-02-23 16:32:11 +08:00
Tiger 65981e516c feat: 优化多人游戏框架 2026-02-22 15:22:24 +08:00
Tiger 53e56845dc feat: 搭建多人游戏框架 2026-02-22 12:55:49 +08:00
Tiger 0b4f67fc2f feat: 增加服务器信号 2026-02-18 21:15:04 +08:00
Tiger 117f097bb2 feat: 更新README 2026-02-17 21:05:38 +08:00
Tiger 851f8442fc feat: 更改了项目logo 2026-02-17 18:30:11 +08:00
Tiger 52a4e31067 Merge branch 'develop' into 'master'
做好了开发游戏玩法的准备

See merge request paper-chemis-community/game!2
2026-02-16 20:41:39 +08:00
Tiger a7ba031568 feat: 更改窗口尺寸为2560*1440 2026-02-16 20:39:58 +08:00
Tiger 8e8a9b368e Merge branch 'develop' into 'master'
完成基础功能

See merge request paper-chemis-community/game!1
2026-02-14 10:24:47 +08:00
21 changed files with 343 additions and 130 deletions
+12 -8
View File
@@ -16,13 +16,14 @@ game/
- assets/ - assets/
- fonts/ - fonts/
- AlibabaPuHuiTi-3-65-Medium.ttf # 阿里巴巴普惠体 - AlibabaPuHuiTi-3-65-Medium.ttf # 阿里巴巴普惠体
- pics/ - translation/
- scenes - trans.csv
- scenes/
- menus/
- main_menu.tscn - main_menu.tscn
- game.tscn
- settings.tscn - settings.tscn
- prefabs/
- game/ - game/
- game.tscn
- card.tscn - card.tscn
- scripts/ - scripts/
- autoload/ - autoload/
@@ -36,20 +37,23 @@ game/
- create_game_ui.gd - create_game_ui.gd
- game/ - game/
- game.gd - game.gd
- card.gd
- settings/ - settings/
- settings.gd - settings.gd
``` ```
## 如何运行 ## 如何运行
请先运行数据后端,在游戏设置中输入后端 URL包含端口号和 `http://``https://` 前缀,或者选择本地已有的数据源,然后创建游戏或加入游戏开始游玩。 请先运行数据后端,在游戏设置中输入后端 URL包含端口号和 `http://``https://` 前缀,或者选择本地已有的数据源,然后创建游戏或加入游戏开始游玩。
## 最佳实践 ## 最佳实践
本项目目前正在使用 Godot 4.6 进行开发。开发用语言为 GDScript。 本项目目前正在使用 Godot 4.6.2 进行开发。开发用语言为 GDScript。
你的开发应当遵循 Godot 引擎提供的[最佳实践](https://docs.godotengine.org/zh-cn/4.x/tutorials/best_practices/)及[GDScript 编写风格指南](https://docs.godotengine.org/zh-cn/4.x/tutorials/scripting/gdscript/gdscript_styleguide.html)。但下面提到的除外: 你的开发应当遵循 Godot 引擎提供的[最佳实践](https://docs.godotengine.org/zh-cn/4.x/tutorials/best_practices/)及[GDScript 编写风格指南](https://docs.godotengine.org/zh-cn/4.x/tutorials/scripting/gdscript/gdscript_styleguide.html)。但下面提到的除外:
`autoload` 目录下的单例脚本使用大驼峰式命名,其余脚本均应使用小蛇形式命。所有节点均应使用大驼峰式命名。 - `autoload` 目录下的单例脚本使用大驼峰式命名,其余脚本均应使用小蛇形式命。所有节点均应使用大驼峰式命名。
除连接了信号或 HTTPRequest、MultiplayerAPI 的函数外,任何函数都不应该以下划线(`_`)开头。 - 除连接了信号或 HTTPRequest、MultiplayerAPI 的函数外,任何函数都不应该以下划线(`_`)开头。
- 函数之间只需间隔一行,无需间隔两行。
+34
View File
@@ -0,0 +1,34 @@
keys,en,zh-cn
en,English,English
zh-cn,简体中文,简体中文
MAINMENU_TITLE,Paper Chemis Community,纸片化学社区版
UI_CONFIRM,Confirm,确定
MAINMENU_CREATEGAME,Create LAN Game,创建局域网游戏
MAINMENU_INPUTPLAYERNUM,Please Input max Player Number (2~4),请输入最大玩家数24
MAINMENU_PLAYERNUMERROR,Error! Please Input an integer between 2 and 4,输入数据错误请输入24之间的整数
MAINMENU_CREATEROOM,Create Room,创建房间
MAINMENU_JOINGAME,Join LAN Game,加入局域网游戏
MAINMENU_INPUTSERVERIP,Please Input IP Address (No Port),请输入服务器IP无需加端口
MAINMENU_JOINROOM,Join Room,加入房间
MAINMENU_QUITGAME,Quit Game,退出游戏
MAINMENU_SETTINGS,Settings,设置
SETTINGS_SETSOURCE,Set Data Source,数据源设置
SETTINGS_IPBEGIN,Auto IP Beginning,自动识别 IP 地址的起始部分
SETTINGS_NICKNAME,Nickname in Game,局内显示昵称
SETTINGS_LOADDATA,Load Local Data,加载本地数据
SETTINGS_SAVESETTINGS,Save Settings,保存设置
SETTINGS_BACK,Back,返回
SETTINGS_DOWNLOAD,Download,下载文件
SETTINGS_LOAD,Load Data,加载数据
SETTINGS_CHOOSELANG,Choose Language,选择语言
SETTINGS_TIP_NULL,Tip: None,提示:无
SETTINGS_TIP_SAVESETTINGS,Tip: Successfully saved settings,提示:保存设置成功
SETTINGS_TIP_STARTDOWNLOAD,Tip: Have started downloading. do not close the settings page,提示:已开始下载,请勿关闭设置页面
SETTINGS_TIP_SOURCEERROR,Tip: Download failed. Data source path error,提示:下载失败。数据源路径错误
SETTINGS_TIP_REQUESTERROR,Tip: Download failed. Failed to create a request,提示:下载失败。创建请求失败
SETTINGS_TIP_LOADING,Tip: Loading Resources. do not close the settings page,提示:正在加载资源,请勿关闭设置页面
SETTINGS_TIP_LOADED,Tip: Finish Loading,提示:完成加载
SETTINGS_TIP_NOLOCALSOURCE,Tip: No local data or no selection,提示:无本地数据或未选择,无法加载
GAMEUI_URNULL,Room Running: You are XXX XXXX,啊啊啊啊啊:啊啊啊啊
GAMEUI_URHOST,Room Running: You are the Host,房间运行中:您是房主
GAMEUI_URGUEST,Room Running: You are a Guest,房间运行中:您是房客
1 keys en zh-cn
2 en English English
3 zh-cn 简体中文 简体中文
4 MAINMENU_TITLE Paper Chemis Community 纸片化学社区版
5 UI_CONFIRM Confirm 确定
6 MAINMENU_CREATEGAME Create LAN Game 创建局域网游戏
7 MAINMENU_INPUTPLAYERNUM Please Input max Player Number (2~4) 请输入最大玩家数(2~4)
8 MAINMENU_PLAYERNUMERROR Error! Please Input an integer between 2 and 4 输入数据错误!请输入2~4之间的整数!
9 MAINMENU_CREATEROOM Create Room 创建房间
10 MAINMENU_JOINGAME Join LAN Game 加入局域网游戏
11 MAINMENU_INPUTSERVERIP Please Input IP Address (No Port) 请输入服务器IP(无需加端口)
12 MAINMENU_JOINROOM Join Room 加入房间
13 MAINMENU_QUITGAME Quit Game 退出游戏
14 MAINMENU_SETTINGS Settings 设置
15 SETTINGS_SETSOURCE Set Data Source 数据源设置
16 SETTINGS_IPBEGIN Auto IP Beginning 自动识别 IP 地址的起始部分
17 SETTINGS_NICKNAME Nickname in Game 局内显示昵称
18 SETTINGS_LOADDATA Load Local Data 加载本地数据
19 SETTINGS_SAVESETTINGS Save Settings 保存设置
20 SETTINGS_BACK Back 返回
21 SETTINGS_DOWNLOAD Download 下载文件
22 SETTINGS_LOAD Load Data 加载数据
23 SETTINGS_CHOOSELANG Choose Language 选择语言
24 SETTINGS_TIP_NULL Tip: None 提示:无
25 SETTINGS_TIP_SAVESETTINGS Tip: Successfully saved settings 提示:保存设置成功
26 SETTINGS_TIP_STARTDOWNLOAD Tip: Have started downloading. do not close the settings page 提示:已开始下载,请勿关闭设置页面
27 SETTINGS_TIP_SOURCEERROR Tip: Download failed. Data source path error 提示:下载失败。数据源路径错误
28 SETTINGS_TIP_REQUESTERROR Tip: Download failed. Failed to create a request 提示:下载失败。创建请求失败
29 SETTINGS_TIP_LOADING Tip: Loading Resources. do not close the settings page 提示:正在加载资源,请勿关闭设置页面
30 SETTINGS_TIP_LOADED Tip: Finish Loading 提示:完成加载
31 SETTINGS_TIP_NOLOCALSOURCE Tip: No local data or no selection 提示:无本地数据或未选择,无法加载
32 GAMEUI_URNULL Room Running: You are XXX XXXX 啊啊啊啊啊:啊啊啊啊
33 GAMEUI_URHOST Room Running: You are the Host 房间运行中:您是房主
34 GAMEUI_URGUEST Room Running: You are a Guest 房间运行中:您是房客
+19
View File
@@ -0,0 +1,19 @@
[remap]
importer="csv_translation"
type="Translation"
uid="uid://bkanjeodutw2s"
[deps]
files=["res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation"]
source_file="res://assets/translation/trans.csv"
dest_files=["res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation"]
[params]
compress=1
delimiter=0
unescape_keys=false
unescape_translations=true
Binary file not shown.
Binary file not shown.
+1 -1
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 80 KiB

+1 -1
View File
@@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cc4kcdj5nwnua" uid="uid://b1t4aos7bunb3"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
+6 -2
View File
@@ -28,8 +28,12 @@ DownloadManager="*res://scripts/autoload/DownloadManager.gd"
[display] [display]
window/size/viewport_width=1920 window/size/viewport_width=2560
window/size/viewport_height=1080 window/size/viewport_height=1440
[internationalization]
locale/translations=PackedStringArray("res://assets/translation/trans.en.translation", "res://assets/translation/trans.zh.translation")
[rendering] [rendering]
+11 -11
View File
@@ -9,8 +9,8 @@ script = ExtResource("1_yqjtg")
[node name="Background" type="ColorRect" parent="." unique_id=802635055] [node name="Background" type="ColorRect" parent="." unique_id=802635055]
offset_left = -34.0 offset_left = -34.0
offset_top = -27.0 offset_top = -27.0
offset_right = 1954.0 offset_right = 2594.0
offset_bottom = 1167.0 offset_bottom = 1476.0
color = Color(0.7058824, 0.6862745, 0, 1) color = Color(0.7058824, 0.6862745, 0, 1)
[node name="IsServerLabel" type="Label" parent="." unique_id=592205212] [node name="IsServerLabel" type="Label" parent="." unique_id=592205212]
@@ -20,7 +20,7 @@ offset_right = 255.0
offset_bottom = 63.0 offset_bottom = 63.0
theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_fonts/font = ExtResource("1_uwrxv")
theme_override_font_sizes/font_size = 20 theme_override_font_sizes/font_size = 20
text = "啊啊啊啊啊:啊啊啊啊" text = "GAMEUI_URNULL"
[node name="IPLabel" type="Label" parent="." unique_id=2017838611] [node name="IPLabel" type="Label" parent="." unique_id=2017838611]
offset_left = 54.0 offset_left = 54.0
@@ -34,10 +34,10 @@ text = "127.0.0.2"
[node name="Player1" type="Node2D" parent="." unique_id=1336934388] [node name="Player1" type="Node2D" parent="." unique_id=1336934388]
[node name="Username" type="Label" parent="Player1" unique_id=264475054] [node name="Username" type="Label" parent="Player1" unique_id=264475054]
offset_left = 49.0 offset_left = 70.0
offset_top = 970.0 offset_top = 1338.0
offset_right = 531.0 offset_right = 552.0
offset_bottom = 1028.0 offset_bottom = 1396.0
theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_fonts/font = ExtResource("1_uwrxv")
theme_override_font_sizes/font_size = 35 theme_override_font_sizes/font_size = 35
text = "Player1" text = "Player1"
@@ -45,10 +45,10 @@ text = "Player1"
[node name="Player2" type="Node2D" parent="." unique_id=1559551502] [node name="Player2" type="Node2D" parent="." unique_id=1559551502]
[node name="Username" type="Label" parent="Player2" unique_id=1130366682] [node name="Username" type="Label" parent="Player2" unique_id=1130366682]
offset_left = 1521.0 offset_left = 2121.0
offset_top = 15.0 offset_top = 36.0
offset_right = 1834.0 offset_right = 2434.0
offset_bottom = 73.0 offset_bottom = 94.0
theme_override_fonts/font = ExtResource("1_uwrxv") theme_override_fonts/font = ExtResource("1_uwrxv")
theme_override_font_sizes/font_size = 35 theme_override_font_sizes/font_size = 35
text = "Player2" text = "Player2"
@@ -1,155 +1,164 @@
[gd_scene load_steps=5 format=3 uid="uid://b2rokrdsjgx62"] [gd_scene format=3 uid="uid://b2rokrdsjgx62"]
[ext_resource type="Script" uid="uid://bnieej0tc51ei" path="res://scripts/main_menu/main_menu.gd" id="1_ekxnf"] [ext_resource type="Script" uid="uid://bnieej0tc51ei" path="res://scripts/main_menu/main_menu.gd" id="1_ekxnf"]
[ext_resource type="FontFile" uid="uid://c2bipf4tpdjj8" path="res://assets/fonts/AlibabaPuHuiTi-3-65-Medium.ttf" id="1_l6cm7"] [ext_resource type="FontFile" uid="uid://c2bipf4tpdjj8" path="res://assets/fonts/AlibabaPuHuiTi-3-65-Medium.ttf" id="1_l6cm7"]
[ext_resource type="Script" uid="uid://dxekqwgtgqkg" path="res://scripts/main_menu/create_game_ui.gd" id="3_bqqt6"] [ext_resource type="Script" uid="uid://dxekqwgtgqkg" path="res://scripts/main_menu/create_game_ui.gd" id="3_bqqt6"]
[ext_resource type="Script" uid="uid://cosrsj5i8s26q" path="res://scripts/main_menu/join_game_ui.gd" id="4_wu84c"] [ext_resource type="Script" uid="uid://cosrsj5i8s26q" path="res://scripts/main_menu/join_game_ui.gd" id="4_wu84c"]
[node name="MainMenu" type="Node2D"] [node name="MainMenu" type="Node2D" unique_id=436810236]
script = ExtResource("1_ekxnf") script = ExtResource("1_ekxnf")
[node name="Background" type="ColorRect" parent="."] [node name="Background" type="ColorRect" parent="." unique_id=1930466338]
offset_left = -24.0 offset_left = -24.0
offset_top = -22.0 offset_top = -22.0
offset_right = 1925.0 offset_right = 2631.0
offset_bottom = 1153.0 offset_bottom = 1500.0
color = Color(0.7058824, 0.6862745, 0, 1) color = Color(0.7058824, 0.6862745, 0, 1)
[node name="Title" type="Label" parent="."] [node name="Title" type="Label" parent="." unique_id=1636642337]
offset_left = 540.0 offset_left = 796.0
offset_top = 58.0 offset_top = 88.0
offset_right = 1119.0 offset_right = 1375.0
offset_bottom = 177.0 offset_bottom = 207.0
size_flags_horizontal = 4 size_flags_horizontal = 4
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 84 theme_override_font_sizes/font_size = 84
text = "纸片化学社区版" text = "MAINMENU_TITLE"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="StartGame" type="Button" parent="."] [node name="StartGame" type="Button" parent="." unique_id=1933485497]
offset_left = 672.0 offset_left = 931.0
offset_top = 355.0 offset_top = 533.0
offset_right = 988.03845 offset_right = 1247.0385
offset_bottom = 454.0 offset_bottom = 632.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36 theme_override_font_sizes/font_size = 36
text = "创建局域网游戏" text = "MAINMENU_CREATEGAME"
[node name="JoinGame" type="Button" parent="."] [node name="JoinGame" type="Button" parent="." unique_id=1061477634]
offset_left = 666.0 offset_left = 932.0
offset_top = 509.0 offset_top = 748.0
offset_right = 982.03845 offset_right = 1248.0385
offset_bottom = 608.0 offset_bottom = 847.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36 theme_override_font_sizes/font_size = 36
text = "加入局域网游戏" text = "MAINMENU_JOINGAME"
[node name="CreateGameUI" type="Node2D" parent="."] [node name="QuitGame" type="Button" parent="." unique_id=70898198]
offset_left = 932.0
offset_top = 959.0
offset_right = 1248.0386
offset_bottom = 1058.0
theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36
text = "MAINMENU_QUITGAME"
[node name="CreateGameUI" type="Node2D" parent="." unique_id=462604530]
visible = false visible = false
position = Vector2(585, 355) position = Vector2(585, 355)
script = ExtResource("3_bqqt6") script = ExtResource("3_bqqt6")
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="Background" type="ColorRect" parent="CreateGameUI"] [node name="Background" type="ColorRect" parent="CreateGameUI" unique_id=1379723910]
offset_right = 475.0 offset_right = 475.0
offset_bottom = 257.0 offset_bottom = 257.0
color = Color(0, 0.7372549, 0, 1) color = Color(0, 0.7372549, 0, 1)
[node name="CreateGameEdit" type="LineEdit" parent="CreateGameUI"] [node name="CreateGameEdit" type="LineEdit" parent="CreateGameUI" unique_id=1841600293]
offset_left = 65.0 offset_left = 65.0
offset_top = 26.0 offset_top = 26.0
offset_right = 392.0 offset_right = 392.0
offset_bottom = 87.0 offset_bottom = 87.0
[node name="CreateGameButton" type="Button" parent="CreateGameUI"] [node name="CreateGameButton" type="Button" parent="CreateGameUI" unique_id=1430273388]
offset_left = 128.0 offset_left = 128.0
offset_top = 127.0 offset_top = 127.0
offset_right = 330.81818 offset_right = 330.81818
offset_bottom = 224.0 offset_bottom = 224.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36 theme_override_font_sizes/font_size = 36
text = "创建房间" text = "MAINMENU_CREATEROOM"
[node name="Label" type="Label" parent="CreateGameUI"] [node name="Label" type="Label" parent="CreateGameUI" unique_id=1494594728]
offset_left = 131.0 offset_left = 131.0
offset_top = 88.0 offset_top = 88.0
offset_right = 326.0 offset_right = 326.0
offset_bottom = 126.0 offset_bottom = 126.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "请输入最大玩家数24" text = "MAINMENU_INPUTPLAYERNUM"
[node name="Warn" type="Node2D" parent="CreateGameUI"] [node name="Warn" type="Node2D" parent="CreateGameUI" unique_id=961920457]
visible = false visible = false
[node name="WarnBackground" type="ColorRect" parent="CreateGameUI/Warn"] [node name="WarnBackground" type="ColorRect" parent="CreateGameUI/Warn" unique_id=2017035604]
offset_left = 86.0 offset_left = 86.0
offset_top = 41.0 offset_top = 41.0
offset_right = 366.0 offset_right = 366.0
offset_bottom = 202.0 offset_bottom = 202.0
color = Color(1, 0.3137255, 1, 1) color = Color(1, 0.3137255, 1, 1)
[node name="WarnButton" type="Button" parent="CreateGameUI/Warn"] [node name="WarnButton" type="Button" parent="CreateGameUI/Warn" unique_id=1006038249]
offset_left = 167.0 offset_left = 167.0
offset_top = 125.0 offset_top = 125.0
offset_right = 279.0 offset_right = 279.0
offset_bottom = 188.0 offset_bottom = 188.0
text = "确定" text = "UI_CONFIRM"
[node name="WarnLabel" type="Label" parent="CreateGameUI/Warn"] [node name="WarnLabel" type="Label" parent="CreateGameUI/Warn" unique_id=320937650]
offset_left = 126.0 offset_left = 126.0
offset_top = 64.0 offset_top = 64.0
offset_right = 316.0 offset_right = 316.0
offset_bottom = 107.0 offset_bottom = 107.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "输入数据错误! text = "MAINMENU_PLAYERNUMERROR"
请输入24之间的整数"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="JoinGameUI" type="Node2D" parent="."] [node name="JoinGameUI" type="Node2D" parent="." unique_id=1134060090]
visible = false visible = false
position = Vector2(585, 355) position = Vector2(585, 355)
script = ExtResource("4_wu84c") script = ExtResource("4_wu84c")
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="Background" type="ColorRect" parent="JoinGameUI"] [node name="Background" type="ColorRect" parent="JoinGameUI" unique_id=1020957244]
offset_right = 475.0 offset_right = 475.0
offset_bottom = 257.0 offset_bottom = 257.0
color = Color(0, 0.7372549, 0, 1) color = Color(0, 0.7372549, 0, 1)
[node name="JoinGameEdit" type="LineEdit" parent="JoinGameUI"] [node name="JoinGameEdit" type="LineEdit" parent="JoinGameUI" unique_id=179057807]
offset_left = 65.0 offset_left = 65.0
offset_top = 26.0 offset_top = 26.0
offset_right = 392.0 offset_right = 392.0
offset_bottom = 87.0 offset_bottom = 87.0
[node name="JoinGameButton" type="Button" parent="JoinGameUI"] [node name="JoinGameButton" type="Button" parent="JoinGameUI" unique_id=403873003]
offset_left = 128.0 offset_left = 128.0
offset_top = 127.0 offset_top = 127.0
offset_right = 330.81818 offset_right = 330.81818
offset_bottom = 224.0 offset_bottom = 224.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 36 theme_override_font_sizes/font_size = 36
text = "加入房间" text = "MAINMENU_JOINROOM"
[node name="Label" type="Label" parent="JoinGameUI"] [node name="Label" type="Label" parent="JoinGameUI" unique_id=1927653368]
offset_left = 131.0 offset_left = 131.0
offset_top = 88.0 offset_top = 88.0
offset_right = 326.0 offset_right = 326.0
offset_bottom = 126.0 offset_bottom = 126.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
text = "请输入服务器IP无需加端口" text = "MAINMENU_INPUTSERVERIP"
[node name="SettingButton" type="Button" parent="."] [node name="SettingButton" type="Button" parent="." unique_id=1367541903]
offset_left = 1591.0 offset_left = 1998.0
offset_top = 39.0 offset_top = 130.0
offset_right = 1699.0 offset_right = 2106.0
offset_bottom = 109.0 offset_bottom = 200.0
theme_override_fonts/font = ExtResource("1_l6cm7") theme_override_fonts/font = ExtResource("1_l6cm7")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "设置" text = "MAINMENU_SETTINGS"
[connection signal="pressed" from="StartGame" to="." method="_on_start_game_pressed"] [connection signal="pressed" from="StartGame" to="." method="_on_start_game_pressed"]
[connection signal="pressed" from="JoinGame" to="." method="_on_join_game_pressed"] [connection signal="pressed" from="JoinGame" to="." method="_on_join_game_pressed"]
[connection signal="pressed" from="QuitGame" to="." method="_on_quit_game_pressed"]
[connection signal="pressed" from="CreateGameUI/CreateGameButton" to="CreateGameUI" method="_on_create_game_button_pressed"] [connection signal="pressed" from="CreateGameUI/CreateGameButton" to="CreateGameUI" method="_on_create_game_button_pressed"]
[connection signal="pressed" from="CreateGameUI/Warn/WarnButton" to="CreateGameUI" method="_on_warn_button_pressed"] [connection signal="pressed" from="CreateGameUI/Warn/WarnButton" to="CreateGameUI" method="_on_warn_button_pressed"]
[connection signal="pressed" from="JoinGameUI/JoinGameButton" to="JoinGameUI" method="_on_join_game_button_pressed"] [connection signal="pressed" from="JoinGameUI/JoinGameButton" to="JoinGameUI" method="_on_join_game_button_pressed"]
@@ -9,8 +9,8 @@ script = ExtResource("1_r6d6q")
[node name="Background" type="ColorRect" parent="." unique_id=1213198647] [node name="Background" type="ColorRect" parent="." unique_id=1213198647]
offset_left = -34.0 offset_left = -34.0
offset_top = -27.0 offset_top = -27.0
offset_right = 1911.0 offset_right = 2623.0
offset_bottom = 1050.0 offset_bottom = 1500.0
color = Color(0.7058824, 0.6862745, 0, 1) color = Color(0.7058824, 0.6862745, 0, 1)
[node name="DataSetting" type="Node2D" parent="." unique_id=700043200] [node name="DataSetting" type="Node2D" parent="." unique_id=700043200]
@@ -23,7 +23,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "数据源设置" text = "SETTINGS_SETSOURCE"
[node name="LineEdit" type="LineEdit" parent="DataSetting" unique_id=34011310] [node name="LineEdit" type="LineEdit" parent="DataSetting" unique_id=34011310]
offset_left = 217.0 offset_left = 217.0
@@ -44,7 +44,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "自动识别IP地址的起始部分" text = "SETTINGS_IPBEGIN"
[node name="LineEdit" type="LineEdit" parent="IPBeginSetting" unique_id=1179342188] [node name="LineEdit" type="LineEdit" parent="IPBeginSetting" unique_id=1179342188]
offset_left = 424.0 offset_left = 424.0
@@ -65,7 +65,7 @@ offset_right = 193.0
offset_bottom = 90.0 offset_bottom = 90.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "局内显示昵称" text = "SETTINGS_NICKNAME"
[node name="LineEdit" type="LineEdit" parent="UsernameSetting" unique_id=694430941] [node name="LineEdit" type="LineEdit" parent="UsernameSetting" unique_id=694430941]
offset_left = 424.0 offset_left = 424.0
@@ -86,7 +86,7 @@ offset_right = 132.0
offset_bottom = 40.0 offset_bottom = 40.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "加载本地数据" text = "SETTINGS_LOADDATA"
[node name="ChooseSource" type="OptionButton" parent="LoadSource" unique_id=1045074926] [node name="ChooseSource" type="OptionButton" parent="LoadSource" unique_id=1045074926]
offset_left = 381.0 offset_left = 381.0
@@ -95,50 +95,75 @@ offset_right = 830.0
offset_bottom = 60.0 offset_bottom = 60.0
theme_override_font_sizes/font_size = 25 theme_override_font_sizes/font_size = 25
[node name="SaveButton" type="Button" parent="." unique_id=1377249836] [node name="ChooseLanguage" type="Node2D" parent="." unique_id=323270128]
offset_left = 85.0 position = Vector2(39, 405)
offset_top = 912.0 metadata/_edit_group_ = true
offset_right = 249.0
offset_bottom = 989.0 [node name="ChooseLanguageLabel" type="Label" parent="ChooseLanguage" unique_id=1719434618]
offset_left = 9.0
offset_top = 10.0
offset_right = 132.0
offset_bottom = 40.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "保存设置" text = "SETTINGS_CHOOSELANG"
[node name="ChooseLanguage" type="OptionButton" parent="ChooseLanguage" unique_id=476490830]
offset_left = 381.0
offset_top = 5.0
offset_right = 830.0
offset_bottom = 60.0
theme_override_font_sizes/font_size = 25
item_count = 2
popup/item_0/text = "en"
popup/item_0/id = 0
popup/item_1/text = "zh-cn"
popup/item_1/id = 1
[node name="SaveButton" type="Button" parent="." unique_id=1377249836]
offset_left = 132.0
offset_top = 1315.0
offset_right = 338.0
offset_bottom = 1392.0
theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30
text = "SETTINGS_SAVESETTINGS"
[node name="DownloadButton" type="Button" parent="." unique_id=315804661] [node name="DownloadButton" type="Button" parent="." unique_id=315804661]
offset_left = 493.0 offset_left = 598.0
offset_top = 905.0 offset_top = 1316.0
offset_right = 669.0 offset_right = 774.0
offset_bottom = 994.0 offset_bottom = 1405.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "下载文件" text = "SETTINGS_DOWNLOAD"
[node name="CancelButton" type="Button" parent="." unique_id=135993345] [node name="CancelButton" type="Button" parent="." unique_id=135993345]
offset_left = 286.0 offset_left = 371.0
offset_top = 906.0 offset_top = 1305.0
offset_right = 462.0 offset_right = 550.0
offset_bottom = 995.0 offset_bottom = 1394.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "取消" text = "SETTINGS_BACK"
[node name="LoadButton" type="Button" parent="." unique_id=2015694853] [node name="LoadButton" type="Button" parent="." unique_id=2015694853]
offset_left = 73.0 offset_left = 135.0
offset_top = 793.0 offset_top = 1198.0
offset_right = 249.0 offset_right = 311.0
offset_bottom = 882.0 offset_bottom = 1287.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "加载数据" text = "SETTINGS_LOAD"
[node name="Tips" type="Label" parent="." unique_id=1777076648] [node name="Tips" type="Label" parent="." unique_id=1777076648]
offset_left = 711.0 offset_left = 893.0
offset_top = 913.0 offset_top = 1318.0
offset_right = 1738.0 offset_right = 1920.0
offset_bottom = 966.0 offset_bottom = 1388.0
theme_override_fonts/font = ExtResource("2_6wm04") theme_override_fonts/font = ExtResource("2_6wm04")
theme_override_font_sizes/font_size = 50 theme_override_font_sizes/font_size = 50
text = "提示:无" text = "SETTINGS_TIP_NULL"
[connection signal="pressed" from="SaveButton" to="." method="_on_save_button_pressed"] [connection signal="pressed" from="SaveButton" to="." method="_on_save_button_pressed"]
[connection signal="pressed" from="DownloadButton" to="." method="_on_download_button_pressed"] [connection signal="pressed" from="DownloadButton" to="." method="_on_download_button_pressed"]
+2
View File
@@ -108,6 +108,8 @@ func load_resource():
asset_file.close() asset_file.close()
func get_sources(): func get_sources():
if !DirAccess.dir_exists_absolute("user://download/sources/"):
DirAccess.make_dir_recursive_absolute("user://download/sources/")
var dir = DirAccess.open("user://download/sources/") var dir = DirAccess.open("user://download/sources/")
var subdirs: PackedStringArray = dir.get_directories() var subdirs: PackedStringArray = dir.get_directories()
for subdir in subdirs: for subdir in subdirs:
+108 -5
View File
@@ -1,25 +1,128 @@
extends Node extends Node
var peer = ENetMultiplayerPeer.new() var peer = ENetMultiplayerPeer.new()
var players: Array var players: Array
var player_num var cards: Array
var my_card: Array
var max_players: int
var player_cards: Dictionary
var player_turns: Dictionary
var player_username: Dictionary
var player_hp: Dictionary
var server_round: int
var client_round: int
func add_player(id: int): func add_player(id: int):
if players.size() < player_num: if players.size() < max_players:
players.append(id) players.append(id)
player_cards[id] = []
func remove_player(id: int):
for i in range(players.size()):
if players[i] == id:
players.pop_at(i)
player_cards.erase(id)
break
func create_server(playern: int) -> void: func create_server(playern: int) -> void:
player_num = playern max_players = playern
var error = peer.create_server(8989, playern) var error = peer.create_server(8989, playern)
if error != OK: if error != OK:
printerr(error) printerr(error)
return return
multiplayer.multiplayer_peer = peer multiplayer.multiplayer_peer = peer
multiplayer.peer_connected.connect(_on_peer_connected) multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
func create_client(ip: String) -> void: func create_client(ip: String) -> void:
peer.create_client(ip, 8989) peer.create_client(ip, 8989)
multiplayer.multiplayer_peer = peer multiplayer.multiplayer_peer = peer
func _on_peer_connected(id: int): func _on_peer_connected(id: int) -> void:
pass add_player(id)
func _on_peer_disconnected(id: int) -> void:
remove_player(id)
func start_game() -> void:
if players.size() != max_players:
return
deal_cards()
server_round = 1
remote_variable()
func extract() -> String:
if cards.size() == 0:
return ""
var index = randi() % cards.size()
var card = cards[index]
cards.pop_at(index)
return card
func deal_cards() -> void:
for player in players:
while player_cards[player].size() < 8:
var card = extract()
if card != "":
player_cards[player].append(card)
func next_round() -> void:
settle_round()
server_round += 1
func settle_round() -> void:
for player in players:
request_card_draw(player)
remote_variable()
func request_card_draw(player_id: int) -> void:
if server_round == 1 and 0 <= player_turns[player_id] <= 1:
for i in range(3):
if player_cards[player_id].size() >= 8:
break
var card = extract()
if card != "":
player_cards[player_id].append(card)
else:
for i in range(4):
if player_cards[player_id].size() >= 8:
break
var card = extract()
if card != "":
player_cards[player_id].append(card)
remote_variable()
func get_my_cards() -> void:
request_cards.rpc()
@rpc("any_peer", "call_remote", "reliable")
func request_cards() -> void:
var sender_id = multiplayer.get_remote_sender_id()
var data: Array = player_cards.get(sender_id, [-1])
send_cards.rpc_id(sender_id, data)
@rpc("authority", "call_remote", "reliable")
func send_cards(data: Array) -> void:
my_card = data
func remote_variable() -> void:
if not multiplayer.is_server():
return
var data: Dictionary = {}
data["cards"] = cards
data["player_cards"] = player_cards
data["player_turns"] = player_turns
data["player_hp"] = player_hp
data["server_round"] = server_round
get_remote_variable.rpc(data)
@rpc("authority", "call_remote", "reliable")
func get_remote_variable(data: Dictionary) -> void:
cards = data["cards"]
player_cards = data["player_cards"]
player_turns = data["player_turns"]
player_hp = data["player_hp"]
server_round = data["server_round"]
+2 -1
View File
@@ -9,5 +9,6 @@ func _ready():
current_scene = root.get_child(root.get_child_count() - 1) current_scene = root.get_child(root.get_child_count() - 1)
func goto_scene(path: String): func goto_scene(path: String):
current_scene = path
get_tree().change_scene_to_file("res://scenes/%s.tscn" % [path]) get_tree().change_scene_to_file("res://scenes/%s.tscn" % [path])
var root = get_tree().root
current_scene = root.get_child(root.get_child_count() - 1)
+6
View File
@@ -12,3 +12,9 @@ func set_texture(pic: String) -> void:
func set_card(cname: String) -> void: func set_card(cname: String) -> void:
card_name = cname card_name = cname
set_texture("user://download/sources/%s/assets/pics/%s" % [DownloadManager.uuid, GameManager.pic_list[card_name]]) set_texture("user://download/sources/%s/assets/pics/%s" % [DownloadManager.uuid, GameManager.pic_list[card_name]])
func set_pos(x: int, y: int) -> void:
$Sprite.position = Vector2(x, y)
func get_pos() -> Vector2:
return $Sprite.position
+6 -3
View File
@@ -1,6 +1,6 @@
extends Node2D extends Node2D
var CardScene = preload("res://prefabs/game/card.tscn") var CardScene = preload("res://scenes/game/card.tscn")
var card_list: Array var card_list: Array
@@ -8,18 +8,21 @@ func _ready() -> void:
init() init()
var card = create_card("Oxygen") var card = create_card("Oxygen")
card.show() card.show()
card.set_pos(300, 300)
print(card.get_pos())
func init() -> void: func init() -> void:
if multiplayer.is_server(): if multiplayer.is_server():
$IsServerLabel.text = "房间运行中:您是房主" $IsServerLabel.text = "GAMEUI_URHOST"
else: else:
$IsServerLabel.text = "房间运行中:您是房客" $IsServerLabel.text = "GAMEUI_URGUEST"
var addresses: PackedStringArray = IP.get_local_addresses() var addresses: PackedStringArray = IP.get_local_addresses()
var ipaddress: String = "" var ipaddress: String = ""
for address in addresses: for address in addresses:
if address.substr(0, GameManager.ip_begin.length()) == GameManager.ip_begin: if address.substr(0, GameManager.ip_begin.length()) == GameManager.ip_begin:
ipaddress = address ipaddress = address
break
$IPLabel.text = ipaddress $IPLabel.text = ipaddress
$Player1/Username.text = GameManager.username $Player1/Username.text = GameManager.username
+1 -1
View File
@@ -5,7 +5,7 @@ func _on_create_game_button_pressed() -> void:
if 2 <= player_num and player_num <= 4: if 2 <= player_num and player_num <= 4:
MultiGame.create_server(int(player_num)) MultiGame.create_server(int(player_num))
$".".hide() $".".hide()
SceneManager.goto_scene("game") SceneManager.goto_scene("game/game")
else: else:
$Warn.show() $Warn.show()
+1 -1
View File
@@ -5,4 +5,4 @@ func _on_join_game_button_pressed() -> void:
var ip: String = $JoinGameEdit.text var ip: String = $JoinGameEdit.text
MultiGame.create_client(ip) MultiGame.create_client(ip)
$".".hide() $".".hide()
SceneManager.goto_scene("game") SceneManager.goto_scene("game/game")
+4 -2
View File
@@ -7,6 +7,8 @@ func _on_join_game_pressed() -> void:
func _on_start_game_pressed() -> void: func _on_start_game_pressed() -> void:
$CreateGameUI.show() $CreateGameUI.show()
func _on_setting_button_pressed() -> void: func _on_setting_button_pressed() -> void:
SceneManager.goto_scene("settings") SceneManager.goto_scene("menus/settings")
func _on_quit_game_pressed() -> void:
get_tree().quit()
+10 -9
View File
@@ -20,32 +20,33 @@ func _on_save_button_pressed() -> void:
GameManager.ip_begin = $IPBeginSetting/LineEdit.text GameManager.ip_begin = $IPBeginSetting/LineEdit.text
GameManager.username = $UsernameSetting/LineEdit.text GameManager.username = $UsernameSetting/LineEdit.text
GameManager.source = $LoadSource/ChooseSource.get_selected() GameManager.source = $LoadSource/ChooseSource.get_selected()
SceneManager.goto_scene("main_menu") TranslationServer.set_locale($ChooseLanguage/ChooseLanguage.text)
$Tips.text = "SETTINGS_TIP_SAVESETTINGS"
func _on_cancel_button_pressed() -> void: func _on_cancel_button_pressed() -> void:
SceneManager.goto_scene("main_menu") SceneManager.goto_scene("menus/main_menu")
func _on_download_button_pressed() -> void: func _on_download_button_pressed() -> void:
$Tips.text = "提示:已开始下载,请勿关闭设置页面" $Tips.text = "SETTINGS_TIP_STARTDOWNLOAD"
var result: int = await DownloadManager.download_from_origin() var result: int = await DownloadManager.download_from_origin()
if result == 1: if result == 1:
$Tips.text = "提示:下载失败。数据源路径错误" $Tips.text = "SETTINGS_TIP_SOURCEERROR"
return return
elif result == 2: elif result == 2:
$Tips.text = "提示:下载失败。创建请求失败" $Tips.text = "SETTINGS_TIP_REQUESTERROR"
return return
$Tips.text = "提示:正在加载资源,请勿关闭设置页面" $Tips.text = "SETTINGS_TIP_LOADING"
DownloadManager.load_resource() DownloadManager.load_resource()
$Tips.text = "提示:完成加载" $Tips.text = "SETTINGS_TIP_LOADED"
func _on_load_button_pressed() -> void: func _on_load_button_pressed() -> void:
if GameManager.sources.size() == 0 or GameManager.source == -1: if GameManager.sources.size() == 0 or GameManager.source == -1:
$Tips.text = "提示:无本地数据或未选择,无法加载" $Tips.text = "SETTINGS_TIP_NOLOCALSOURCE"
return; return;
DownloadManager.uuid = GameManager.sources[$LoadSource/ChooseSource.text] DownloadManager.uuid = GameManager.sources[$LoadSource/ChooseSource.text]
DownloadManager.load_resource() DownloadManager.load_resource()
$Tips.text = "提示:完成加载" $Tips.text = "SETTINGS_TIP_LOADED"