godot-psd-training/sceen/platform/screenDoor.gd

57 lines
1.4 KiB
GDScript3
Raw Normal View History

2024-04-12 11:06:25 +08:00
extends Node3D
2024-04-17 15:26:37 +08:00
##屏蔽门
class_name ScreenDoor
2024-04-12 11:06:25 +08:00
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
2024-04-22 10:57:46 +08:00
signal clickLcbSignalAndSent(screenDoor)
2024-04-17 15:26:37 +08:00
2024-04-12 15:01:34 +08:00
## 屏蔽门的状态枚举
2024-04-12 11:06:25 +08:00
enum Screen_Door_STATE{
idle = 0,
open = 1,# 开门
close = 2,# 关门
}
2024-04-12 15:01:34 +08:00
##屏蔽门的状态
2024-04-12 11:06:25 +08:00
@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")
2024-04-12 16:55:38 +08:00
##打开屏蔽门
2024-04-12 15:01:34 +08:00
func openScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.open
##关闭屏蔽门
func closeScreenDoor ()-> void:
screenDoorState=Screen_Door_STATE.close
2024-04-12 11:06:25 +08:00
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
2024-04-12 15:01:34 +08:00
2024-04-22 10:57:46 +08:00
func _on_lcb_click() -> void:
self.clickLcbSignalAndSent.emit(self)