2024-04-12 11:06:25 +08:00
|
|
|
extends Node3D
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##车门
|
|
|
|
class_name TrainDoor
|
2024-04-12 11:06:25 +08:00
|
|
|
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
|
|
|
|
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
|
|
|
|
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
## 车门的状态枚举
|
2024-04-12 11:06:25 +08:00
|
|
|
enum Train_Door_STATE{
|
2024-04-29 15:00:41 +08:00
|
|
|
open,# 开门
|
|
|
|
close,# 关门
|
2024-04-12 11:06:25 +08:00
|
|
|
}
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##车门的状态
|
|
|
|
@onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.close :
|
2024-04-12 11:06:25 +08:00
|
|
|
set(value):
|
|
|
|
if trainDoorState != value:
|
|
|
|
trainDoorState = value
|
|
|
|
if trainDoorState ==Train_Door_STATE.open :
|
|
|
|
left_animation_player.play("leftOpen")
|
|
|
|
right_animation_player.play("rightOpen")
|
|
|
|
elif trainDoorState ==Train_Door_STATE.close :
|
|
|
|
left_animation_player.play("leftClose")
|
|
|
|
right_animation_player.play("rightClose")
|
|
|
|
|
|
|
|
|
2024-04-29 15:00:41 +08:00
|
|
|
##打开车门
|
|
|
|
func openTrainDoor ()-> void:
|
|
|
|
trainDoorState=Train_Door_STATE.open
|
|
|
|
|
|
|
|
|
|
|
|
##关闭车门
|
|
|
|
func closeTrainDoor ()-> void:
|
|
|
|
trainDoorState=Train_Door_STATE.close
|