godot-psd-training/UI/ShortcutTool/shortcutTool.gd

123 lines
4.3 KiB
GDScript3
Raw Normal View History

2024-06-21 08:45:56 +08:00
extends Node2D
2024-07-09 17:27:43 +08:00
##场景中需要布置的快捷工具对应的实体
@export var shortcutToolModel2: ShortcutToolModel2
2024-06-21 08:45:56 +08:00
##是否允许操作
var allowHandle :bool = true
##所有ShortTool点击操作汇总
signal AllClickShortcutTool(equipmentName:String,equipmentInfo)
#电扶梯钥匙
func _on_escalator_key_pressed() -> void:
AllClickShortcutTool.emit('escalatorKey',self)
if !allowHandle :
return
#手提广播
func _on_handheld_radio_pressed() -> void:
AllClickShortcutTool.emit('handheldRadio',self)
if !allowHandle :
return
#围挡(扶梯处)
func _on_hoarding_pressed() -> void:
AllClickShortcutTool.emit('hoarding',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
showSetShortcutToolEntity()
2024-06-21 08:45:56 +08:00
#警戒线(进站闸机处)
func _on_picketline_pressed() -> void:
AllClickShortcutTool.emit('picketline',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
showSetShortcutToolEntity()
2024-06-21 08:45:56 +08:00
#铁马
func _on_metal_barrier_pressed() -> void:
AllClickShortcutTool.emit('metalBarrier',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
showSetMetalBarrier()
2024-06-21 08:45:56 +08:00
#警示牌
func _on_notice_signs_pressed() -> void:
AllClickShortcutTool.emit('noticeSigns',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
showSetShortcutToolEntity()
##显示对应布置的工具
func showSetShortcutToolEntity()-> void:
var currentCamera :LargePassengerFlowScene.Camera_name = $"..".getCurrentCamera()
var camera_to_node_path := {
LargePassengerFlowScene.Camera_name.BUpperStep: 'hoardingAtEscalatorUp',
LargePassengerFlowScene.Camera_name.BLowerStep: 'hoardingAtEscalatorDown',
LargePassengerFlowScene.Camera_name.BGangway: 'picketlineModelAtB',
LargePassengerFlowScene.Camera_name.AGangway: 'picketlineModelAtA',
LargePassengerFlowScene.Camera_name.BInboundGate: 'picketlineModelAtGateB',
LargePassengerFlowScene.Camera_name.AInboundGate: 'picketlineModelAtGateA',
LargePassengerFlowScene.Camera_name.AEntrance: 'noticeSignsModelAtAEntrance',
LargePassengerFlowScene.Camera_name.BEntrance: 'noticeSignsModelAtBEntrance',
LargePassengerFlowScene.Camera_name.CEntrance: 'noticeSignsModelAtCEntrance',
LargePassengerFlowScene.Camera_name.DEntrance: 'noticeSignsModelAtDEntrance',
}
for camera in camera_to_node_path.keys():
if currentCamera == camera:
var node_path = camera_to_node_path[camera]
var entity = shortcutToolModel2.get_node(node_path)
entity.position.y += 30
entity.visible = true
2024-07-11 17:49:28 +08:00
if node_path in ['picketlineModelAtB','picketlineModelAtA','picketlineModelAtGateB','picketlineModelAtGateA']:
entity.get_node('Timer').start()
2024-07-09 17:27:43 +08:00
break
##显示对应布置的工具(铁马单独处理)
func showSetMetalBarrier()-> void:
var currentCamera :LargePassengerFlowScene.Camera_name = $"..".getCurrentCamera()
var camera_to_node_path := {
LargePassengerFlowScene.Camera_name.DEntrance: 'metalBarrierModelAtDEntrance',
LargePassengerFlowScene.Camera_name.StationHallDExit: 'metalBarrierModelAtStationHallDExit',
LargePassengerFlowScene.Camera_name.CEntrance: 'metalBarrierModelAtCEntrance',
LargePassengerFlowScene.Camera_name.StationHallCExit: 'metalBarrierModelAtStationHallCExit',
}
for camera in camera_to_node_path.keys():
if currentCamera == camera:
var node_path = camera_to_node_path[camera]
var entity = shortcutToolModel2.get_node(node_path)
entity.position.y += 30
entity.visible = true
break
2024-06-21 08:45:56 +08:00
##点击快捷工具对应的实物触发
func clickShortcutToolEntity(shortcutToolName:String,equipmentInfo: Variant) -> void:
if !equipmentInfo.allowHandle :
return
if shortcutToolName == 'escalatorKeyModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/escalatorKey.show()
$MarginContainer/HBoxContainer/escalatorKeyT.hide()
elif shortcutToolName == 'handheldRadioModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/handheldRadio.show()
$MarginContainer/HBoxContainer/handheldRadioT.hide()
elif shortcutToolName == 'hoardingModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/hoarding.show()
$MarginContainer/HBoxContainer/hoardingT.hide()
elif shortcutToolName == 'picketlineModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/picketline.show()
$MarginContainer/HBoxContainer/picketlineT.hide()
elif shortcutToolName == 'metalBarrierModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/metalBarrier.show()
$MarginContainer/HBoxContainer/metalBarrierT.hide()
elif shortcutToolName == 'noticeSignsModel':
2024-06-21 09:55:02 +08:00
$MarginContainer/HBoxContainer/noticeSigns.show()
$MarginContainer/HBoxContainer/noticeSignsT.hide()