godot-psd-training/sceen/platform/gate/gateDoor.gd
2024-07-16 11:00:51 +08:00

40 lines
1022 B
GDScript

extends Node3D
##车门
class_name GateDoor
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
## 车门的状态枚举
enum Gate_Door_STATE{
opening,# 正在开门
open,#开到位
closeing,#正在关门
close,# 关到位
}
##车门的状态
@onready var gateDoorState : Gate_Door_STATE = Gate_Door_STATE.close :
set(value):
if gateDoorState != value:
gateDoorState = value
if gateDoorState == Gate_Door_STATE.open :
left_animation_player.play("leftOpen")
right_animation_player.play("rightOpen")
elif gateDoorState == Gate_Door_STATE.close :
left_animation_player.play("leftClose")
right_animation_player.play("rightClose")
##打开车门
func openGateDoor ()-> void:
if gateDoorState == Gate_Door_STATE.close :
gateDoorState = Gate_Door_STATE.open
##关闭车门
func closeGateDoor ()-> void:
if gateDoorState == Gate_Door_STATE.open :
gateDoorState=Gate_Door_STATE.close