From f2a580973258ec7424f96a0cf918b25ca003890a Mon Sep 17 00:00:00 2001 From: TsubakiLoL <2789646812@qq.com> Date: Mon, 23 Sep 2024 11:47:55 +0800 Subject: [PATCH] =?UTF-8?q?9.23=E4=B8=8A=E5=8D=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/global/script/global.gd | 28 ++++- json/character.json | 176 +++++++++++++++++++++++++++++++ json/npc.json | 5 + json/scene.json | 13 ++- project.godot | 1 + scene/game_flow.gd | 8 ++ scene/game_flow.tscn | 25 ++++- scene/game_flow_touch.gd | 10 ++ scene/game_flow_touch.tscn | 12 ++- scene/map.gd | 66 +++++++----- scene/map.tscn | 10 +- test/scene/map_example_2.gd | 3 +- 12 files changed, 314 insertions(+), 43 deletions(-) create mode 100644 json/npc.json create mode 100644 scene/game_flow_touch.gd diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 9188d95..d4738d9 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -15,6 +15,12 @@ var character_json_path:String="res://json/character.json" var character_data:Dictionary var map_json_path:String="res://json/map.json" var map_data:Dictionary + +var npc_json_path:String="res://json/npc.json" +var npc_data:Dictionary + + + var system_config_data:Dictionary={ } @@ -73,6 +79,12 @@ func call_triger(triger_type:String,data): return triger[triger_type].call(data) else: return null +var condition_triger:Dictionary={ + "date_limit":"", + "time_limit":"", + "rand":"", + +} func move_scene(scene_id:String,distance): if scene_id==get_now_scene(): return false @@ -97,6 +109,7 @@ func _ready() -> void: load_scene_data() load_character_data() load_map_data() + load_npc_data() func load_texture_data(): var file=FileAccess.open(texture_json_path,FileAccess.READ) var str=file.get_as_text() @@ -147,7 +160,13 @@ func load_map_data(): for i in dictionary.keys(): dictionary[i]["id"]=i map_data=dictionary - +func load_npc_data(): + var file=FileAccess.open(npc_json_path,FileAccess.READ) + var str=file.get_as_text() + var dictionary:Dictionary=JSON.parse_string(str) + for i in dictionary.keys(): + dictionary[i]["id"]=i + npc_data=dictionary func get_texture(id:String): if texture_data.has(id): return texture_data[id] @@ -187,3 +206,10 @@ func get_map_data(id:String): else: return null pass +func get_npc_data(id:String): + if npc_data.has(id): + var dictionary:Dictionary=npc_data[id] + return dictionary.duplicate() + else: + return null + pass diff --git a/json/character.json b/json/character.json index e912c62..095d0ca 100644 --- a/json/character.json +++ b/json/character.json @@ -155,6 +155,182 @@ } ], + "favor":[{ + "name":"姐姐", + "value":100 + } + ], + "reputation":[ + { + "name":"某地区", + "value":100 + } + ] + }, + + + + + + + + + + "test_character_02":{ + "character":{ + "name":"朱雀院椿(NPC)", + "star":3, + + "skin":[ + { + "name":"皮肤1", + "card_face":"test_character_tsubaki", + "character":"角色图片路径" + } + ], + "skin_now_use":0 + }, + "basic_mes":{ + "script_category":"剧本类别", + "place":"地点", + "sex":0, + "race":"种族", + "birthday":"xxxx-xx-xx", + + "introduction":"这是一个介绍", + "basic_attribute":[ + { + "name":"体质", + "value":100, + }, + { + "name":"敏捷", + "value":100, + }, + { + "name":"智力", + "value":100, + }, + { + "name":"感知", + "value":100, + }, + ], + "fight_attribute":[ + { + "name":"生命", + "value":100, + }, + { + "name":"精神", + "value":100, + }, + { + "name":"物理攻击", + "value":100, + }, + { + "name":"法术强度", + "value":100, + }, + ] + }, + "special":[ + { + "name":"倾国倾城", + "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" + } + ], + "ability":[ + { + "name":"武学 LV3", + "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" + } + ], + + "favor":[{ + "name":"姐姐", + "value":100 + } + ], + "reputation":[ + { + "name":"某地区", + "value":100 + } + ] + }, + "test_character_02":{ + "character":{ + "name":"朱雀院椿(测试)", + "star":3, + "skin":[ + { + "name":"皮肤1", + "card_face":"test_character_tsubaki", + "character":"角色图片路径" + } + ], + "skin_now_use":0 + }, + "basic_mes":{ + "script_category":"剧本类别", + "place":"地点", + "sex":0, + "race":"种族", + "birthday":"xxxx-xx-xx", + + "introduction":"这是一个介绍", + "basic_attribute":[ + { + "name":"体质", + "value":100, + }, + { + "name":"敏捷", + "value":100, + }, + { + "name":"智力", + "value":100, + }, + { + "name":"感知", + "value":100, + }, + ], + "fight_attribute":[ + { + "name":"生命", + "value":100, + }, + { + "name":"精神", + "value":100, + }, + { + "name":"物理攻击", + "value":100, + }, + { + "name":"法术强度", + "value":100, + }, + ] + }, + "special":[ + { + "name":"倾国倾城", + "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" + } + ], + "ability":[ + { + "name":"武学 LV3", + "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" + } + ], + "favor":[{ "name":"姐姐", "value":100 diff --git a/json/npc.json b/json/npc.json new file mode 100644 index 0000000..7ae0445 --- /dev/null +++ b/json/npc.json @@ -0,0 +1,5 @@ +{ + "测试npc_1":{ + + } +} diff --git a/json/scene.json b/json/scene.json index a13fe2f..a284b01 100644 --- a/json/scene.json +++ b/json/scene.json @@ -63,7 +63,18 @@ "id":"scene_01", "distance":100 } - ] + ], + "touch":{ + + "测试互动点1":{ + "triger":[], + "event":["event_01"] + }, + "测试互动点2":{ + "triger":[], + "character":[] + } + } }, } diff --git a/project.godot b/project.godot index 5f149dc..a039577 100644 --- a/project.godot +++ b/project.godot @@ -26,6 +26,7 @@ Bgm="*res://autoload/BGM/tscn/bgm.tscn" window/size/viewport_width=1920 window/size/viewport_height=1080 +window/size/mode=3 [editor_plugins] diff --git a/scene/game_flow.gd b/scene/game_flow.gd index c8a6ae9..7904294 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -10,6 +10,7 @@ class_name GameFlow @onready var character_name: Label = $hbox/TextureRect2/vbox/HBoxContainer/character_name @onready var map: Control = $map @onready var date: Label = $hbox/TextureRect2/vbox/date +@onready var touch_add_pos: Control = $touch_add_pos const GAME_FLOW_TOUCH = preload("res://scene/game_flow_touch.tscn") @@ -31,6 +32,8 @@ func set_scene(id:String): i.queue_free() for i in place_add.get_children(): i.queue_free() + for i in touch_add_pos.get_children(): + i.queue_free() for i in scene_data["quick_event"]: var new_btn=GAME_FLOW_EVENT.instantiate() event.add_child(new_btn) @@ -41,6 +44,11 @@ func set_scene(id:String): place_add.add_child(new_place) new_place.set_data(i) new_place.pressed.connect(place_pressed) + pass + for i in scene_data["touch"]: + + + pass pass diff --git a/scene/game_flow.tscn b/scene/game_flow.tscn index 67c9b23..b1754d5 100644 --- a/scene/game_flow.tscn +++ b/scene/game_flow.tscn @@ -89,6 +89,14 @@ texture = ExtResource("1_gjw3y") expand_mode = 1 stretch_mode = 6 +[node name="touch_add_pos" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + [node name="NinePatchRect" type="NinePatchRect" parent="."] layout_mode = 0 anchor_left = 0.0166667 @@ -379,11 +387,18 @@ texture = ExtResource("14_5tsah") layout_mode = 1 [node name="place_add" type="VBoxContainer" parent="."] -layout_mode = 0 -offset_left = 1610.0 -offset_top = 119.0 -offset_right = 1886.0 -offset_bottom = 633.0 +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.0 +anchor_top = 0.136 +anchor_right = 1.0 +anchor_bottom = 0.136 +offset_left = -281.0 +offset_top = 0.119995 +offset_right = -5.0 +offset_bottom = 383.12 +grow_horizontal = 0 +grow_vertical = 2 theme_override_constants/separation = 37 [node name="game_flow_place" parent="place_add" instance=ExtResource("15_2cypk")] diff --git a/scene/game_flow_touch.gd b/scene/game_flow_touch.gd new file mode 100644 index 0000000..eb52334 --- /dev/null +++ b/scene/game_flow_touch.gd @@ -0,0 +1,10 @@ +extends MarginContainer + +signal touch_click() + + +func judge(): + + + + pass diff --git a/scene/game_flow_touch.tscn b/scene/game_flow_touch.tscn index 1f50c73..f5eb60c 100644 --- a/scene/game_flow_touch.tscn +++ b/scene/game_flow_touch.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=8 format=3 uid="uid://bk0xuj6xb5n8n"] +[gd_scene load_steps=9 format=3 uid="uid://bk0xuj6xb5n8n"] +[ext_resource type="Script" path="res://scene/game_flow_touch.gd" id="1_maikt"] [ext_resource type="Texture2D" uid="uid://xjk24mq7dqjp" path="res://res/ui/ui_019_game_flow/tuceng11.png" id="1_rc7al"] [ext_resource type="Texture2D" uid="uid://bowl27hko0yx2" path="res://res/ui/ui_019_game_flow/tuceng13.png" id="2_2pfym"] [ext_resource type="Texture2D" uid="uid://824g8kb1h4o4" path="res://res/ui/ui_019_game_flow/tuoyuan1.png" id="3_garvq"] @@ -8,9 +9,12 @@ [ext_resource type="Texture2D" uid="uid://cpito436o4akn" path="res://res/ui/ui_019_game_flow/tuceng10.png" id="5_oqc0n"] [ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="7_xebjv"] -[node name="HBoxContainer" type="MarginContainer"] -offset_right = 204.0 -offset_bottom = 204.0 +[node name="margin" type="MarginContainer"] +offset_left = -102.0 +offset_top = -102.0 +offset_right = 102.0 +offset_bottom = 102.0 +script = ExtResource("1_maikt") [node name="HBoxContainer" type="HBoxContainer" parent="."] layout_mode = 2 diff --git a/scene/map.gd b/scene/map.gd index cd5450e..4a80c39 100644 --- a/scene/map.gd +++ b/scene/map.gd @@ -13,37 +13,47 @@ extends Control @onready var pointer: Label = $ScrollContainer/HBoxContainer/map_add_pos/pointer_map/pointer +var map_tween:Array=[null,null] +func recreate_map_tween(): + for i in map_tween.size(): + if map_tween[i]==null: + map_tween[i]=get_tree().create_tween() + else: + map_tween[i].stop() + map_tween[i].kill() + + map_tween[i]=get_tree().create_tween() +func show_map_animation(map_from,map_next): + recreate_map_tween() + map_from.modulate.a=1 + map_next.modulate.a=1 + var map=[map_0,map_1,map_2] + for i in map: + if not i in [map_from,map_next]: + i.hide() + i.modulate.a=1 + else: + i.show() + + map_tween[0].tween_property(map_from,"modulate:a",0,0.1) + map_tween[0].tween_callback(map_from.hide) + map_tween[1].tween_property(map_next,"modulate:a",1,0.1) + #map_from.hide() + #map_next.show() + pass signal scene_change(scene_id:String) var scale_rag:float=1: set(val): if val>scale_index_1 and valscale_index_2): - var t=get_tree().create_tween() - t.tween_property(map_now,"modulate:a",0,0.1) - t.tween_callback(map_now.hide) - var t2=get_tree().create_tween() - map_1.modulate.a=0 - map_1.show() + show_map_animation(map_now,map_1) map_now=map_1 - t2.tween_property(map_1,"modulate:a",1,0.1) elif val<=scale_index_1 and scale_rag>scale_index_1: - var t=get_tree().create_tween() - t.tween_property(map_now,"modulate:a",0,0.1) - t.tween_callback(map_now.hide) - var t2=get_tree().create_tween() - map_0.modulate.a=0 - map_0.show() + show_map_animation(map_now,map_0) map_now=map_0 - t2.tween_property(map_0,"modulate:a",1,0.1) elif val>scale_index_2 and scale_rag void: scroll_container.scroll_vertical-=relative.y if Input.is_action_pressed("mouse_up"): if keep_tween==null: - keep_tween=create_tween() + keep_tween=get_tree().create_tween() else: keep_tween.stop() - keep_tween=create_tween() + keep_tween.kill() + keep_tween=get_tree().create_tween() keep_tween.tween_property(self,"scale_rag",clamp(scale_rag+0.2,scale_limit_min,scale_limit_max),0.1) if Input.is_action_just_pressed("mouse_down"): if keep_tween==null: - keep_tween=create_tween() + keep_tween=get_tree().create_tween() else: keep_tween.stop() - keep_tween=create_tween() + keep_tween.kill() + keep_tween=get_tree().create_tween() keep_tween.tween_property(self,"scale_rag",clamp(scale_rag-0.2,scale_limit_min,scale_limit_max),0.1) func _on_back_pressed() -> void: + set_process(false) self.hide() pass # Replace with function body. diff --git a/scene/map.tscn b/scene/map.tscn index c4e2ef6..1a56eb5 100644 --- a/scene/map.tscn +++ b/scene/map.tscn @@ -76,6 +76,7 @@ visible = false layout_mode = 2 [node name="pointer_map" type="Control" parent="ScrollContainer/HBoxContainer/map_add_pos"] +z_index = 2 layout_mode = 2 [node name="pointer" type="Label" parent="ScrollContainer/HBoxContainer/map_add_pos/pointer_map"] @@ -83,11 +84,10 @@ z_index = 3 layout_mode = 1 anchors_preset = -1 anchor_left = -0.027 -anchor_right = 1.031 -anchor_bottom = 1.0 -offset_left = 38.88 -offset_right = -1435.64 -offset_bottom = -956.0 +anchor_right = -0.027 +offset_left = 91.295 +offset_right = 140.295 +offset_bottom = 124.0 theme_override_font_sizes/font_size = 90 text = "⬇" horizontal_alignment = 1 diff --git a/test/scene/map_example_2.gd b/test/scene/map_example_2.gd index d2a2189..6233f50 100644 --- a/test/scene/map_example_2.gd +++ b/test/scene/map_example_2.gd @@ -2,14 +2,13 @@ extends MapIndex - func _on_tool_button_pressed() -> void: click_scene("scene_tower") pass # Replace with function body. func get_scene_global_pos(scene_id:String): match scene_id: "scene_tower": - return $TextureRect/ToolButton.global_position + return $TextureRect/ToolButton.global_position+Vector2($TextureRect/ToolButton.size.x/2,0) _:return Vector2(0,0) pass