godot-psd-training/UI/LCB/lcb.gd
2024-04-26 16:54:17 +08:00

58 lines
1.2 KiB
GDScript

extends Window
var currenScreenDoor:ScreenDoor=null
func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void:
var screenDoorName=String(screenDoor.name)
self.title='LCB'+screenDoorName[screenDoorName.length() - 1]
self.show()
$"../stationKeys".show()
$"../stationKeys".shouAllKeys()
currenScreenDoor=screenDoor
resetState()
func _on_close_requested() -> void:
self.hide()
$"../stationKeys".hide()
## 旋钮的状态枚举
enum KNOB_STATE{
ISOLATE,# 隔离
AUTO,# 自动
OPEN,# 开门
CLOSE,# 关门
}
@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
##重置面板
func resetState():
change_knob_state(KNOB_STATE.AUTO)
$TextureRect2.rotation = 0
hideHandleKey()