51 lines
1014 B
GDScript
51 lines
1014 B
GDScript
extends Window
|
|
|
|
var current_focus: CanvasItem
|
|
|
|
func _on_key_focus_entered(node):
|
|
current_focus = node
|
|
print("node : ", current_focus.name, " focus")
|
|
|
|
## 门的状态枚举
|
|
enum Screen_Door_STATE{
|
|
idle = 0,
|
|
open = 1,# 开门
|
|
close = 2,# 关门
|
|
}
|
|
func _on_button_pressed():
|
|
if current_focus == null:
|
|
print("请选择钥匙")
|
|
else:
|
|
print("使用钥匙:", current_focus.name)
|
|
current_focus.hide_key()
|
|
var zhao=find_child_by_name($"../platform",'screenDoor4')
|
|
zhao.screenDoorState=Screen_Door_STATE.close
|
|
print(zhao.name,zhao.screenDoorState,6666)
|
|
|
|
|
|
|
|
func _on_close_requested():
|
|
print("close req")
|
|
self.hide()
|
|
|
|
|
|
func _on_show_button_pressed():
|
|
self.show()
|
|
|
|
|
|
func _on_psl_button_pressed() -> void:
|
|
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
|
|
|
|
|
|
|