godot-psd-training/sceen/totalOfLargePassengerFlow.gd

528 lines
22 KiB
GDScript3
Raw Normal View History

2024-06-17 14:22:23 +08:00
extends TotalScene
2024-06-18 09:03:09 +08:00
class_name LargePassengerFlowScene
2024-06-17 14:22:23 +08:00
## 照相机名字的枚举
enum Camera_name{
2024-06-18 09:03:09 +08:00
#VehicleControlRoom,#车控室
SparePartsCabinet,#备品柜
PartsArea,#备品区
2024-06-17 14:22:23 +08:00
StationHall,#站厅
UpPlatform,#上行站台
2024-06-18 09:03:09 +08:00
DownPlatform,#下行站台
2024-06-17 19:49:24 +08:00
#APassageway,#A出入口
2024-06-18 08:45:49 +08:00
StationHallAExit,#站厅A出口
AEntrance,#A入口
APassage,#A口通道
2024-06-18 09:03:09 +08:00
#BPassageway,#B出入口
2024-06-18 08:45:49 +08:00
StationHallBExit,#站厅B出口
BEntrance,#B入口
BPassage,#B口通道
2024-06-18 09:03:09 +08:00
#CPassageway,#C出入口
2024-06-18 08:45:49 +08:00
StationHallCExit,#站厅C出口
CEntrance,#C入口
2024-06-18 10:22:05 +08:00
CPassage,#C口通道
2024-06-18 09:03:09 +08:00
#DPassageway,#D出入口
2024-06-18 08:45:49 +08:00
StationHallDExit,#站厅D出口
DEntrance,#D入口
2024-06-18 10:22:05 +08:00
DPassage,#D口通道
2024-06-18 09:03:09 +08:00
#StaionHallA,#站厅A端
2024-06-18 08:45:49 +08:00
ALowerStepSwitch,#A端扶梯下部开关
ATVM,#A端TVM
AInboundGate,#A端进站闸机
AExitGate,#A端出站闸机
AUpperStep,#A端扶梯上部
ALowerStep,#A端扶梯下部
AGangway,#A端站厅步梯口
2024-06-18 09:03:09 +08:00
#StationHallB,#站厅B端
2024-06-18 08:45:49 +08:00
BLowerStepSwitch,#B端扶梯下部开关
BTVM,#B端TVM
BInboundGate,#B端进站闸机
BExitGate,#B端出站闸机
BUpperStep,#B端扶梯上部
BLowerStep,#B端扶梯下部
BGangway,#B端站厅步梯口
2024-06-17 14:22:23 +08:00
}
@onready var cameras = $AllCamera.get_children()
2024-06-17 14:22:23 +08:00
2024-07-09 17:27:43 +08:00
var currentActiveCameraOfLarge:Camera_name = Camera_name.StationHall
2024-06-17 14:22:23 +08:00
##切换相机
func switchCamera (camera :Camera_name)-> void:
currentActiveCamera = cameras[camera]
2024-07-09 17:27:43 +08:00
currentActiveCameraOfLarge = camera
2024-06-17 14:22:23 +08:00
cameras[camera].make_current()
## 人运动区域的枚举
enum PlayerWalkArea3D {
2024-07-11 17:49:28 +08:00
entrance,#入口
passage,#通道
stationHallExit,#出口
ticketingArea, #购票区
entranceGateArea, #闸机入口区
2024-07-18 18:28:32 +08:00
assignArea,#选择步梯还是电梯
2024-07-11 17:49:28 +08:00
gangwayUpArea, #站厅步梯上
gangwayDownArea,#站厅步梯下
2024-07-18 18:28:32 +08:00
elevatorUpArea, #站厅电梯上
elevatorDownArea, #站厅电梯上
screenDoorWaitArea,#屏蔽门等待区域
}
2024-07-11 17:49:28 +08:00
const areaInfo = {
'A':{
'entrance':[Vector3(-55,9.8,43)],
'passage':[Vector3(-40,5.22,43),Vector3(3,5.22,41)],
'stationHallExit':[Vector3(3,5.22,18.74)],
2024-07-11 17:49:28 +08:00
'ticketingArea':[Vector3(-11.27,5.22,18.74)],
'entranceGateArea':[Vector3(-11.27,5.22,16.75),Vector3(36,5.22,16.75),Vector3(36,5.22,14.48)],
2024-07-23 19:46:26 +08:00
'assignArea':[Vector3(36,5.22,11.11)],
'gangwayUpArea':[Vector3(36,5.22,7.45),Vector3(30,5.22,7.45)],
'gangwayDownArea': [Vector3(26.11,3.76,7.45),Vector3(24.41,3.76,7.45),Vector3(20.52,2.27,7.45),Vector3(18.37,2.27,7.45),Vector3(14.12,0.85,7.45),Vector3(11.6,0.85,7.45)],
'elevatorUpArea': [Vector3(29.5,5.22,11.11)],
'elevatorDownArea': [Vector3(15.4,0.93,11.11)],
2024-07-11 17:49:28 +08:00
},
'B':{
'entrance':[ Vector3(-54.8,9.8,-67.3),Vector3(-50,9.8,-64),Vector3(-28,9.8,-62.3)],
'passage':[Vector3(-15,5.22,-62.3),Vector3(1.92,5.22,-62.3)],
'stationHallExit':[Vector3(1.92,5.22,0)],
2024-07-11 17:49:28 +08:00
},
'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(120,9.8,-66.38)],
'passage':[Vector3(106,5.22,-66.38),Vector3(87.3,5.22,-66.38)],
'stationHallExit':[Vector3(87.3,5.22,-1.77)],
2024-07-11 17:49:28 +08:00
},
'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(120,9.8,39.55)],
'passage':[Vector3(107,5.22,39.55),Vector3(93.38,5.22,39.55)],
'stationHallExit':[Vector3(93.38,5.22,21.04)],
2024-07-11 17:49:28 +08:00
'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.29,5.22,17.29),Vector3(56.29,5.22,14.48)],
2024-07-23 19:46:26 +08:00
'gangwayUpArea':[Vector3(56,5.22,7.45),Vector3(62.15,5.22,7.45)],
'gangwayDownArea': [Vector3(66.12,3.76,7.45),Vector3(67.71,3.76,7.45),Vector3(71.5,2.27,7.45),Vector3(73.74,2.27,7.45),Vector3(77,0.85,7.45),Vector3(96.7,0.85,7.45)]
2024-07-11 17:49:28 +08:00
}
}
##区域运动(进站-连续的路径点)
func playerGoToNextArea(peopleWalkFollow:PlayerPathFollow,nextArea: PlayerWalkArea3D) -> void:
2024-07-11 17:49:28 +08:00
var targetAreaInfo = areaInfo[peopleWalkFollow.generateArea]
match nextArea:
2024-07-11 17:49:28 +08:00
PlayerWalkArea3D.entrance:
walkByPathFollow(targetAreaInfo.entrance,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-11 17:49:28 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.passage)
PlayerWalkArea3D.passage:
walkByPathFollow(targetAreaInfo.passage,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-11 17:49:28 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
PlayerWalkArea3D.stationHallExit:
walkByPathFollow(targetAreaInfo.stationHallExit,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-23 19:46:26 +08:00
await get_tree().create_timer(0.5).timeout
2024-07-18 18:28:32 +08:00
if peopleWalkFollow.generateArea == 'A' and $AllAreaDetection/TicketingLfetAreaDetection.waitPeopleCount > 8:
peopleWalkFollow.generateArea = 'D'
walkByPathFollow([Vector3(6.66,5.22,18.74),Vector3(6.66,5.22,20.25),Vector3(85.58,5.22,20.25)],peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
elif peopleWalkFollow.generateArea == 'B' || peopleWalkFollow.generateArea == 'C':
2024-07-11 17:49:28 +08:00
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.ticketingArea)
PlayerWalkArea3D.ticketingArea:
walkByPathFollow(targetAreaInfo.ticketingArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-18 18:28:32 +08:00
await get_tree().create_timer(3).timeout
2024-07-11 17:49:28 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entranceGateArea)
PlayerWalkArea3D.entranceGateArea:
2024-07-18 18:28:32 +08:00
#peopleWalkFollow.waitTimeWalkAgain = 0.5
2024-07-11 17:49:28 +08:00
walkByPathFollow(targetAreaInfo.entranceGateArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
2024-07-18 18:28:32 +08:00
if peopleWalkFollow.generateArea == 'A' :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.assignArea)
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
PlayerWalkArea3D.assignArea:
walkByPathFollow(targetAreaInfo.assignArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-22 11:18:50 +08:00
await get_tree().create_timer(0.2).timeout
2024-07-23 19:46:26 +08:00
var currentExerciseType = $platform.getElevatorCurrentExerciseType()
if currentExerciseType == Elevator.Exercise_type.reversal :
2024-07-22 11:18:50 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
2024-07-18 18:28:32 +08:00
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.elevatorUpArea)
2024-07-11 17:49:28 +08:00
PlayerWalkArea3D.gangwayUpArea:
walkByPathFollow(targetAreaInfo.gangwayUpArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-11 17:49:28 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayDownArea)
PlayerWalkArea3D.gangwayDownArea:
2024-07-22 11:18:50 +08:00
peopleWalkFollow.playerRotate(false)
await get_tree().create_timer(0.2).timeout
2024-07-11 17:49:28 +08:00
walkByPathFollow(targetAreaInfo.gangwayDownArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
2024-07-15 10:29:36 +08:00
#playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.screenDoorWaitArea)
2024-07-18 18:28:32 +08:00
PlayerWalkArea3D.elevatorUpArea:
walkByPathFollow(targetAreaInfo.elevatorUpArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-23 19:46:26 +08:00
peopleWalkFollow.speed = 0.5
2024-07-18 18:28:32 +08:00
peopleWalkFollow.playerRotate(false)
2024-07-23 19:46:26 +08:00
walkByPathFollow([Vector3(16.2,0.93,11.11)],peopleWalkFollow,Vector3(),"Idle")
2024-07-18 18:28:32 +08:00
await peopleWalkFollow.player.ArriveTargetPos
2024-07-23 19:46:26 +08:00
peopleWalkFollow.speed = 1
walkByPathFollow([Vector3(12.5,0.93,11.11)],peopleWalkFollow)
2024-07-18 18:28:32 +08:00
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.playerRotate(true)
walkByPathFollow([Vector3(12.5,0.93,14)],peopleWalkFollow)
2024-07-18 18:28:32 +08:00
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
PlayerWalkArea3D.elevatorDownArea:
walkByPathFollow(targetAreaInfo.elevatorDownArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
2024-07-23 19:46:26 +08:00
peopleWalkFollow.speed = 0.5
2024-07-18 18:28:32 +08:00
peopleWalkFollow.playerRotate(false)
2024-07-23 19:46:26 +08:00
walkByPathFollow([Vector3(29.12,5.22,11.11)],peopleWalkFollow,Vector3(),"Idle")
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.speed = 1
peopleWalkFollow.playerRotate(true)
walkByPathFollow([Vector3(33,5.22,11.11),Vector3(33,5.22,3)],peopleWalkFollow)
2024-07-18 18:28:32 +08:00
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
2024-07-15 10:29:36 +08:00
PlayerWalkArea3D.screenDoorWaitArea:
goToScreenDoorAreaAndWaitTrain(peopleWalkFollow,0)
2024-07-11 17:49:28 +08:00
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),
2024-07-18 18:28:32 +08:00
'entrance':[Vector3(-13,5.22,-66.15),Vector3(-30.1,9.8,-66.15)],
2024-07-11 17:49:28 +08:00
},
'C':{
'stationHallExit':[Vector3(82,5.22,6.75),Vector3(90,5.22,6.75)],
'passage':Vector3(90,5.22,-63.43),
2024-07-18 18:28:32 +08:00
'entrance':[Vector3(106.6,5.22,-63.43)],
},
'D':{
'stationHallExit':[Vector3(86.63,5.22,20.25)],
'passage':Vector3(86.63,5.22,42),
'entrance':[Vector3(105,5.22,42)],
2024-07-11 17:49:28 +08:00
},
}
##区域运动(出站)
2024-07-18 18:28:32 +08:00
var loopAntBEntrance = true
2024-07-11 17:49:28 +08:00
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
2024-07-22 11:18:50 +08:00
if peopleWalkFollow.generateArea == 'B' and !loopAntBEntrance :
peopleWalkFollow.queue_free()
else :
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
2024-07-11 17:49:28 +08:00
PlayerWalkArea3D.entrance:
2024-07-18 18:28:32 +08:00
walkByPathFollow(targetAreaInfo.entrance,peopleWalkFollow)
2024-07-11 17:49:28 +08:00
await peopleWalkFollow.player.ArriveTargetPos
2024-07-22 11:18:50 +08:00
if peopleWalkFollow.generateArea == 'C' or peopleWalkFollow.generateArea == 'D' :
2024-07-18 18:28:32 +08:00
peopleWalkFollow.queue_free()
2024-07-22 11:18:50 +08:00
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
2024-07-11 17:49:28 +08:00
##演示排队的区域
var screenDoorAreaInfo = [
{
"areaName": "ScreenDoorWaitArea1",
"screenDoorName": 'screenDoor1',
},
{
"areaName": "ScreenDoorWaitArea2",
"screenDoorName": 'screenDoor2',
},
{
"areaName": "ScreenDoorWaitArea3",
"screenDoorName": 'screenDoor3',
},
{
"areaName": "ScreenDoorWaitArea4",
"screenDoorName": 'screenDoor4',
},
]
##进入指定屏蔽门区域并等待上车
2024-07-23 19:46:26 +08:00
var peopleTakeTheSubway = true
func goToScreenDoorAreaAndWaitTrain(peopleWalkFollow:PlayerPathFollow, screenDoorAreaInfoIndex:int) -> void:
var screenDoorPos = $platform.get_node(screenDoorAreaInfo[screenDoorAreaInfoIndex].screenDoorName).get_node('dimiantishi').get_global_position()
2024-07-15 10:29:36 +08:00
screenDoorPos.z += 1.2
var addPoint = Vector3(screenDoorPos.x,screenDoorPos.y,screenDoorPos.z+3.2)
walkByPathFollow([addPoint,screenDoorPos],peopleWalkFollow)
2024-07-23 19:46:26 +08:00
if !peopleTakeTheSubway :
return
await self.screenDoorOpenConfirmSignal
2024-07-15 10:29:36 +08:00
var trainPoint1 = Vector3(screenDoorPos.x,screenDoorPos.y,screenDoorPos.z-3.5)
var trainPoint2 = Vector3(screenDoorPos.x+3,screenDoorPos.y,screenDoorPos.z-3.5)
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:
2024-07-15 10:29:36 +08:00
var waitPeopleCounts = [$AllScreenDoorWaitArea/ScreenDoorWaitArea1.waitPeopleCount,$AllScreenDoorWaitArea/ScreenDoorWaitArea2.waitPeopleCount,$AllScreenDoorWaitArea/ScreenDoorWaitArea3.waitPeopleCount,$AllScreenDoorWaitArea/ScreenDoorWaitArea4.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)
2024-07-15 10:29:36 +08:00
var trainLeaveAtDownPlatform = true
func _on_screen_door_wait_area_1_area_entered(area: Area3D) -> void:
2024-07-15 10:29:36 +08:00
if $AllScreenDoorWaitArea/ScreenDoorWaitArea1.waitPeopleCount>=4 and trainLeaveAtDownPlatform:
trainComeAndLeace()
##通过PathFollow运动
2024-07-18 18:28:32 +08:00
func walkByPathFollow(allTargetPos:Array,peopleWalkFollow:PlayerPathFollow,curveAngle=Vector3(),state = "Walk") -> 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)
2024-07-18 18:28:32 +08:00
peopleWalkFollow.peopleBeginWalk(state)
2024-07-09 17:27:43 +08:00
##开始生成人的运动
var people_scene = preload("res://sceen/people/peopleWalkFollow.tscn")
func startGeneratePeople() -> void:
$AllTimer/generatePeopleAEntranceTimer.start()
$AllTimer/generatePeopleBEntranceTimer.start()
2024-07-18 18:28:32 +08:00
$AllTimer/generatePeopleAtBTicketingArea.start()
2024-07-22 11:18:50 +08:00
$AllTimer/generatePeopleDownPlatformTimer.start()
$AllTimer/generatePeopleAtMiddleStepTimer.start()
$AllTimer/generatePeopleAtBInboundGateArea.start()
2024-07-18 18:28:32 +08:00
func startGeneratePeopleAtCD() -> void:
$AllTimer/generatePeopleCEntranceTimer.start()
$AllTimer/generatePeopleDEntranceTimer.start()
2024-07-18 18:28:32 +08:00
func stopGeneratePeopleAtA() -> void:
$AllTimer/generatePeopleAEntranceTimer.stop()
2024-07-23 19:46:26 +08:00
$AllTimer/generatePeopleAtBTicketingArea.stop()
$AllTimer/generatePeopleAtBInboundGateArea.stop()
2024-07-18 18:28:32 +08:00
func stopGeneratePeopleAtB() -> void:
loopAntBEntrance = false
func stopGeneratePeopleAtC() -> void:
$AllTimer/generatePeopleCEntranceTimer.stop()
func stopGeneratePeopleAtD() -> void:
$AllTimer/generatePeopleDEntranceTimer.stop()
##A入口生成
var totalOfAEntrance=0
2024-07-09 17:27:43 +08:00
func generatePeopleAtAEntrance() -> void:
if $AllAreaDetection/APassageAreaDetection.passPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.APassage:
2024-07-15 10:29:36 +08:00
generatePeopleAPassage()
2024-07-18 18:28:32 +08:00
if $AllAreaDetection/TicketingLfetAreaDetection.waitPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.BTVM:
2024-07-15 10:29:36 +08:00
generatePeopleAtBTVM()
totalOfAEntrance += 1
var peoplePosition = Vector3(-80,9.8,40.5)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'A','A{0}'.format([totalOfAEntrance]))
2024-07-15 10:29:36 +08:00
##A通道生成
var totalOfAPassage=0
func generatePeopleAPassage() -> void:
totalOfAPassage += 1
2024-07-09 17:27:43 +08:00
var peoplePosition = Vector3(3,5.22,41)
2024-07-18 18:28:32 +08:00
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.stationHallExit,'A','APassage{0}'.format([totalOfAPassage]))
2024-07-09 17:27:43 +08:00
2024-07-15 10:29:36 +08:00
##A闸机生成
var totalOfBTVM=0
func generatePeopleAtBTVM() -> void:
totalOfBTVM += 1
2024-07-18 18:28:32 +08:00
var peoplePosition = Vector3(-11.27,5.22,17.66)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entranceGateArea,'A','BTVM{0}'.format([totalOfBTVM]))
##A进站口
var totalOfBInboundGate=0
func generatePeopleAtBInboundGate() -> void:
if $AllAreaDetection/BInboundGateAreaDetection.waitPeopleCount > 20:
return
totalOfBInboundGate += 1
var peopleInstance = generatePeople(Vector3(7,5.22,18.41), str(totalOfBInboundGate))
walkByPathFollow([Vector3(15.54,5.22,18.41),Vector3(37.83,5.22,17.58),Vector3(37.83,5.22,14.48)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
walkByPathFollow([Vector3(37.83,5.22,5),Vector3(44.96,5.22,5),Vector3(44.96,5.22,6.48)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
peopleInstance.playerRotate(false)
walkByPathFollow([Vector3(44.96,3.9,9.72)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
peopleInstance.queue_free()
2024-07-09 17:27:43 +08:00
##售票厅循环排队
var totalOfBTicketingArea = 0
2024-07-09 17:27:43 +08:00
func generatePeopleAtBTicketingArea() -> void:
if $AllAreaDetection/TicketingAreaDetection.waitPeopleCount < 8:
totalOfBTicketingArea += 1
var peopleId = 'BTicketing{0}'.format([totalOfBTicketingArea])
var peopleInstance = generatePeople(Vector3(1,5.22,15.84),peopleId)
walkByPathFollow([Vector3(-11.27,5.22,15.84)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
2024-07-09 17:27:43 +08:00
await get_tree().create_timer(5).timeout
walkByPathFollow([Vector3(-11.27,5.22,14.4),Vector3(2,5.22,14.4)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
peopleInstance.queue_free()
2024-07-09 17:27:43 +08:00
2024-07-15 10:29:36 +08:00
##下行站台生成
func letPeopleWaitTrainAtDownPlatform() -> void:
2024-07-22 11:18:50 +08:00
currentNeedGenerate = 16
2024-07-15 10:29:36 +08:00
$AllTimer/generatePeopleDownPlatformTimer.start()
2024-07-22 11:18:50 +08:00
var totalOfDownPlatform = 0
var currentNeedGenerate = 4
2024-07-23 19:46:26 +08:00
var allGeneratePeopleAtDownPlatform :Array[PlayerPathFollow] = []
2024-07-15 10:29:36 +08:00
func generatePeopleAtDownPlatform() -> void:
2024-07-22 11:18:50 +08:00
if totalOfDownPlatform < currentNeedGenerate :
totalOfDownPlatform += 1
2024-07-18 18:28:32 +08:00
var peoplePosition = Vector3(6.12,0.85,7.62)
2024-07-23 19:46:26 +08:00
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.screenDoorWaitArea,'A','DownPlatform{0}'.format([totalOfDownPlatform]))
2024-07-15 10:29:36 +08:00
else :
$AllTimer/generatePeopleDownPlatformTimer.stop()
2024-07-23 19:46:26 +08:00
##下行站台电梯口B端
func letPeopleGotoElevatorDown() -> void:
$AllTimer/generatePeopleAtBLowerStepTimer.start()
var totalOfBLowerStep = 0
func generatePeopleAtBLowerStep() -> void:
totalOfBLowerStep += 1
var peoplePosition = Vector3(10.66,0.93,11.11)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.elevatorDownArea,'A','A{0}'.format([totalOfBLowerStep]))
2024-07-11 17:49:28 +08:00
##B入口生成(从进到出3分钟间隔10秒18个人完成循环)
var totalOfBEntrance=18
func generatePeopleAtBEntrance() -> void:
if totalOfBEntrance> 0:
totalOfBEntrance -= 1
var peoplePosition = Vector3(-54.8,9.8,-61)
2024-07-22 11:18:50 +08:00
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'B','B{0}'.format([totalOfBEntrance]))
2024-07-11 17:49:28 +08:00
else :
$AllTimer/generatePeopleBEntranceTimer.stop()
2024-07-18 18:28:32 +08:00
##C入口生成(21个人完成循环)
var totalOfCEntrance = 21
2024-07-11 17:49:28 +08:00
func generatePeopleAtCEntrance() -> void:
2024-07-18 18:28:32 +08:00
totalOfCEntrance += 1
var peoplePosition = Vector3(146.12,9.8,-60)
2024-07-22 11:18:50 +08:00
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'C','C{0}'.format([totalOfCEntrance]))
2024-07-11 17:49:28 +08:00
##D入口生成
var totalOfDEntrance = 0
2024-07-11 17:49:28 +08:00
func generatePeopleAtDEntrance() -> void:
totalOfDEntrance += 1
if totalOfDEntrance > 10:
2024-07-18 18:28:32 +08:00
$AllTimer/generatePeopleDEntranceTimer.wait_time = 6
var peoplePosition = Vector3(146.12,9.8,46)
2024-07-22 11:18:50 +08:00
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'D','D{0}'.format([totalOfDEntrance]))
2024-07-11 17:49:28 +08:00
##中间步梯生成BC口出
var totalOfMiddleStep = 0
func generatePeopleAtMiddleStep() -> void:
totalOfMiddleStep += 1
var peopleInstance = generatePeople(Vector3(47,3.3,9.72), str(totalOfMiddleStep))
peopleInstance.playerRotate(false)
walkByPathFollow([Vector3(47,5.22,6.48)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
peopleInstance.playerRotate(true)
if int(peopleInstance.id) % 4 == 0 :
walkByPathFollow([Vector3(47,5.22,0.2),Vector3(18.60,5.22,0.2)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
walkByPathFollow([Vector3(8.34,5.22,0.2),Vector3(8.34,5.22,9.61)],peopleInstance)
elif int(peopleInstance.id) % 4 == 1 :
walkByPathFollow([Vector3(47,5.22,3.79),Vector3(18.60,5.22,3.79)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
walkByPathFollow([Vector3(8.34,5.22,3.79),Vector3(8.34,5.22,9.61)],peopleInstance)
elif int(peopleInstance.id) % 4 == 2 :
walkByPathFollow([Vector3(47,5.22,3.6),Vector3(73.13,5.22,3.6)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
walkByPathFollow([Vector3(81.56,5.22,3.6),Vector3(81.56,5.22,9)],peopleInstance)
else :
walkByPathFollow([Vector3(47,5.22,0.1),Vector3(73.13,5.22,0.1)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
walkByPathFollow([Vector3(81.56,5.22,0.1),Vector3(81.56,5.22,9)],peopleInstance)
await peopleInstance.player.ArriveTargetPos
peopleInstance.queue_free()
2024-07-09 17:27:43 +08:00
##在指定区域增加人
func generatePeopleAtDesignatedArea(peoplePosition:Vector3, goToNextArea: PlayerWalkArea3D,generateArea:String, peopleId:String='A0') -> void:
var peopleInstance = generatePeople(peoplePosition,peopleId)
peopleInstance.generateArea = generateArea
2024-07-23 19:46:26 +08:00
if 'DownPlatform' in peopleId :
allGeneratePeopleAtDownPlatform.append(peopleInstance)
peopleInstance.connect("peopleInDesignatedAreaChangeMoveSignal",Callable(self,"peopleInDesignatedAreaChangeMove"))
playerGoToNextArea(peopleInstance,goToNextArea)
##生成人不指定去哪
func generatePeople(peoplePosition:Vector3,peopleId:String='A0')-> PlayerPathFollow:
var peopleInstance = people_scene.instantiate()
add_child(peopleInstance)
peopleInstance.global_position = peoplePosition
peopleInstance.buildPos = peoplePosition
peopleInstance.id = peopleId
return peopleInstance
2024-07-23 19:46:26 +08:00
func peopleInDesignatedAreaChangeMove(areaName:String,peopleWalkFollow:PlayerPathFollow) -> void:
if areaName == 'hoardingAtEscalatorUp' :
walkByPathFollow([Vector3(33.5,5.22,7.45),Vector3(30,5.22,7.45)],peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayDownArea)
elif areaName == 'hoardingAtEscalatorDown' :
$AllTimer/generatePeopleAtBLowerStepTimer.stop()
walkByPathFollow([Vector3(12.36,0.93,8.11)],peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
2024-07-11 17:49:28 +08:00
signal trainComingSignal()
func trainComeAndLeace() -> void:
2024-07-15 10:29:36 +08:00
trainLeaveAtDownPlatform = false
2024-07-11 17:49:28 +08:00
trainComingSignal.emit()
self.trainComeAndOpenScreenDoor()
2024-07-23 19:46:26 +08:00
await get_tree().create_timer(20).timeout
self.closeScreenDoorAndTrainLeave()
2024-07-23 19:46:26 +08:00
peopleTakeTheSubway = false
currentNeedGenerate = 32
$AllTimer/generatePeopleDownPlatformTimer.start()
2024-07-18 18:28:32 +08:00
func peopleAtDownPlatformDecreased() -> void:
$AllScreenDoorWaitArea.queue_free()
2024-07-23 19:46:26 +08:00
var allPeopleAtDownPlatform = $"AllDecoration /AllPeopleAtDownPlatform".get_children()
2024-07-18 18:28:32 +08:00
for child in allPeopleAtDownPlatform :
child.position.y = 0.85
2024-07-22 11:18:50 +08:00
child.get_node('Player').state_machine.change_state("Idle")
2024-07-23 19:46:26 +08:00
allGeneratePeopleAtDownPlatform = allGeneratePeopleAtDownPlatform.slice(16, allGeneratePeopleAtDownPlatform.size())
for child in allGeneratePeopleAtDownPlatform :
child.queue_free()
2024-07-18 18:28:32 +08:00
2024-07-09 17:27:43 +08:00
func temporaryTicketOfficeComing() -> void:
$platform.get_node('TemporaryTicketOffice').temporaryTicketOfficeComing()
2024-07-11 17:49:28 +08:00
func allTimerStopAndShowRedStripe() -> void:
$platform.get_node('ShortcutToolModel2').allTimerStopAndShowRedStripe()
func _ready():
$platform.showCameraAndShortcutTool()
2024-07-15 10:29:36 +08:00
$platform.screenDoorOpenAndCloseNoMusic()