This commit is contained in:
TsubakiLoL 2024-09-20 20:20:14 +08:00
parent fa517b71c3
commit 467a98b069
10 changed files with 178 additions and 13 deletions

View File

@ -27,8 +27,13 @@ var now_game_data:Dictionary={
"script_data":{ "script_data":{
}, },
"difficulty":0 "now_scene":"scene_01",
"difficulty":0,
} }
var now_game_flow
func get_now_character_data():
return now_game_data["character_data"]
func _ready() -> void: func _ready() -> void:
load_texture_data() load_texture_data()
load_script_data() load_script_data()

View File

@ -11,6 +11,34 @@
"name":"测试场景事件", "name":"测试场景事件",
"event":"event_02" "event":"event_02"
} }
] ],
"linked_scene":[{
"name":"测试场景2",
"id":"scene_02",
"distance":100
} }
]
},
"scene_02":{
"name":"测试场景1",
"texture":"test_character",
"quick_event":[
{
"name":"测试场景事件",
"event":"event_01"
},
{
"name":"测试场景事件",
"event":"event_02"
}
],
"linked_scene":[
{
"name":"测试场景1",
"id":"scene_01",
"distance":100
}
]
},
} }

View File

@ -34,6 +34,8 @@ func set_event_data(id:String):
new_btn.click.connect(choice_click) new_btn.click.connect(choice_click)
animation_player.play("open") animation_player.play("open")
func choice_click(event_data:Dictionary): func choice_click(event_data:Dictionary):
if not event_data.has("triger"):
return
for i in event_data["triger"]: for i in event_data["triger"]:

View File

