339 lines
13 KiB
GDScript
339 lines
13 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.get_children()
|
||
|
||
var currentActiveCameraOfLarge:Camera_name = Camera_name.StationHall
|
||
##切换相机
|
||
func switchCamera (camera :Camera_name)-> void:
|
||
currentActiveCamera = cameras[camera]
|
||
currentActiveCameraOfLarge = camera
|
||
cameras[camera].make_current()
|
||
|
||
## 人运动区域的枚举
|
||
enum PlayerWalkArea3D {
|
||
entrance,#入口
|
||
passage,#通道
|
||
stationHallExit,#出口
|
||
ticketingArea, #购票区
|
||
entranceGateArea, #闸机入口区
|
||
gangwayUpArea, #站厅步梯上
|
||
gangwayDownArea,#站厅步梯下
|
||
screenDoorWaitArea,#屏蔽门等待区域
|
||
}
|
||
|
||
const areaInfo = {
|
||
'A':{
|
||
'entrance':[Vector3(-60,9.8,43)],
|
||
'passage':Vector3(3,5.22,41),
|
||
'stationHallExit':Vector3(3,5.22,18.74),
|
||
'ticketingArea':[Vector3(-11.27,5.22,18.74)],
|
||
'entranceGateArea':[Vector3(-11.27,5.22,17.25),Vector3(36,5.22,17.25),Vector3(36,5.22,14)],
|
||
'gangwayUpArea':[Vector3(36,5.22,7.45),Vector3(31,5.22,7.45)],
|
||
'gangwayDownArea': [Vector3(14.12,0.85,7.45)]
|
||
},
|
||
'B':{
|
||
'entrance':[ Vector3(-54.8,9.8,-67.3),Vector3(-50,9.8,-64),Vector3(-30.1,9.8,-62.3)],
|
||
'passage':Vector3(1.92,5.22,-62.3),
|
||
'stationHallExit':Vector3(1.92,5.22,0),
|
||
},
|
||
'C':{'entrance':[Vector3(144.12,9.8,-60),Vector3(144.12,9.8,-68.7),Vector3(142,9.8,-68.7),Vector3(142,9.8,-60),Vector3(140,9.8,-60),Vector3(140,9.8,-67),Vector3(122.46,9.8,-66.38)],
|
||
'passage':Vector3(87.3,5.22,-66.38),
|
||
'stationHallExit':Vector3(87.3,5.22,-1.77),
|
||
},
|
||
'D':{'entrance':[Vector3(144.12,9.8,46),Vector3(144.12,9.8,36.58),Vector3(142,9.8,36.58),Vector3(142,9.8,46),Vector3(140,9.8,46),Vector3(140,9.8,38.28),Vector3(122.46,9.8,39.55)],
|
||
'passage':Vector3(93.38,5.22,39.55),
|
||
'stationHallExit':Vector3(93.38,5.22,21.04),
|
||
'ticketingArea':[Vector3(99,5.22,14.25),Vector3(99,5.22,7.86),Vector3(109.26,5.22,7.86)],
|
||
'entranceGateArea':[Vector3(109.26,5.22,6.86),Vector3(92,5.22,6.86),Vector3(92,5.22,12.98),Vector3(78.33,5.22,17.29),Vector3(56,5.22,17.29),Vector3(56,5.22,14)],
|
||
'gangwayUpArea':[Vector3(56,5.22,7.45),Vector3(61.46,5.22,7.45)],
|
||
'gangwayDownArea': [Vector3(77,0.85,7.45)]
|
||
}
|
||
}
|
||
|
||
##区域运动(进站-连续的路径点)
|
||
func playerGoToNextArea(peopleWalkFollow:PlayerPathFollow,nextArea: PlayerWalkArea3D) -> void:
|
||
var targetAreaInfo = areaInfo[peopleWalkFollow.generateArea]
|
||
match nextArea:
|
||
PlayerWalkArea3D.entrance:
|
||
walkByPathFollow(targetAreaInfo.entrance,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.passage)
|
||
PlayerWalkArea3D.passage:
|
||
peopleWalkFollow.player.setTargetPos(targetAreaInfo.passage,0.1)
|
||
peopleWalkFollow.player.goToTarget()
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
|
||
PlayerWalkArea3D.stationHallExit:
|
||
peopleWalkFollow.player.setTargetPos(targetAreaInfo.stationHallExit,0.1)
|
||
peopleWalkFollow.player.goToTarget()
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
await get_tree().create_timer(1).timeout
|
||
if peopleWalkFollow.generateArea == 'B' || peopleWalkFollow.generateArea == 'C':
|
||
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
|
||
else :
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.ticketingArea)
|
||
PlayerWalkArea3D.ticketingArea:
|
||
walkByPathFollow(targetAreaInfo.ticketingArea,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
await get_tree().create_timer(5).timeout
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entranceGateArea)
|
||
PlayerWalkArea3D.entranceGateArea:
|
||
walkByPathFollow(targetAreaInfo.entranceGateArea,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
await get_tree().create_timer(0.2).timeout
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
|
||
PlayerWalkArea3D.gangwayUpArea:
|
||
walkByPathFollow(targetAreaInfo.gangwayUpArea,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayDownArea)
|
||
PlayerWalkArea3D.gangwayDownArea:
|
||
walkByPathFollow(targetAreaInfo.gangwayDownArea,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.screenDoorWaitArea)
|
||
#PlayerWalkArea3D.screenDoorWaitArea:
|
||
#goToScreenDoorAreaAndWaitTrain(peopleWalkFollow,0)
|
||
|
||
const areaBackInfo = {
|
||
'B':{
|
||
'stationHallExit':[Vector3(1.92,5.22,3.5),Vector3(5.3,5.22,3.5)],
|
||
'passage':Vector3(5.3,5.22,-66.15),
|
||
'entrance':Vector3(-13,5.22,-66.15),
|
||
},
|
||
'C':{
|
||
'stationHallExit':[Vector3(82,5.22,6.75),Vector3(90,5.22,6.75)],
|
||
'passage':Vector3(90,5.22,-63.43),
|
||
'entrance':Vector3(106.6,5.22,-63.43),
|
||
},
|
||
}
|
||
|
||
##区域运动(出站)
|
||
func playerBackGoToNextArea(peopleWalkFollow:PlayerPathFollow,nextArea: PlayerWalkArea3D) -> void:
|
||
var targetAreaInfo = areaBackInfo[peopleWalkFollow.generateArea]
|
||
match nextArea:
|
||
PlayerWalkArea3D.stationHallExit:
|
||
walkByPathFollow(targetAreaInfo.stationHallExit,peopleWalkFollow)
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.passage)
|
||
PlayerWalkArea3D.passage:
|
||
peopleWalkFollow.player.setTargetPos(targetAreaInfo.passage,0.1)
|
||
peopleWalkFollow.player.goToTarget()
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
|
||
PlayerWalkArea3D.entrance:
|
||
peopleWalkFollow.player.setTargetPos(targetAreaInfo.entrance,0.1)
|
||
peopleWalkFollow.player.goToTarget()
|
||
await peopleWalkFollow.player.ArriveTargetPos
|
||
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
|
||
|
||
|
||
##演示排队的区域
|
||
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 addPoint = Vector3(screenDoorPos.x,screenDoorPos.y,screenDoorPos.z+2)
|
||
walkByPathFollow([addPoint,screenDoorPos],peopleWalkFollow)
|
||
await self.screenDoorOpenConfirmSignal
|
||
var trainPoint1 = Vector3(screenDoorPos.x,screenDoorPos.y,screenDoorPos.z-3)
|
||
var trainPoint2 = Vector3(screenDoorPos.x+3,screenDoorPos.y,screenDoorPos.z-3)
|
||
walkByPathFollow([trainPoint1,trainPoint2],peopleWalkFollow)
|
||
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)
|
||
|
||
func _on_screen_door_wait_area_1_area_entered(area: Area3D) -> void:
|
||
if $AllScreenDoorWaitArea/ScreenDoorWaitArea1.waitPeopleCount>=4 :
|
||
trainComeAndLeace()
|
||
|
||
##通过PathFollow运动
|
||
func walkByPathFollow(allTargetPos:Array,peopleWalkFollow:PlayerPathFollow,curveAngle=Vector3()) -> void:
|
||
var walkPoints = [peopleWalkFollow.player.position]
|
||
for child in allTargetPos:
|
||
var xOffset = child.x - peopleWalkFollow.buildPos.x
|
||
var yOffset = child.y - peopleWalkFollow.buildPos.y
|
||
var zOffset = child.z - peopleWalkFollow.buildPos.z
|
||
walkPoints.append(Vector3(xOffset,yOffset,zOffset))
|
||
peopleWalkFollow.setPathPoints(walkPoints,curveAngle)
|
||
peopleWalkFollow.peopleBeginWalk()
|
||
|
||
|
||
##开始生成人的运动
|
||
var people_scene = preload("res://sceen/people/peoplewalkfollow.tscn")
|
||
func startGeneratePeople() -> void:
|
||
$AllTimer/generatePeopleAEntranceTimer.start()
|
||
|
||
|
||
##A入口生成
|
||
var totalOfAEntrance=0
|
||
func generatePeopleAtAEntrance() -> void:
|
||
if $AllAreaDetection/StationHallAExitAreaDetection.passPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.APassage:
|
||
generatePeopleAtStationHallAExit()
|
||
if totalOfAEntrance< 15:
|
||
totalOfAEntrance += 1
|
||
#$AllTimer/generatePeopleAEntranceTimer.wait_time = 10000
|
||
var peoplePosition = Vector3(-80,9.8,40.5)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'A',totalOfAEntrance)
|
||
else :
|
||
$AllTimer/generatePeopleAEntranceTimer.stop()
|
||
|
||
##A出口生成
|
||
var totalOfStationHallAExit=0
|
||
func generatePeopleAtStationHallAExit() -> void:
|
||
totalOfStationHallAExit += 1
|
||
var peoplePosition = Vector3(3,5.22,41)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.stationHallExit,'A')
|
||
|
||
##售票厅循环排队
|
||
var totalOfBTicketingArea=0
|
||
func generatePeopleAtBTicketingArea() -> void:
|
||
if $AllAreaDetection/TicketingAreaDetection.waitPeopleCount <7:
|
||
var peoplrInstance = people_scene.instantiate()
|
||
add_child(peoplrInstance)
|
||
peoplrInstance.global_position = Vector3(1,5.22,15.84)
|
||
peoplrInstance.buildPos = Vector3(1,5.22,15.84)
|
||
walkByPathFollow([Vector3(-11.27,5.22,15.84)],peoplrInstance)
|
||
await peoplrInstance.player.ArriveTargetPos
|
||
await get_tree().create_timer(5).timeout
|
||
walkByPathFollow([Vector3(-11.27,5.22,14.4),Vector3(2,5.22,14.4)],peoplrInstance)
|
||
await peoplrInstance.player.ArriveTargetPos
|
||
peoplrInstance.queue_free()
|
||
|
||
##B入口生成(从进到出3分钟,间隔10秒,18个人完成循环)
|
||
var totalOfBEntrance=18
|
||
func generatePeopleAtBEntrance() -> void:
|
||
if totalOfBEntrance> 0:
|
||
totalOfBEntrance -= 1
|
||
var peoplePosition = Vector3(-54.8,9.8,-61)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'B',totalOfAEntrance)
|
||
else :
|
||
$AllTimer/generatePeopleBEntranceTimer.stop()
|
||
|
||
##C入口生成
|
||
var totalOfCEntrance=21
|
||
func generatePeopleAtCEntrance() -> void:
|
||
if totalOfCEntrance> 0:
|
||
totalOfCEntrance -= 1
|
||
var peoplePosition = Vector3(146.12,9.8,-60)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'C',totalOfAEntrance)
|
||
else :
|
||
$AllTimer/generatePeopleCEntranceTimer.stop()
|
||
|
||
##D入口生成
|
||
var totalOfDEntrance=15
|
||
func generatePeopleAtDEntrance() -> void:
|
||
if totalOfDEntrance > 0:
|
||
totalOfDEntrance -= 1
|
||
var peoplePosition = Vector3(146.12,9.8,46)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'D',totalOfAEntrance)
|
||
else :
|
||
$AllTimer/generatePeopleDEntranceTimer.stop()
|
||
|
||
|
||
##下行站台生成
|
||
var totalOfDownPlatform=0
|
||
func generatePeopleAtDownPlatform() -> void:
|
||
if totalOfDownPlatform< 9:
|
||
totalOfDownPlatform += 1
|
||
var peoplePosition = Vector3(13.54,0.85,11.2)
|
||
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.screenDoorWaitArea,'A')
|
||
else :
|
||
$AllTimer/generatePeopleDownPlatformTimer.stop()
|
||
|
||
##在指定区域增加人
|
||
func generatePeopleAtDesignatedArea(peoplePosition:Vector3, goToNextArea: PlayerWalkArea3D,generateArea:String, peopleId:int=0) -> void:
|
||
var peoplrInstance = people_scene.instantiate()
|
||
add_child(peoplrInstance)
|
||
peoplrInstance.global_position = peoplePosition
|
||
peoplrInstance.buildPos = peoplePosition
|
||
peoplrInstance.generateArea = generateArea
|
||
if peopleId :
|
||
peoplrInstance.id = peopleId
|
||
playerGoToNextArea(peoplrInstance,goToNextArea)
|
||
|
||
|
||
signal trainComingSignal()
|
||
func trainComeAndLeace() -> void:
|
||
trainComingSignal.emit()
|
||
self.trainComeAndOpenScreenDoor()
|
||
await get_tree().create_timer(25).timeout
|
||
self.closeScreenDoorAndTrainLeave()
|
||
|
||
func temporaryTicketOfficeComing() -> void:
|
||
$platform.get_node('TemporaryTicketOffice').temporaryTicketOfficeComing()
|
||
|
||
func allTimerStopAndShowRedStripe() -> void:
|
||
$platform.get_node('ShortcutToolModel2').allTimerStopAndShowRedStripe()
|
||
|
||
func _ready():
|
||
$platform.showCameraAndShortcutTool()
|