This commit is contained in:
soul-walker 2024-04-18 19:03:04 +08:00
commit 38727dfffd
9 changed files with 143 additions and 56 deletions

View File

@ -1,19 +1,12 @@
extends Window
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_psl_button_pressed() -> void:
print('psl-button-pressed');
var currenScreenDoor:ScreenDoor=null
func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void:
self.show()
$"../stationKeys".show()
$"../stationKeys".shouAllKeys()
currenScreenDoor=screenDoor
hideHandleKey()
func _on_close_requested() -> void:
@ -26,7 +19,29 @@ enum KNOB_STATE{
OPEN,# 开门
CLOSE,# 关门
}
var knob_state = KNOB_STATE.AUTO;
@onready var knob_state : KNOB_STATE = KNOB_STATE.AUTO :
set(value):
knob_state = value
if knob_state==KNOB_STATE.OPEN:
currenScreenDoor.openScreenDoor()
elif knob_state==KNOB_STATE.CLOSE:
currenScreenDoor.closeScreenDoor()
func change_knob_state(state):
knob_state = state
##展示控制的钥匙
func shouHandleKey():
$TextureRect2.visible=true
$LCB2_Right_Rotate.visible=true
$LCB2_Left_Rotate.visible=true
##隐藏控制的钥匙
func hideHandleKey():
$TextureRect2.visible=false
$LCB2_Right_Rotate.visible=false
$LCB2_Left_Rotate.visible=false

View File

@ -163,6 +163,7 @@ texture = ExtResource("3_g3cqx")
stretch_mode = 5
[node name="TextureRect2" type="TextureRect" parent="."]
visible = false
offset_left = 72.0
offset_top = 72.0
offset_right = 328.0
@ -206,6 +207,7 @@ theme = ExtResource("2_owxtu")
text = "关门"
[node name="LCB2_Right_Rotate" type="Sprite2D" parent="."]
visible = false
modulate = Color(0, 1, 1, 1)
position = Vector2(241, 140)
rotation = 0.968658
@ -214,6 +216,7 @@ texture = ExtResource("5_l3h46")
script = ExtResource("6_bg24u")
[node name="LCB2_Left_Rotate" type="Sprite2D" parent="."]
visible = false
position = Vector2(154, 140)
rotation = -0.961676
scale = Vector2(0.23, 0.23)

View File

@ -2,19 +2,21 @@ extends Window
var current_focus: CanvasItem
const NodeUtils = preload("res://util/NodeUtils.gd")
func _on_key_focus_entered(node):
current_focus = node
print("node : ", current_focus.name, " focus")
func _on_button_pressed():
if current_focus == null:
print("请选择钥匙")
else:
print("使用钥匙:", current_focus.name)
current_focus.hide_key()
var screenDoor4=find_child_by_name($"../platform",'screenDoor4')
screenDoor4.closeScreenDoor()
if(current_focus.name.contains('LCB')):
$"../LCB".shouHandleKey()
func _on_close_requested():
@ -25,21 +27,9 @@ func _on_close_requested():
func _on_show_button_pressed():
print('on_show_button_pressed');
self.show()
func shouAllKeys():
NodeUtils.make_node_and_descendants_visible($PanelContainer/VBoxContainer/GridContainer)
func _on_psl_button_pressed() -> void:
print('psl-button-pressed');
self.show()
func find_child_by_name(parent_node, target_name):
if parent_node.name == target_name:
return parent_node
for child in parent_node.get_children():
var found_node = find_child_by_name(child, target_name)
if found_node != null:
return found_node
return null

View File

@ -0,0 +1,19 @@
extends Area3D
@onready var mouse_over = false
@onready var screen_door: ScreenDoor = $"../.."
func _input(event):
if event is InputEventMouseButton and event.pressed:
if mouse_over and event.button_index == MOUSE_BUTTON_LEFT: # 左键点击
screen_door.clickLcbSignal.emit(screen_door)
func _on_mouse_entered() -> void:
mouse_over = true
func _on_mouse_exited() -> void:
mouse_over = false

View File