@ -1,17 +1,50 @@
extends Control extends Control
@onready var back: TextureRect = $back @onready var back: TextureRect = $back
@onready var event: HBoxContainer = $bottom_container/event @onready var event: HBoxContainer = $bottom_container/event
@onready var place_add: VBoxContainer = $place_add
@onready var animation_player: AnimationPlayer = $AnimationPlayer
@onready var animation_mask: ColorRect = $animation_mask
@onready var character_texture: TextureRect = $hbox/TextureRect/TextureRect/character_texture
@onready var event_panel: Control = $event_panel
const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn") const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn")
const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn")
var scene_data:Dictionary var scene_data:Dictionary
func _ready() -> void: func _ready() -> void:
set_scene("scene_01") set_scene("scene_01")
var character_data=Global.get_now_character_data()
character_texture.texture=Global.get_texture(character_data["character"]["skin"][character_data["character"]["skin_now_use"]]["card_face"])
func set_scene(id:String): func set_scene(id:String):
scene_data=Global.get_scene_data(id) scene_data=Global.get_scene_data(id)
back.texture=Global.get_texture(scene_data["texture"]) back.texture=Global.get_texture(scene_data["texture"])
for i in event.get_children(): for i in event.get_children():
i.queue_free() i.queue_free()
for i in place_add.get_children():
i.queue_free()
for i in scene_data["quick_event"]: for i in scene_data["quick_event"]:
var new_btn=GAME_FLOW_EVENT.instantiate() var new_btn=GAME_FLOW_EVENT.instantiate()
event.add_child(new_btn) event.add_child(new_btn)
new_btn.set_data(i) new_btn.set_data(i)
new_btn.pressed.connect(event_pressed)
for i in scene_data["linked_scene"]:
var new_place=GAME_FLOW_PLACE.instantiate()
place_add.add_child(new_place)
new_place.set_data(i)
new_place.pressed.connect(place_pressed)
pass
pass
func place_pressed(data:Dictionary):
animation_mask.show()
animation_player.play("change")
await animation_player.animation_finished
set_scene(data["id"])
await get_tree().create_timer(0.2).timeout
animation_player.play_backwards("change")
await animation_player.animation_finished
animation_mask.hide()
pass
func event_pressed(event_data:Dictionary):
event_panel.show()
event_panel.set_event_data(event_data["event"])
pass pass

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://bht5sd88340s5"] [gd_scene load_steps=25 format=3 uid="uid://bht5sd88340s5"]
[ext_resource type="Texture2D" uid="uid://5vyvaedcfv38" path="res://res/ui/ui_019_game_flow/tuceng1.png" id="1_gjw3y"] [ext_resource type="Texture2D" uid="uid://5vyvaedcfv38" path="res://res/ui/ui_019_game_flow/tuceng1.png" id="1_gjw3y"]
[ext_resource type="Script" path="res://scene/game_flow.gd" id="1_w6afk"] [ext_resource type="Script" path="res://scene/game_flow.gd" id="1_w6afk"]
@ -17,6 +17,57 @@
[ext_resource type="Texture2D" uid="uid://cfkrivnhdpg8l" path="res://res/ui/ui_019_game_flow/tuceng281.png" id="14_5tsah"] [ext_resource type="Texture2D" uid="uid://cfkrivnhdpg8l" path="res://res/ui/ui_019_game_flow/tuceng281.png" id="14_5tsah"]
[ext_resource type="PackedScene" uid="uid://dr7aeaevf1qun" path="res://scene/game_flow_place.tscn" id="15_2cypk"] [ext_resource type="PackedScene" uid="uid://dr7aeaevf1qun" path="res://scene/game_flow_place.tscn" id="15_2cypk"]
[ext_resource type="PackedScene" uid="uid://b3hw4w5shpyu0" path="res://scene/event.tscn" id="17_xt42m"] [ext_resource type="PackedScene" uid="uid://b3hw4w5shpyu0" path="res://scene/event.tscn" id="17_xt42m"]
[ext_resource type="Shader" path="res://res/shader/change_scene.gdshader" id="18_ubmfk"]
[sub_resource type="Gradient" id="Gradient_4wq1v"]
[sub_resource type="GradientTexture2D" id="GradientTexture2D_jb43e"]
gradient = SubResource("Gradient_4wq1v")
width = 1920
height = 1080
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1nx3x"]
shader = ExtResource("18_ubmfk")
shader_parameter/cutoff = 1.0
shader_parameter/smooth_size = null
shader_parameter/mask = SubResource("GradientTexture2D_jb43e")
[sub_resource type="Animation" id="Animation_i6qty"]
resource_name = "change"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("animation_mask:material:shader_parameter/cutoff")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [1.0, 0.0]
}
[sub_resource type="Animation" id="Animation_bsgds"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("animation_mask:material:shader_parameter/cutoff")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [1.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ljrcq"]
_data = {
"RESET": SubResource("Animation_bsgds"),
"change": SubResource("Animation_i6qty")
}
[node name="game_flow" type="Control"] [node name="game_flow" type="Control"]
layout_mode = 3 layout_mode = 3
@ -115,7 +166,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("6_jmymv") texture = ExtResource("6_jmymv")
[node name="TextureRect" type="TextureRect" parent="hbox/TextureRect/TextureRect"] [node name="character_texture" type="TextureRect" parent="hbox/TextureRect/TextureRect"]
show_behind_parent = true show_behind_parent = true
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
@ -339,7 +390,7 @@ texture = ExtResource("14_5tsah")
[node name="ToolButton" parent="HBoxContainer/TextureRect3" instance=ExtResource("8_q6ple")] [node name="ToolButton" parent="HBoxContainer/TextureRect3" instance=ExtResource("8_q6ple")]
layout_mode = 1 layout_mode = 1
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="place_add" type="VBoxContainer" parent="."]
layout_mode = 0 layout_mode = 0
offset_left = 1610.0 offset_left = 1610.0
offset_top = 119.0 offset_top = 119.0
@ -347,18 +398,34 @@ offset_right = 1886.0
offset_bottom = 633.0 offset_bottom = 633.0
theme_override_constants/separation = 37 theme_override_constants/separation = 37
[node name="game_flow_place" parent="VBoxContainer" instance=ExtResource("15_2cypk")] [node name="game_flow_place" parent="place_add" instance=ExtResource("15_2cypk")]
layout_mode = 2 layout_mode = 2
[node name="game_flow_place2" parent="VBoxContainer" instance=ExtResource("15_2cypk")] [node name="game_flow_place2" parent="place_add" instance=ExtResource("15_2cypk")]
layout_mode = 2 layout_mode = 2
[node name="game_flow_place3" parent="VBoxContainer" instance=ExtResource("15_2cypk")] [node name="game_flow_place3" parent="place_add" instance=ExtResource("15_2cypk")]
layout_mode = 2 layout_mode = 2
[node name="game_flow_place4" parent="VBoxContainer" instance=ExtResource("15_2cypk")] [node name="game_flow_place4" parent="place_add" instance=ExtResource("15_2cypk")]
layout_mode = 2 layout_mode = 2
[node name="event" parent="." instance=ExtResource("17_xt42m")] [node name="event_panel" parent="." instance=ExtResource("17_xt42m")]
visible = false visible = false
layout_mode = 1 layout_mode = 1
[node name="animation_mask" type="ColorRect" parent="."]
visible = false
material = SubResource("ShaderMaterial_1nx3x")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_ljrcq")
}

View File

@ -1,7 +1,12 @@
extends Panel extends Panel
@onready var label: Label = $Label @onready var label: Label = $Label
signal pressed(data:Dictionary)
var data:Dictionary var data:Dictionary
func set_data(d:Dictionary): func set_data(d:Dictionary):
data=d data=d
label.text=data.name label.text=data.name
func _on_tool_button_pressed() -> void:
pressed.emit(data)
pass # Replace with function body.

View File

@ -37,3 +37,5 @@ metadata/_edit_use_anchors_ = true
[node name="ToolButton" parent="." instance=ExtResource("2_cbja7")] [node name="ToolButton" parent="." instance=ExtResource("2_cbja7")]
layout_mode = 1 layout_mode = 1
[connection signal="pressed" from="ToolButton" to="." method="_on_tool_button_pressed"]

14
scene/game_flow_place.gd Normal file
View File

