Merge branch 'develop' into 'master'
完成基础功能 See merge request paper-chemis-community/game!1
This commit is contained in:
@@ -21,6 +21,9 @@ game/
|
|||||||
- main_menu.tscn
|
- main_menu.tscn
|
||||||
- game.tscn
|
- game.tscn
|
||||||
- settings.tscn
|
- settings.tscn
|
||||||
|
- prefabs/
|
||||||
|
- game/
|
||||||
|
- card.tscn
|
||||||
- scripts/
|
- scripts/
|
||||||
- autoload/
|
- autoload/
|
||||||
- GameManager.gd # 游戏管理
|
- GameManager.gd # 游戏管理
|
||||||
@@ -39,12 +42,12 @@ game/
|
|||||||
|
|
||||||
## 如何运行
|
## 如何运行
|
||||||
|
|
||||||
请先运行数据后端,在游戏设置中输入后端 URL(包含端口号和 `http://` 或 `https://` 前缀,然后创建游戏或加入游戏开始游玩。
|
请先运行数据后端,在游戏设置中输入后端 URL(包含端口号和 `http://` 或 `https://` 前缀,或者选择本地已有的数据源,然后创建游戏或加入游戏开始游玩。
|
||||||
|
|
||||||
## 最佳实践
|
## 最佳实践
|
||||||
|
|
||||||
本项目目前正在使用 Godot 4.6 进行开发。开发用语言为 GDScript。
|
本项目目前正在使用 Godot 4.6 进行开发。开发用语言为 GDScript。
|
||||||
|
|
||||||
你的开发应当遵循 Godot 引擎提供的[最佳实践](https://docs.godotengine.org/zh-cn/4.5/tutorials/best_practices/)及[GDScript 编写风格指南](https://docs.godotengine.org/zh-cn/4.5/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` 目录下的单例脚本使用大驼峰式命名,其余脚本均应使用小蛇形式命令。所有节点均应使用大驼峰式命名。
|
||||||
|
|||||||
@@ -75,6 +75,26 @@ offset_bottom = 81.0
|
|||||||
theme_override_fonts/font = ExtResource("2_6wm04")
|
theme_override_fonts/font = ExtResource("2_6wm04")
|
||||||
theme_override_font_sizes/font_size = 24
|
theme_override_font_sizes/font_size = 24
|
||||||
|
|
||||||
|
[node name="LoadSource" type="Node2D" parent="." unique_id=230611076]
|
||||||
|
position = Vector2(44, 314)
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="LoadSourceLabel" type="Label" parent="LoadSource" unique_id=299353496]
|
||||||
|
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_font_sizes/font_size = 30
|
||||||
|
text = "加载本地数据"
|
||||||
|
|
||||||
|
[node name="ChooseSource" type="OptionButton" parent="LoadSource" unique_id=1045074926]
|
||||||
|
offset_left = 381.0
|
||||||
|
offset_top = 5.0
|
||||||
|
offset_right = 830.0
|
||||||
|
offset_bottom = 60.0
|
||||||
|
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 = 85.0
|
||||||
offset_top = 912.0
|
offset_top = 912.0
|
||||||
@@ -102,6 +122,15 @@ 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]
|
||||||
|
offset_left = 73.0
|
||||||
|
offset_top = 793.0
|
||||||
|
offset_right = 249.0
|
||||||
|
offset_bottom = 882.0
|
||||||
|
theme_override_fonts/font = ExtResource("2_6wm04")
|
||||||
|
theme_override_font_sizes/font_size = 30
|
||||||
|
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 = 711.0
|
||||||
offset_top = 913.0
|
offset_top = 913.0
|
||||||
@@ -114,3 +143,4 @@ text = "提示:无"
|
|||||||
[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"]
|
||||||
[connection signal="pressed" from="CancelButton" to="." method="_on_cancel_button_pressed"]
|
[connection signal="pressed" from="CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||||
|
[connection signal="pressed" from="LoadButton" to="." method="_on_load_button_pressed"]
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ func download_from_origin() -> int:
|
|||||||
|
|
||||||
get_uuid()
|
get_uuid()
|
||||||
|
|
||||||
|
DirAccess.remove_absolute("user://download/temp/index.json")
|
||||||
|
DirAccess.remove_absolute("user://download/temp/")
|
||||||
|
|
||||||
|
await download_file(origin + "index", "user://download/%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/%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/%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/%s/matters/list.json" % [uuid])
|
||||||
@@ -80,6 +84,8 @@ func download_from_origin() -> int:
|
|||||||
|
|
||||||
await download_assets(origin)
|
await download_assets(origin)
|
||||||
|
|
||||||
|
get_sources()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
func load_resource():
|
func load_resource():
|
||||||
@@ -100,3 +106,17 @@ func load_resource():
|
|||||||
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():
|
||||||
|
var dir = DirAccess.open("user://download/")
|
||||||
|
var subdirs: PackedStringArray = dir.get_directories()
|
||||||
|
for subdir in subdirs:
|
||||||
|
if subdir == "temp":
|
||||||
|
continue
|
||||||
|
var file = FileAccess.open("user://download/%s/index.json" % [subdir], FileAccess.READ)
|
||||||
|
var text = file.get_as_text()
|
||||||
|
var content = JSON.parse_string(text)
|
||||||
|
file.close()
|
||||||
|
var source_name = content["name"]
|
||||||
|
var source_uuid = content["uuid"]
|
||||||
|
GameManager.sources[source_name] = source_uuid
|
||||||
|
|||||||
@@ -3,6 +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 card_list: Dictionary = {}
|
var card_list: Dictionary = {}
|
||||||
var matter_list: Dictionary = {}
|
var matter_list: Dictionary = {}
|
||||||
@@ -10,3 +11,5 @@ var reaction_list: Dictionary = {}
|
|||||||
var match_list: Dictionary = {}
|
var match_list: Dictionary = {}
|
||||||
var pic_list: Dictionary = {}
|
var pic_list: Dictionary = {}
|
||||||
var sound_list: Dictionary = {}
|
var sound_list: Dictionary = {}
|
||||||
|
|
||||||
|
var sources: Dictionary = {}
|
||||||
@@ -1,14 +1,25 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
init_sources()
|
||||||
|
init_text()
|
||||||
|
|
||||||
|
func init_text() -> void:
|
||||||
$DataSetting/LineEdit.text = GameManager.data_origin
|
$DataSetting/LineEdit.text = GameManager.data_origin
|
||||||
$IPBeginSetting/LineEdit.text = GameManager.ip_begin
|
$IPBeginSetting/LineEdit.text = GameManager.ip_begin
|
||||||
$UsernameSetting/LineEdit.text = GameManager.username
|
$UsernameSetting/LineEdit.text = GameManager.username
|
||||||
|
$LoadSource/ChooseSource.select(GameManager.source)
|
||||||
|
|
||||||
|
func init_sources() -> void:
|
||||||
|
DownloadManager.get_sources()
|
||||||
|
for source_name in GameManager.sources:
|
||||||
|
$LoadSource/ChooseSource.add_item(source_name)
|
||||||
|
|
||||||
func _on_save_button_pressed() -> void:
|
func _on_save_button_pressed() -> void:
|
||||||
GameManager.data_origin = $DataSetting/LineEdit.text
|
GameManager.data_origin = $DataSetting/LineEdit.text
|
||||||
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()
|
||||||
SceneManager.goto_scene("main_menu")
|
SceneManager.goto_scene("main_menu")
|
||||||
|
|
||||||
|
|
||||||
@@ -29,3 +40,9 @@ func _on_download_button_pressed() -> void:
|
|||||||
DownloadManager.load_resource()
|
DownloadManager.load_resource()
|
||||||
$Tips.text = "提示:完成加载"
|
$Tips.text = "提示:完成加载"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_load_button_pressed() -> void:
|
||||||
|
DownloadManager.uuid = GameManager.sources[$LoadSource/ChooseSource.text]
|
||||||
|
DownloadManager.load_resource()
|
||||||
|
$Tips.text = "提示:完成加载"
|
||||||
|
|||||||
Reference in New Issue
Block a user