184 lines
7.2 KiB
GDScript
184 lines
7.2 KiB
GDScript
extends TotalScene
|
|
|
|
class_name LargePassengerFlowScene
|
|
|
|
## 照相机名字的枚举
|
|
enum Camera_name{
|
|
#VehicleControlRoom,#车控室
|
|
SparePartsCabinet,#备品柜
|
|
PartsArea,#备品区
|
|
StationHall,#站厅
|
|
UpPlatform,#上行站台
|
|
DownPlatform,#下行站台
|
|
#APassageway,#A出入口
|
|
StationHallAExit,#站厅A出口
|
|
AEntrance,#A入口
|
|
APassage,#A口通道
|
|
#BPassageway,#B出入口
|
|
StationHallBExit,#站厅B出口
|
|
BEntrance,#B入口
|
|
BPassage,#B口通道
|
|
#CPassageway,#C出入口
|
|
StationHallCExit,#站厅C出口
|
|
CEntrance,#C入口
|
|
CPassage,#C口通道
|
|
#DPassageway,#D出入口
|
|
StationHallDExit,#站厅D出口
|
|
DEntrance,#D入口
|
|
DPassage,#D口通道
|
|
#StaionHallA,#站厅A端
|
|
ALowerStepSwitch,#A端扶梯下部开关
|
|
ATVM,#A端TVM
|
|
AInboundGate,#A端进站闸机
|
|
AExitGate,#A端出站闸机
|
|
AUpperStep,#A端扶梯上部
|
|
ALowerStep,#A端扶梯下部
|
|
AGangway,#A端站厅步梯口
|
|
#StationHallB,#站厅B端
|
|
BLowerStepSwitch,#B端扶梯下部开关
|
|
BTVM,#B端TVM
|
|
BInboundGate,#B端进站闸机
|
|
BExitGate,#B端出站闸机
|
|
BUpperStep,#B端扶梯上部
|
|
BLowerStep,#B端扶梯下部
|
|
BGangway,#B端站厅步梯口
|
|
}
|
|
|
|
@onready var cameras = [$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall,$AllCamera/SparePartsCabinet,$AllCamera/PartsArea,$AllCamera/StationHall]
|
|
|
|
##切换相机
|
|
func switchCamera (camera :Camera_name)-> void:
|
|
cameras[camera].make_current()
|
|
|
|
## 人运动区域的枚举
|
|
enum PlayerWalkArea3D {
|
|
defaultArea, #其它非固定区
|
|
ticketingArea, #购票区
|
|
entranceGateArea, #闸机入口区
|
|
elevatorUpArea, #扶梯上区
|
|
elevatorDownArea,#扶梯下区
|
|
screenDoorWaitArea,#屏蔽门等待区域
|
|
}
|
|
|
|
##区域运动(连续的路径点)
|
|
func playerGoToNextArea(peopleWalkFollow:PlayerPathFollow,currentArea: PlayerWalkArea3D) -> void:
|
|
match currentArea:
|
|
PlayerWalkArea3D.defaultArea:
|
|
peopleWalkFollow.player.setTargetPos(Vector3(1.4,1.2,11),0.1)
|
|
peopleWalkFollow.player.goToTarget()
|
|
await peopleWalkFollow.player.ArriveTargetPos
|
|
await get_tree().create_timer(1).timeout
|
|
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.ticketingArea)
|
|
PlayerWalkArea3D.ticketingArea:
|
|
peopleWalkFollow.player.setTargetPos(Vector3(-2,1.2,12),0.1)
|
|
peopleWalkFollow.player.goToTarget()
|
|
await peopleWalkFollow.player.ArriveTargetPos
|
|
await get_tree().create_timer(1).timeout
|
|
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entranceGateArea)
|
|
PlayerWalkArea3D.entranceGateArea:
|
|
peopleWalkFollow.player.setTargetPos(Vector3(-4.6,1.2,11),0.1)
|
|
peopleWalkFollow.player.goToTarget()
|
|
await peopleWalkFollow.player.ArriveTargetPos
|
|
await get_tree().create_timer(1).timeout
|
|
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.elevatorUpArea)
|
|
PlayerWalkArea3D.elevatorUpArea:
|
|
peopleWalkFollow.setPathPoints([peopleWalkFollow.player.position,Vector3(7,0,-2),Vector3(7,0,-5)],Vector3(4.5,4.5,0))
|
|
peopleWalkFollow.peopleBeginWalk()
|
|
await peopleWalkFollow.player.ArriveTargetPos
|
|
await get_tree().create_timer(1).timeout
|
|
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.elevatorDownArea)
|
|
PlayerWalkArea3D.elevatorDownArea:
|
|
goToScreenDoorAreaAndWaitTrain(peopleWalkFollow,3)
|
|
|
|
##演示排队的区域
|
|
var screenDoorAreaInfo = [
|
|
{
|
|
"areaName": "ScreenDoorWaitArea1",
|
|
"screenDoorName": 'screenDoor1',
|
|
},
|
|
{
|
|
"areaName": "ScreenDoorWaitArea2",
|
|
"screenDoorName": 'screenDoor2',
|
|
},
|
|
{
|
|
"areaName": "ScreenDoorWaitArea3",
|
|
"screenDoorName": 'screenDoor3',
|
|
},
|
|
{
|
|
"areaName": "ScreenDoorWaitArea4",
|
|
"screenDoorName": 'screenDoor4',
|
|
},
|
|
]
|
|
|
|
##进入指定屏蔽门区域并等待上车
|
|
func goToScreenDoorAreaAndWaitTrain(peopleWalkFollow:PlayerPathFollow, screenDoorAreaInfoIndex:int) -> void:
|
|
var screenDoorPos = $platform.get_node(screenDoorAreaInfo[screenDoorAreaInfoIndex].screenDoorName).get_node('dimiantishi').get_global_position()
|
|
var xOffset = screenDoorPos.x - peopleWalkFollow.buildPos.x
|
|
var zOffset = screenDoorPos.z - peopleWalkFollow.buildPos.z
|
|
await get_tree().create_timer(0.5).timeout
|
|
peopleWalkFollow.setPathPoints([peopleWalkFollow.player.position,Vector3(xOffset,0,zOffset+2),Vector3(xOffset,0,zOffset)])
|
|
peopleWalkFollow.peopleBeginWalk()
|
|
await self.screenDoorOpenConfirmSignal
|
|
peopleWalkFollow.setPathPoints([peopleWalkFollow.player.position,Vector3(xOffset,0,zOffset-3),Vector3(xOffset+3,0,zOffset-3)])
|
|
peopleWalkFollow.peopleBeginWalk()
|
|
await self.screenDoorCloseConfirmSignal
|
|
peopleWalkFollow.queue_free()
|
|
|
|
|
|
const ArrayUtils = preload("res://util/ArrayUtils.gd")
|
|
func _on_screen_door_wait_area_screen_door_area_enter(curentArea: Area3D, peopleWalkFollow: PlayerPathFollow) -> void:
|
|
var waitPeopleCounts = [$AllScreenDoorWaitArea/ScreenDoorWaitArea1.waitPeopleCount,$AllScreenDoorWaitArea/ScreenDoorWaitArea2.waitPeopleCount,$AllScreenDoorWaitArea/ScreenDoorWaitArea3.waitPeopleCount]
|
|
for index in range(screenDoorAreaInfo.size()):
|
|
if screenDoorAreaInfo[index].areaName == curentArea.name and curentArea.waitPeopleCount-1 <= ArrayUtils.removeElementByIndex(waitPeopleCounts,index).min() :
|
|
peopleWalkFollow.peopleStopWalk()
|
|
goToScreenDoorAreaAndWaitTrain(peopleWalkFollow,index)
|
|
|
|
var people_scene = preload("res://sceen/people/peoplewalkfollow.tscn")
|
|
|
|
|
|
##开始生成人的运动
|
|
func startGeneratePeople() -> void:
|
|
$AllTimer/generatePeopleTimer.start()
|
|
$AllTimer/generatePeopleTimer2.start()
|
|
$AllTimer/trainComeAndLeace.start()
|
|
|
|
|
|
var total=0
|
|
func _on_generate_people_timer_timeout() -> void:
|
|
if total< 9:
|
|
total += 1
|
|
var peoplrInstance = people_scene.instantiate()
|
|
add_child(peoplrInstance)
|
|
peoplrInstance.global_position = Vector3(-7.5,1,8)
|
|
peoplrInstance.buildPos = Vector3(-7.5,1,8)
|
|
peoplrInstance.setPathPoints([Vector3(0,0,0),Vector3(4,0,0),Vector3(9.5,0,-3),Vector3(9.5,0,-5)])
|
|
peoplrInstance.peopleBeginWalk()
|
|
else :
|
|
$AllTimer/generatePeopleTimer.stop()
|
|
|
|
var total2=0
|
|
func _on_generate_people_timer_2_timeout() -> void:
|
|
if total2< 4:
|
|
total2 += 1
|
|
if total2>3 :
|
|
$AllTimer/generatePeopleTimer2.wait_time = 10
|
|
var peoplrInstance = people_scene.instantiate()
|
|
add_child(peoplrInstance)
|
|
peoplrInstance.global_position = Vector3(0,1,12)
|
|
peoplrInstance.buildPos = Vector3(0,1,12)
|
|
playerGoToNextArea(peoplrInstance,LargePassengerFlowScene.PlayerWalkArea3D.defaultArea)
|
|
else :
|
|
$AllTimer/generatePeopleTimer2.stop()
|
|
|
|
|
|
func _on_train_come_and_leace_timeout() -> void:
|
|
self.trainComeAndOpenScreenDoor()
|
|
await get_tree().create_timer(25).timeout
|
|
self.closeScreenDoorAndTrainLeave()
|
|
|
|
|
|
|
|
func _ready():
|
|
self.currentActiveCamera = $AllCamera/PartsArea
|
|
$platform.showCameraAndShortcutTool()
|