Merge branch 'develop' into 'master'
做好了开发游戏玩法的准备 See merge request paper-chemis-community/game!2
This commit is contained in:
@@ -51,3 +51,5 @@ game/
|
|||||||
你的开发应当遵循 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 的函数外,任何函数都不应该以下划线(`_`)开头。
|
||||||
|
|||||||
+2
-2
@@ -28,8 +28,8 @@ 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
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -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]
|
||||||
@@ -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"
|
||||||
|
|||||||
+39
-39
@@ -1,67 +1,67 @@
|
|||||||
[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 = "纸片化学社区版"
|
||||||
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 = "创建局域网游戏"
|
||||||
|
|
||||||
[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 = "加入局域网游戏"
|
||||||
|
|
||||||
[node name="CreateGameUI" type="Node2D" parent="."]
|
[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
|
||||||
@@ -70,7 +70,7 @@ theme_override_fonts/font = ExtResource("1_l6cm7")
|
|||||||
theme_override_font_sizes/font_size = 36
|
theme_override_font_sizes/font_size = 36
|
||||||
text = "创建房间"
|
text = "创建房间"
|
||||||
|
|
||||||
[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
|
||||||
@@ -78,24 +78,24 @@ offset_bottom = 126.0
|
|||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
text = "请输入最大玩家数(2~4)"
|
text = "请输入最大玩家数(2~4)"
|
||||||
|
|
||||||
[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 = "确定"
|
||||||
|
|
||||||
[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
|
||||||
@@ -105,24 +105,24 @@ text = "输入数据错误!
|
|||||||
请输入2~4之间的整数!"
|
请输入2~4之间的整数!"
|
||||||
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
|
||||||
@@ -131,7 +131,7 @@ theme_override_fonts/font = ExtResource("1_l6cm7")
|
|||||||
theme_override_font_sizes/font_size = 36
|
theme_override_font_sizes/font_size = 36
|
||||||
text = "加入房间"
|
text = "加入房间"
|
||||||
|
|
||||||
[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
|
||||||
@@ -139,11 +139,11 @@ offset_bottom = 126.0
|
|||||||
theme_override_fonts/font = ExtResource("1_l6cm7")
|
theme_override_fonts/font = ExtResource("1_l6cm7")
|
||||||
text = "请输入服务器IP(无需加端口)"
|
text = "请输入服务器IP(无需加端口)"
|
||||||
|
|
||||||
[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 = "设置"
|
||||||
|
|||||||
+22
-22
@@ -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]
|
||||||
@@ -96,46 +96,46 @@ 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="SaveButton" type="Button" parent="." unique_id=1377249836]
|
||||||
offset_left = 85.0
|
offset_left = 150.0
|
||||||
offset_top = 912.0
|
offset_top = 1321.0
|
||||||
offset_right = 249.0
|
offset_right = 314.0
|
||||||
offset_bottom = 989.0
|
offset_bottom = 1398.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 = "保存设置"
|
||||||
|
|
||||||
[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 = "下载文件"
|
||||||
|
|
||||||
[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 = "取消"
|
||||||
|
|
||||||
[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 = "加载数据"
|
||||||
|
|
||||||
[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 = "提示:无"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var uuid: String = "source"
|
var uuid: String
|
||||||
|
|
||||||
func create_file(file_path: String) -> void:
|
func create_file(file_path: String) -> void:
|
||||||
var base_dir = file_path.get_base_dir()
|
var base_dir = file_path.get_base_dir()
|
||||||
@@ -20,14 +20,14 @@ func download_file(server_path: String, local_path: String) -> void:
|
|||||||
await http.request_completed
|
await http.request_completed
|
||||||
|
|
||||||
func get_uuid() -> void:
|
func get_uuid() -> void:
|
||||||
var index_file = FileAccess.open("user://download/temp/index.json", FileAccess.READ)
|
var index_file = FileAccess.open("user://download/sources/temp/index.json", FileAccess.READ)
|
||||||
var index_text = index_file.get_as_text()
|
var index_text = index_file.get_as_text()
|
||||||
var content = JSON.parse_string(index_text)
|
var content = JSON.parse_string(index_text)
|
||||||
index_file.close()
|
index_file.close()
|
||||||
uuid = content["uuid"]
|
uuid = content["uuid"]
|
||||||
|
|
||||||
func download_defs(type: String, origin: String) -> void:
|
func download_defs(type: String, origin: String) -> void:
|
||||||
var list_file = FileAccess.open("user://download/%s/%ss/list.json" % [uuid, type], FileAccess.READ)
|
var list_file = FileAccess.open("user://download/sources/%s/%ss/list.json" % [uuid, type], FileAccess.READ)
|
||||||
var list_text = list_file.get_as_text()
|
var list_text = list_file.get_as_text()
|
||||||
var list = JSON.parse_string(list_text)
|
var list = JSON.parse_string(list_text)
|
||||||
list_file.close()
|
list_file.close()
|
||||||
@@ -35,10 +35,10 @@ func download_defs(type: String, origin: String) -> void:
|
|||||||
return
|
return
|
||||||
for k in list:
|
for k in list:
|
||||||
var filename = list[k]
|
var filename = list[k]
|
||||||
await download_file("%s%s/id/%s" % [origin, type, k], "user://download/%s/%ss/%s.json" % [uuid, type, filename])
|
await download_file("%s%s/id/%s" % [origin, type, k], "user://download/sources/%s/%ss/%s.json" % [uuid, type, filename])
|
||||||
|
|
||||||
func download_assets(origin: String) -> void:
|
func download_assets(origin: String) -> void:
|
||||||
var list_file = FileAccess.open("user://download/%s/assets/list.json" % [uuid], FileAccess.READ)
|
var list_file = FileAccess.open("user://download/sources/%s/assets/list.json" % [uuid], FileAccess.READ)
|
||||||
var list_text = list_file.get_as_text()
|
var list_text = list_file.get_as_text()
|
||||||
var list = JSON.parse_string(list_text)
|
var list = JSON.parse_string(list_text)
|
||||||
list_file.close()
|
list_file.close()
|
||||||
@@ -46,10 +46,10 @@ func download_assets(origin: String) -> void:
|
|||||||
return
|
return
|
||||||
for k in list["pics"]:
|
for k in list["pics"]:
|
||||||
var filename = list["pics"][k]
|
var filename = list["pics"][k]
|
||||||
await download_file("%sasset/pic/%s" % [origin, k], "user://download/%s/assets/pics/%s" % [uuid, filename])
|
await download_file("%sasset/pic/%s" % [origin, k], "user://download/sources/%s/assets/pics/%s" % [uuid, filename])
|
||||||
for k in list["sounds"]:
|
for k in list["sounds"]:
|
||||||
var filename = list["sounds"][k]
|
var filename = list["sounds"][k]
|
||||||
await download_file("%sasset/sound/%s" % [origin, k], "user://download/%s/assets/sounds/%s" % [uuid, filename])
|
await download_file("%sasset/sound/%s" % [origin, k], "user://download/sources/%s/assets/sounds/%s" % [uuid, filename])
|
||||||
|
|
||||||
func download_from_origin() -> int:
|
func download_from_origin() -> int:
|
||||||
var origin = GameManager.data_origin
|
var origin = GameManager.data_origin
|
||||||
@@ -65,18 +65,18 @@ func download_from_origin() -> int:
|
|||||||
if origin[-1] != "/":
|
if origin[-1] != "/":
|
||||||
origin = origin + "/"
|
origin = origin + "/"
|
||||||
|
|
||||||
await download_file(origin + "index", "user://download/temp/index.json")
|
await download_file(origin + "index", "user://download/sources/temp/index.json")
|
||||||
|
|
||||||
get_uuid()
|
get_uuid()
|
||||||
|
|
||||||
DirAccess.remove_absolute("user://download/temp/index.json")
|
DirAccess.remove_absolute("user://download/sources/temp/index.json")
|
||||||
DirAccess.remove_absolute("user://download/temp/")
|
DirAccess.remove_absolute("user://download/sources/temp/")
|
||||||
|
|
||||||
await download_file(origin + "index", "user://download/%s/index.json" % [uuid])
|
await download_file(origin + "index", "user://download/sources/%s/index.json" % [uuid])
|
||||||
await download_file(origin + "card/list", "user://download/%s/cards/list.json" % [uuid])
|
await download_file(origin + "card/list", "user://download/sources/%s/cards/list.json" % [uuid])
|
||||||
await download_file(origin + "reaction/list", "user://download/%s/reactions/list.json" % [uuid])
|
await download_file(origin + "reaction/list", "user://download/sources/%s/reactions/list.json" % [uuid])
|
||||||
await download_file(origin + "matter/list", "user://download/%s/matters/list.json" % [uuid])
|
await download_file(origin + "matter/list", "user://download/sources/%s/matters/list.json" % [uuid])
|
||||||
await download_file(origin + "asset/list", "user://download/%s/assets/list.json" % [uuid])
|
await download_file(origin + "asset/list", "user://download/sources/%s/assets/list.json" % [uuid])
|
||||||
|
|
||||||
await download_defs("card", origin)
|
await download_defs("card", origin)
|
||||||
await download_defs("reaction", origin)
|
await download_defs("reaction", origin)
|
||||||
@@ -89,31 +89,33 @@ func download_from_origin() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
func load_resource():
|
func load_resource():
|
||||||
var card_file = FileAccess.open("user://download/%s/cards/list.json" % [uuid], FileAccess.READ)
|
var card_file = FileAccess.open("user://download/sources/%s/cards/list.json" % [uuid], FileAccess.READ)
|
||||||
GameManager.card_list = JSON.parse_string(card_file.get_as_text())
|
GameManager.card_list = JSON.parse_string(card_file.get_as_text())
|
||||||
card_file.close()
|
card_file.close()
|
||||||
|
|
||||||
var reaction_file = FileAccess.open("user://download/%s/reactions/list.json" % [uuid], FileAccess.READ)
|
var reaction_file = FileAccess.open("user://download/sources/%s/reactions/list.json" % [uuid], FileAccess.READ)
|
||||||
GameManager.reaction_list = JSON.parse_string(reaction_file.get_as_text())
|
GameManager.reaction_list = JSON.parse_string(reaction_file.get_as_text())
|
||||||
reaction_file.close()
|
reaction_file.close()
|
||||||
|
|
||||||
var matter_file = FileAccess.open("user://download/%s/matters/list.json" % [uuid], FileAccess.READ)
|
var matter_file = FileAccess.open("user://download/sources/%s/matters/list.json" % [uuid], FileAccess.READ)
|
||||||
GameManager.matter_list = JSON.parse_string(matter_file.get_as_text())
|
GameManager.matter_list = JSON.parse_string(matter_file.get_as_text())
|
||||||
matter_file.close()
|
matter_file.close()
|
||||||
|
|
||||||
var asset_file = FileAccess.open("user://download/%s/assets/list.json" % [uuid], FileAccess.READ)
|
var asset_file = FileAccess.open("user://download/sources/%s/assets/list.json" % [uuid], FileAccess.READ)
|
||||||
var asset_list = JSON.parse_string(asset_file.get_as_text())
|
var asset_list = JSON.parse_string(asset_file.get_as_text())
|
||||||
GameManager.pic_list = asset_list["pics"]
|
GameManager.pic_list = asset_list["pics"]
|
||||||
GameManager.sound_list = asset_list["sounds"]
|
GameManager.sound_list = asset_list["sounds"]
|
||||||
asset_file.close()
|
asset_file.close()
|
||||||
|
|
||||||
func get_sources():
|
func get_sources():
|
||||||
var dir = DirAccess.open("user://download/")
|
if !DirAccess.dir_exists_absolute("user://download/sources/"):
|
||||||
|
DirAccess.make_dir_recursive_absolute("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:
|
||||||
if subdir == "temp":
|
if subdir == "temp":
|
||||||
continue
|
continue
|
||||||
var file = FileAccess.open("user://download/%s/index.json" % [subdir], FileAccess.READ)
|
var file = FileAccess.open("user://download/sources/%s/index.json" % [subdir], FileAccess.READ)
|
||||||
var text = file.get_as_text()
|
var text = file.get_as_text()
|
||||||
var content = JSON.parse_string(text)
|
var content = JSON.parse_string(text)
|
||||||
file.close()
|
file.close()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ extends Node
|
|||||||
var data_origin: String = ""
|
var data_origin: String = ""
|
||||||
var ip_begin: String = "192.168."
|
var ip_begin: String = "192.168."
|
||||||
var username: String = "Player1"
|
var username: String = "Player1"
|
||||||
var source: int = 0
|
var source: int = -1
|
||||||
|
|
||||||
var card_list: Dictionary = {}
|
var card_list: Dictionary = {}
|
||||||
var matter_list: Dictionary = {}
|
var matter_list: Dictionary = {}
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
# 基于 ENet 多人游戏
|
var peer = ENetMultiplayerPeer.new()
|
||||||
|
var players: Array
|
||||||
|
var player_num
|
||||||
|
|
||||||
func create_server(player_num: int) -> void:
|
func add_player(id: int):
|
||||||
var peer = ENetMultiplayerPeer.new()
|
if players.size() < player_num:
|
||||||
peer.create_server(8989, player_num)
|
players.append(id)
|
||||||
|
|
||||||
|
func create_server(playern: int) -> void:
|
||||||
|
player_num = playern
|
||||||
|
var error = peer.create_server(8989, playern)
|
||||||
|
if error != OK:
|
||||||
|
printerr(error)
|
||||||
|
return
|
||||||
multiplayer.multiplayer_peer = peer
|
multiplayer.multiplayer_peer = peer
|
||||||
|
multiplayer.peer_connected.connect(_on_peer_connected)
|
||||||
|
|
||||||
func create_client(ip: String) -> void:
|
func create_client(ip: String) -> void:
|
||||||
var peer = ENetMultiplayerPeer.new()
|
|
||||||
peer.create_client(ip, 8989)
|
peer.create_client(ip, 8989)
|
||||||
multiplayer.multiplayer_peer = peer
|
multiplayer.multiplayer_peer = peer
|
||||||
|
|
||||||
|
func _on_peer_connected(id: int):
|
||||||
|
pass
|
||||||
@@ -11,4 +11,4 @@ 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/%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]])
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
func _on_create_game_button_pressed() -> void:
|
func _on_create_game_button_pressed() -> void:
|
||||||
var player_num = int($CreateGameEdit.text)
|
var player_num = int($CreateGameEdit.text)
|
||||||
if 2 <= player_num and player_num <= 4:
|
if 2 <= player_num and player_num <= 4:
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ func _on_download_button_pressed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_load_button_pressed() -> void:
|
func _on_load_button_pressed() -> void:
|
||||||
|
if GameManager.sources.size() == 0 or GameManager.source == -1:
|
||||||
|
$Tips.text = "提示:无本地数据或未选择,无法加载"
|
||||||
|
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 = "提示:完成加载"
|
||||||
|
|||||||
Reference in New Issue
Block a user