godot-psd-training/sceen/platform/screenDoor.gd
2024-04-12 11:06:25 +08:00

42 lines
1.1 KiB
GDScript

extends Node3D
##左边的门
class_name screenDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
## 门的状态枚举
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")
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