godot-psd-training/UI/station_keys/station_keys_window.gd
2024-04-16 09:46:51 +08:00

46 lines
925 B
GDScript

extends Window
var current_focus: CanvasItem
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()
func _on_close_requested():
print("close req")
self.hide()
func _on_show_button_pressed():
print('on_show_button_pressed');
self.show()
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