36 lines
736 B
GDScript
36 lines
736 B
GDScript
extends Node3D
|
|
|
|
##左边的门
|
|
class_name train
|
|
@onready var train_animation_player: AnimationPlayer = $"../trainAnimationPlayer"
|
|
|
|
|
|
|
|
## 门的状态枚举
|
|
enum Train_STATE{
|
|
idle = 0,
|
|
come = 1,# 车来
|
|
leave = 2,# 车走
|
|
}
|
|
|
|
##门是否移动
|
|
@onready var trainState : Train_STATE = Train_STATE.idle :
|
|
set(value):
|
|
if trainState != value:
|
|
trainState = value
|
|
if trainState == Train_STATE.come :
|
|
train_animation_player.play("trainCome")
|
|
elif trainState == Train_STATE.leave :
|
|
train_animation_player.play("trainLeave")
|
|
|
|
var count=0
|
|
func _process(delta: float) -> void:
|
|
count+=1
|
|
if count<180:
|
|
trainState=Train_STATE.come
|
|
elif count>1000 and count<2000:
|
|
trainState=Train_STATE.leave
|
|
elif count>2000:
|
|
count=0
|
|
|