godot-psd-training/sceen/platform/screenDoor.gd
2024-04-22 10:57:46 +08:00

57 lines
1.4 KiB
GDScript

extends Node3D
##屏蔽门
class_name ScreenDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
signal clickLcbSignalAndSent(screenDoor)
## 屏蔽门的状态枚举
enum Screen_Door_STATE{
idle = 0,
open = 1,# 开门
close = 2,# 关门
}
##屏蔽门的状态
@onready var screenDoorState : Screen_Door_STATE = Screen_Door_STATE.idle :
set(value):
if screenDoorState != value:
screenDoorState = value
if screenDoorState == Screen_Door_STATE.open :
left_animation_player.play("leftOpen")
right_animation_player.play("rightOpen")
elif screenDoorState == Screen_Door_STATE.close :
left_animation_player.play("leftClose")
right_animation_player.play("rightClose")
##打开屏蔽门
func openScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.open
##关闭屏蔽门
func closeScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.close
var count=0
func _process(delta: float) -> void:
count+=1
if count>150 and count<360:
screenDoorState=Screen_Door_STATE.open
elif count>540 and count<720 :
if self.name != "screenDoor2" and self.name != "screenDoor4":
screenDoorState=Screen_Door_STATE.close
elif count>720 and count<1000 :
if self.name == "screenDoor2":
screenDoorState=Screen_Door_STATE.close
elif count>2000 :
count=0
func _on_lcb_click() -> void:
self.clickLcbSignalAndSent.emit(self)