@ -1,7 +1,9 @@
[gd_scene load_steps=8 format=3 uid="uid://cmnsn2joxo68l"]
[gd_scene load_steps=10 format=3 uid="uid://cmnsn2joxo68l"]
[ext_resource type="PackedScene" uid="uid://b07w0k0uy82f7" path="res://Model/platform/platform.gltf" id="1_5t7j8"]
[ext_resource type="PackedScene" uid="uid://b41ml6vpfik6v" path="res://UI/LCB2/lcb_2.tscn" id="3_f0qkt"]
[ext_resource type="PackedScene" uid="uid://bc2dnsyx16kk6" path="res://sceen/platform/screenDoor.tscn" id="4_507v2"]
[ext_resource type="PackedScene" uid="uid://d167och8l6jms" path="res://UI/station_keys/station_keys_window.tscn" id="4_xd08d"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v2w26"]
resource_name = "20 - Default"
@ -101,3 +103,17 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.65, 0, 0)
[node name="screenDoor4" parent="." instance=ExtResource("4_507v2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.93, 0, 0)
[node name="LCB" parent="." instance=ExtResource("3_f0qkt")]
position = Vector2i(518, 324)
visible = false
[node name="stationKeys" parent="." instance=ExtResource("4_xd08d")]
position = Vector2i(1133, 325)
visible = false
[connection signal="clickLcbSignal" from="screenDoor1" to="LCB" method="_on_screen_door_click_lcb_signal"]
[connection signal="clickLcbSignal" from="screenDoor2" to="LCB" method="_on_screen_door_click_lcb_signal"]
[connection signal="clickLcbSignal" from="screenDoor3" to="LCB" method="_on_screen_door_click_lcb_signal"]
[connection signal="clickLcbSignal" from="screenDoor4" to="LCB" method="_on_screen_door_click_lcb_signal"]
[connection signal="close_requested" from="LCB" to="LCB" method="_on_close_requested"]

View File

@ -1,11 +1,14 @@
extends Node3D
##左边的
class_name screenDoor
##屏蔽
class_name ScreenDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
signal clickLcbSignal(screenDoor)
## 屏蔽门的状态枚举
enum Screen_Door_STATE{
idle = 0,

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=21 format=3 uid="uid://bc2dnsyx16kk6"]
[gd_scene load_steps=23 format=3 uid="uid://bc2dnsyx16kk6"]
[ext_resource type="Script" path="res://sceen/platform/screenDoor.gd" id="1_nse1y"]
[ext_resource type="Script" path="res://sceen/platform/LCB_Area3D.gd" id="2_lbd6y"]
[ext_resource type="Texture2D" uid="uid://c0gto8nc6msh4" path="res://Model/screenDoor/screenDoor_haerbin_jz_menkuangyanse87.png" id="2_rfgim"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v2w26"]
@ -44,6 +45,8 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_5y5yp")
[sub_resource type="BoxShape3D" id="BoxShape3D_lefsu"]
[sub_resource type="ArrayMesh" id="ArrayMesh_mnw5j"]
_surfaces = [{
"aabb": AABB(-0.123623, -0.0377295, -0.0186467, 0.247246, 0.075459, 0.0372938),
@ -264,6 +267,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.75579, 2.92652, -7.30781)
mesh = SubResource("ArrayMesh_ub7at")
skeleton = NodePath("")
[node name="LCB_Area3D" type="Area3D" parent="LCB"]
transform = Transform3D(0.207, 0, 0, 0, 0.125, 0, 0, 0, 0.205, 0, 0.00459647, 0)
script = ExtResource("2_lbd6y")
[node name="CollisionShape3D" type="CollisionShape3D" parent="LCB/LCB_Area3D"]
shape = SubResource("BoxShape3D_lefsu")
[node name="MTD" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.1674, 2.99429, -7.28448)
mesh = SubResource("ArrayMesh_1manj")
@ -290,3 +300,11 @@ root_node = NodePath("../right")
libraries = {
"": SubResource("AnimationLibrary_u6vct")
}
[node name="Label3D" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.75486, 2.94432, -7.258)
text = "LCB"
font_size = 13
[connection signal="mouse_entered" from="LCB/LCB_Area3D" to="LCB/LCB_Area3D" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="LCB/LCB_Area3D" to="LCB/LCB_Area3D" method="_on_mouse_exited"]

View File

@ -1,8 +1,6 @@
[gd_scene load_steps=11 format=3 uid="uid://btcksdsburk7t"]
[gd_scene load_steps=9 format=3 uid="uid://btcksdsburk7t"]
[ext_resource type="PackedScene" uid="uid://cmnsn2joxo68l" path="res://sceen/platform/platform.tscn" id="1_rjva4"]
[ext_resource type="PackedScene" uid="uid://d167och8l6jms" path="res://UI/station_keys/station_keys_window.tscn" id="4_wk067"]
[ext_resource type="PackedScene" uid="uid://b41ml6vpfik6v" path="res://UI/LCB2/lcb_2.tscn" id="5_gexrn"]
[ext_resource type="PackedScene" uid="uid://nx6xnwcuq8cf" path="res://sceen/train/train.tscn" id="14_g0uwl"]
[ext_resource type="Script" path="res://sceen/train/train.gd" id="15_r0ogb"]
@ -85,19 +83,3 @@ root_node = NodePath("../WorldEnvironment")
libraries = {
"": SubResource("AnimationLibrary_lf7ox")
}
[node name="PSL_Button" type="Button" parent="."]
offset_left = 144.0
offset_top = 132.0
offset_right = 180.0
offset_bottom = 163.0
text = "PSL"
[node name="Window" parent="." instance=ExtResource("4_wk067")]
visible = false
[node name="LCB2" parent="." instance=ExtResource("5_gexrn")]
visible = false
[connection signal="pressed" from="PSL_Button" to="Window" method="_on_psl_button_pressed"]
[connection signal="close_requested" from="LCB2" to="LCB2" method="_on_close_requested"]

41
util/NodeUtils.gd Normal file
View File

@ -0,0 +1,41 @@
extends Object
# 移除node节点
static func removeNode(node: Node) -> void:
if (node == null):
return
var parent = node.get_parent()
if (parent == null):
node.queue_free()
return
parent.remove_child(node)
node.queue_free()
pass
# 查找指定节点下的第一个目标节点
static func find_child_by_name(parent_node, target_name):
if parent_node.name == target_name:
return parent_node
for child in parent_node.get_children():
var found_node = find_child_by_name(child, target_name)
if found_node != null:
return found_node
return null
static func search_node(node,target_name,matching_nodes):
if node.name == target_name:
matching_nodes.append(node)
for child in node.get_children():
search_node(child,target_name,matching_nodes)
# 查找指定节点下的所有目标节点
static func find_children_by_name(parent_node, target_name):
var matching_nodes = []
search_node(parent_node,target_name,matching_nodes)
return matching_nodes
##节点下的所有节点可见
static func make_node_and_descendants_visible(node: Node):
node.visible = true
for child in node.get_children():
make_node_and_descendants_visible(child)