godot-psd-training/sceen/platform/shortcutTool/ShortcutToolModel2.gd

196 lines
8.6 KiB
GDScript3
Raw Normal View History

extends Node3D
2024-07-09 17:27:43 +08:00
class_name ShortcutToolModel2
##是否允许操作
var allowHandle :bool = true
##所有ShortTool点击操作汇总
signal AllClickShortcutToolModel2(equipmentName:String, equipmentInfo: Variant)
2024-07-11 17:49:28 +08:00
func allTimerStopAndShowRedStripe() -> void:
for child in [$picketlineModelAtB,$picketlineModelAtA,$picketlineModelAtGateB,$picketlineModelAtGateA]:
child.get_node('Timer').stop()
2024-07-15 10:29:36 +08:00
var redStripe = child.get_node('redStripe')
redStripe.position.y = 0
redStripe.visible = true
2024-07-11 17:49:28 +08:00
var picketlineModelAtBCountTime = 0
func _picketlineModelAtB_timer_timeout() -> void:
handleRedStripeVisible(picketlineModelAtBCountTime,$picketlineModelAtB/redStripe,1)
var picketlineModelAtACountTime = 0
func _picketlineModelAtA_timer_timeout() -> void:
handleRedStripeVisible(picketlineModelAtACountTime,$picketlineModelAtA/redStripe,2)
var picketlineModelAtGateBCountTime = 0
func _picketlineModelAtGateB_timer_timeout() -> void:
handleRedStripeVisible(picketlineModelAtGateBCountTime,$picketlineModelAtGateB/redStripe,3)
var picketlineModelAtGateACountTime = 0
func _picketlineModelAtGateA_timer_timeout() -> void:
handleRedStripeVisible(picketlineModelAtGateACountTime,$picketlineModelAtGateA/redStripe,4)
func handleRedStripeVisible(countTime:int, redStripe:Node3D,index:int) -> void:
countTime += 1
if countTime > 5 and countTime < 15 :
redStripe.visible = false
redStripe.position.y = -30
elif countTime >= 15 :
redStripe.position.y = 0
redStripe.visible = true
countTime = 0
match index :
1:
picketlineModelAtBCountTime = countTime
2:
picketlineModelAtACountTime = countTime
3:
picketlineModelAtGateBCountTime = countTime
4:
picketlineModelAtGateACountTime = countTime
func _on_mouse_entered() -> void:
Input.set_default_cursor_shape(Input.CursorShape.CURSOR_POINTING_HAND)
func _on_mouse_exited() -> void:
Input.set_default_cursor_shape(Input.CursorShape.CURSOR_ARROW)
func _on_hoarding_at_escalator_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('hoardingAtEscalatorUp',self)
if !allowHandle :
return
$hoardingAtEscalatorUp.visible = false
$hoardingAtEscalatorUp/hoardingAtEscalator_Area3D.position.y = -30
2024-07-23 19:46:26 +08:00
func _on_hoarding_at_escalator_area_3d_area_entered(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow and area.is_in_group('player'):
$hoardingAtEscalatorUp/hoardingAtEscalator_Area3D.position.y = -30
peopleWalkFollow.peopleInDesignatedAreaChangeMoveSignal.emit('hoardingAtEscalatorUp',peopleWalkFollow)
await get_tree().create_timer(0.5).timeout
$hoardingAtEscalatorUp/hoardingAtEscalator_Area3D.position.y = 0
func _on_hoarding_at_escalator_down_area_3d_area_entered(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow and area.is_in_group('player'):
$hoardingAtEscalatorDown/hoardingAtEscalatorDown_Area3D.position.y = -30
peopleWalkFollow.peopleInDesignatedAreaChangeMoveSignal.emit('hoardingAtEscalatorDown',peopleWalkFollow)
await get_tree().create_timer(0.5).timeout
$hoardingAtEscalatorDown/hoardingAtEscalatorDown_Area3D.position.y = 0
func _on_hoarding_at_escalator_down_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('hoardingAtEscalatorDown',self)
if !allowHandle :
return
$hoardingAtEscalatorDown.visible = false
func _on_picketline_model_at_b_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('picketlineModelAtB',self)
if !allowHandle :
return
$picketlineModelAtB.visible = false
2024-07-15 14:18:28 +08:00
$picketlineModelAtB/redStripe.position.y = -30
func _on_picketline_model_at_a_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('picketlineModelAtA',self)
if !allowHandle :
return
$picketlineModelAtA.visible = false
2024-07-15 14:18:28 +08:00
$picketlineModelAtA/redStripe.position.y = -30
func _on_picketline_model_at_gate_b_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('picketlineModelAtGateB',self)
if !allowHandle :
return
$picketlineModelAtGateB.visible = false
2024-07-15 14:18:28 +08:00
$picketlineModelAtGateB/redStripe.position.y = -30
func _on_picketline_model_at_gate_a_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('picketlineModelAtGateA',self)
if !allowHandle :
return
$picketlineModelAtGateA.visible = false
2024-07-15 14:18:28 +08:00
$picketlineModelAtGateA/redStripe.position.y = -30
func _on_notice_signs_model_at_a_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('noticeSignsModelAtAEntrance',self)
if !allowHandle :
return
$noticeSignsModelAtAEntrance.visible = false
func _on_notice_signs_model_at_b_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('noticeSignsModelAtBEntrance',self)
if !allowHandle :
return
$noticeSignsModelAtBEntrance.visible = false
func _on_notice_signs_model_at_c_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('noticeSignsModelAtCEntrance',self)
if !allowHandle :
return
$noticeSignsModelAtCEntrance.visible = false
func _on_notice_signs_model_at_d_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('noticeSignsModelAtDEntrance',self)
if !allowHandle :
return
$noticeSignsModelAtDEntrance.visible = false
func _on_metal_barrier_model_at_d_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('metalBarrierModelAtDEntrance',self)
if !allowHandle :
return
$metalBarrierModelAtDEntrance.visible = false
2024-07-09 17:27:43 +08:00
func _on_metal_barrier_model_at_station_hall_d_exit_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
2024-07-09 17:27:43 +08:00
AllClickShortcutToolModel2.emit('metalBarrierModelAtStationHallDExit',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
$metalBarrierModelAtStationHallDExit.visible = false
func _on_metal_barrier_model_at_c_entrance_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
AllClickShortcutToolModel2.emit('metalBarrierModelAtCEntrance',self)
if !allowHandle :
return
$metalBarrierModelAtCEntrance.visible = false
func _on_metal_barrier_model_at_c_passage_area_3d_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
2024-07-09 17:27:43 +08:00
AllClickShortcutToolModel2.emit('metalBarrierModelAtStationHallCExit',self)
if !allowHandle :
return
2024-07-09 17:27:43 +08:00
$metalBarrierModelAtStationHallCExit.visible = false