@ -0,0 +1,14 @@
extends TextureRect
signal pressed(da:Dictionary)
@onready var label: Label = $Label
var data:Dictionary
func set_data(da:Dictionary):
data=da
label.text=data["name"]
pass
func _on_tool_button_pressed() -> void:
pressed.emit(data)
pass # Replace with function body.

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=3 uid="uid://dr7aeaevf1qun"] [gd_scene load_steps=4 format=3 uid="uid://dr7aeaevf1qun"]
[ext_resource type="Texture2D" uid="uid://dvxmxuudn4tf4" path="res://res/ui/ui_019_game_flow/tuceng301.png" id="1_lju64"] [ext_resource type="Texture2D" uid="uid://dvxmxuudn4tf4" path="res://res/ui/ui_019_game_flow/tuceng301.png" id="1_lju64"]
[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="2_ca2j0"] [ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="2_ca2j0"]
[ext_resource type="Script" path="res://scene/game_flow_place.gd" id="2_stiwr"]
[node name="game_flow_place" type="TextureRect"] [node name="game_flow_place" type="TextureRect"]
offset_right = 40.0 offset_right = 40.0
@ -9,6 +10,7 @@ offset_bottom = 40.0
size_flags_horizontal = 8 size_flags_horizontal = 8
size_flags_vertical = 0 size_flags_vertical = 0
texture = ExtResource("1_lju64") texture = ExtResource("1_lju64")
script = ExtResource("2_stiwr")
[node name="Label" type="Label" parent="."] [node name="Label" type="Label" parent="."]
layout_mode = 1 layout_mode = 1
@ -23,3 +25,5 @@ vertical_alignment = 1
[node name="ToolButton" parent="." instance=ExtResource("2_ca2j0")] [node name="ToolButton" parent="." instance=ExtResource("2_ca2j0")]
layout_mode = 1 layout_mode = 1
[connection signal="pressed" from="ToolButton" to="." method="_on_tool_button_pressed"]

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=8 format=3 uid="uid://vd8ovfqb4bkq"] [gd_scene load_steps=9 format=3 uid="uid://vd8ovfqb4bkq"]
[ext_resource type="Script" path="res://scene/start_the_game.gd" id="1_ivvmj"] [ext_resource type="Script" path="res://scene/start_the_game.gd" id="1_ivvmj"]
[ext_resource type="Texture2D" uid="uid://bxpr6jpaoc851" path="res://res/ui/ui_001_start/bg.png" id="1_nr2kd"] [ext_resource type="Texture2D" uid="uid://bxpr6jpaoc851" path="res://res/ui/ui_001_start/bg.png" id="1_nr2kd"]
[ext_resource type="Texture2D" uid="uid://770dcxkygn8b" path="res://res/ui/ui_001_start/title.png" id="2_c0f48"] [ext_resource type="Texture2D" uid="uid://770dcxkygn8b" path="res://res/ui/ui_001_start/title.png" id="2_c0f48"]
[ext_resource type="Texture2D" uid="uid://bbamxd1q6qwkd" path="res://res/ui/ui_001_start/button_0.png" id="3_ljvo4"] [ext_resource type="Texture2D" uid="uid://bbamxd1q6qwkd" path="res://res/ui/ui_001_start/button_0.png" id="3_ljvo4"]
[ext_resource type="Texture2D" uid="uid://syusk0q7y0jv" path="res://res/ui/ui_001_start/choice.png" id="5_yiext"] [ext_resource type="Texture2D" uid="uid://syusk0q7y0jv" path="res://res/ui/ui_001_start/choice.png" id="5_yiext"]
[ext_resource type="PackedScene" uid="uid://ln0ri824gh2c" path="res://scene/save_and_load.tscn" id="6_8wpd4"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_m4deq"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_m4deq"]
content_margin_left = 102.0 content_margin_left = 102.0
@ -154,6 +155,10 @@ pivot_offset = Vector2(38, 42)
mouse_filter = 2 mouse_filter = 2
texture = ExtResource("5_yiext") texture = ExtResource("5_yiext")
[node name="save_and_load" parent="." instance=ExtResource("6_8wpd4")]
visible = false
layout_mode = 1
[connection signal="mouse_entered" from="MarginContainer/VBoxContainer2/VBoxContainer/Button" to="." method="_on_button_mouse_entered"] [connection signal="mouse_entered" from="MarginContainer/VBoxContainer2/VBoxContainer/Button" to="." method="_on_button_mouse_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer2/VBoxContainer/Button" to="." method="_on_button_pressed"] [connection signal="pressed" from="MarginContainer/VBoxContainer2/VBoxContainer/Button" to="." method="_on_button_pressed"]
[connection signal="mouse_entered" from="MarginContainer/VBoxContainer2/VBoxContainer/Button2" to="." method="_on_button_2_mouse_entered"] [connection signal="mouse_entered" from="MarginContainer/VBoxContainer2/VBoxContainer/Button2" to="." method="_on_button_2_mouse_entered"]