godot-psd-training/sceen/totalOfLargePassengerFlow.gd

528 lines
22 KiB
GDScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, #闸机入口区
assignArea,#选择步梯还是电梯
gangwayUpArea, #站厅步梯上
gangwayDownArea,#站厅步梯下
elevatorUpArea, #站厅电梯上
elevatorDownArea, #站厅电梯上
screenDoorWaitArea,#屏蔽门等待区域
}
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)],
'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)],
'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)],
},
'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)],
},
'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)],
},
'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)],
'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)],
'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)]
}
}
##区域运动(进站-连续的路径点)
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:
walkByPathFollow(targetAreaInfo.passage,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
PlayerWalkArea3D.stationHallExit:
walkByPathFollow(targetAreaInfo.stationHallExit,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
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':
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.stationHallExit)
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.ticketingArea)
PlayerWalkArea3D.ticketingArea:
walkByPathFollow(targetAreaInfo.ticketingArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(3).timeout
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entranceGateArea)
PlayerWalkArea3D.entranceGateArea:
#peopleWalkFollow.waitTimeWalkAgain = 0.5
walkByPathFollow(targetAreaInfo.entranceGateArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(0.5).timeout
if peopleWalkFollow.generateArea == 'A' :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.assignArea)
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
PlayerWalkArea3D.assignArea:
walkByPathFollow(targetAreaInfo.assignArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
await get_tree().create_timer(0.2).timeout
var currentExerciseType = $platform.getElevatorCurrentExerciseType()
if currentExerciseType == Elevator.Exercise_type.reversal :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayUpArea)
else :
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.elevatorUpArea)
PlayerWalkArea3D.gangwayUpArea:
walkByPathFollow(targetAreaInfo.gangwayUpArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.gangwayDownArea)
PlayerWalkArea3D.gangwayDownArea:
peopleWalkFollow.playerRotate(false)
await get_tree().create_timer(0.2).timeout
walkByPathFollow(targetAreaInfo.gangwayDownArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
#playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.screenDoorWaitArea)
PlayerWalkArea3D.elevatorUpArea:
walkByPathFollow(targetAreaInfo.elevatorUpArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.speed = 0.5
peopleWalkFollow.playerRotate(false)
walkByPathFollow([Vector3(16.2,0.93,11.11)],peopleWalkFollow,Vector3(),"Idle")
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.speed = 1
walkByPathFollow([Vector3(12.5,0.93,11.11)],peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.playerRotate(true)
walkByPathFollow([Vector3(12.5,0.93,14)],peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
PlayerWalkArea3D.elevatorDownArea:
walkByPathFollow(targetAreaInfo.elevatorDownArea,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.speed = 0.5
peopleWalkFollow.playerRotate(false)
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)
await peopleWalkFollow.player.ArriveTargetPos
peopleWalkFollow.queue_free()
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),Vector3(-30.1,9.8,-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)],
},
'D':{
'stationHallExit':[Vector3(86.63,5.22,20.25)],
'passage':Vector3(86.63,5.22,42),
'entrance':[Vector3(105,5.22,42)],
},
}
##区域运动(出站)
var loopAntBEntrance = true
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
if peopleWalkFollow.generateArea == 'B' and !loopAntBEntrance :
peopleWalkFollow.queue_free()
else :
playerBackGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
PlayerWalkArea3D.entrance:
walkByPathFollow(targetAreaInfo.entrance,peopleWalkFollow)
await peopleWalkFollow.player.ArriveTargetPos
if peopleWalkFollow.generateArea == 'C' or peopleWalkFollow.generateArea == 'D' :
peopleWalkFollow.queue_free()
playerGoToNextArea(peopleWalkFollow,PlayerWalkArea3D.entrance)
##演示排队的区域
var screenDoorAreaInfo = [
{
"areaName": "ScreenDoorWaitArea1",
"screenDoorName": 'screenDoor1',
},
{
"areaName": "ScreenDoorWaitArea2",
"screenDoorName": 'screenDoor2',
},
{
"areaName": "ScreenDoorWaitArea3",
"screenDoorName": 'screenDoor3',
},
{
"areaName": "ScreenDoorWaitArea4",
"screenDoorName": 'screenDoor4',
},
]
##进入指定屏蔽门区域并等待上车
var peopleTakeTheSubway = true
func goToScreenDoorAreaAndWaitTrain(peopleWalkFollow:PlayerPathFollow, screenDoorAreaInfoIndex:int) -> void:
var screenDoorPos = $platform.get_node(screenDoorAreaInfo[screenDoorAreaInfoIndex].screenDoorName).get_node('dimiantishi').get_global_position()
screenDoorPos.z += 1.2
var addPoint = Vector3(screenDoorPos.x,screenDoorPos.y,screenDoorPos.z+3.2)
walkByPathFollow([addPoint,screenDoorPos],peopleWalkFollow)
if !peopleTakeTheSubway :
return
await self.screenDoorOpenConfirmSignal
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:
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)
var trainLeaveAtDownPlatform = true
func _on_screen_door_wait_area_1_area_entered(area: Area3D) -> void:
if $AllScreenDoorWaitArea/ScreenDoorWaitArea1.waitPeopleCount>=4 and trainLeaveAtDownPlatform:
trainComeAndLeace()
##通过PathFollow运动
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)
peopleWalkFollow.peopleBeginWalk(state)
##开始生成人的运动
var people_scene = preload("res://sceen/people/peopleWalkFollow.tscn")
func startGeneratePeople() -> void:
$AllTimer/generatePeopleAEntranceTimer.start()
$AllTimer/generatePeopleBEntranceTimer.start()
$AllTimer/generatePeopleAtBTicketingArea.start()
$AllTimer/generatePeopleDownPlatformTimer.start()
$AllTimer/generatePeopleAtMiddleStepTimer.start()
$AllTimer/generatePeopleAtBInboundGateArea.start()
func startGeneratePeopleAtCD() -> void:
$AllTimer/generatePeopleCEntranceTimer.start()
$AllTimer/generatePeopleDEntranceTimer.start()
func stopGeneratePeopleAtA() -> void:
$AllTimer/generatePeopleAEntranceTimer.stop()
$AllTimer/generatePeopleAtBTicketingArea.stop()
$AllTimer/generatePeopleAtBInboundGateArea.stop()
func stopGeneratePeopleAtB() -> void:
loopAntBEntrance = false
func stopGeneratePeopleAtC() -> void:
$AllTimer/generatePeopleCEntranceTimer.stop()
func stopGeneratePeopleAtD() -> void:
$AllTimer/generatePeopleDEntranceTimer.stop()
##A入口生成
var totalOfAEntrance=0
func generatePeopleAtAEntrance() -> void:
if $AllAreaDetection/APassageAreaDetection.passPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.APassage:
generatePeopleAPassage()
if $AllAreaDetection/TicketingLfetAreaDetection.waitPeopleCount< 1 and currentActiveCameraOfLarge != Camera_name.BTVM:
generatePeopleAtBTVM()
totalOfAEntrance += 1
var peoplePosition = Vector3(-80,9.8,40.5)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'A','A{0}'.format([totalOfAEntrance]))
##A通道生成
var totalOfAPassage=0
func generatePeopleAPassage() -> void:
totalOfAPassage += 1
var peoplePosition = Vector3(3,5.22,41)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.stationHallExit,'A','APassage{0}'.format([totalOfAPassage]))
##A闸机生成
var totalOfBTVM=0
func generatePeopleAtBTVM() -> void:
totalOfBTVM += 1
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()
##售票厅循环排队
var totalOfBTicketingArea = 0
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
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()
##下行站台生成
func letPeopleWaitTrainAtDownPlatform() -> void:
currentNeedGenerate = 16
$AllTimer/generatePeopleDownPlatformTimer.start()
var totalOfDownPlatform = 0
var currentNeedGenerate = 4
var allGeneratePeopleAtDownPlatform :Array[PlayerPathFollow] = []
func generatePeopleAtDownPlatform() -> void:
if totalOfDownPlatform < currentNeedGenerate :
totalOfDownPlatform += 1
var peoplePosition = Vector3(6.12,0.85,7.62)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.screenDoorWaitArea,'A','DownPlatform{0}'.format([totalOfDownPlatform]))
else :
$AllTimer/generatePeopleDownPlatformTimer.stop()
##下行站台电梯口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]))
##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','B{0}'.format([totalOfBEntrance]))
else :
$AllTimer/generatePeopleBEntranceTimer.stop()
##C入口生成(21个人完成循环)
var totalOfCEntrance = 21
func generatePeopleAtCEntrance() -> void:
totalOfCEntrance += 1
var peoplePosition = Vector3(146.12,9.8,-60)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'C','C{0}'.format([totalOfCEntrance]))
##D入口生成
var totalOfDEntrance = 0
func generatePeopleAtDEntrance() -> void:
totalOfDEntrance += 1
if totalOfDEntrance > 10:
$AllTimer/generatePeopleDEntranceTimer.wait_time = 6
var peoplePosition = Vector3(146.12,9.8,46)
generatePeopleAtDesignatedArea(peoplePosition,PlayerWalkArea3D.entrance,'D','D{0}'.format([totalOfDEntrance]))
##中间步梯生成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()
##在指定区域增加人
func generatePeopleAtDesignatedArea(peoplePosition:Vector3, goToNextArea: PlayerWalkArea3D,generateArea:String, peopleId:String='A0') -> void:
var peopleInstance = generatePeople(peoplePosition,peopleId)
peopleInstance.generateArea = generateArea
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
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()
signal trainComingSignal()
func trainComeAndLeace() -> void:
trainLeaveAtDownPlatform = false
trainComingSignal.emit()
self.trainComeAndOpenScreenDoor()
await get_tree().create_timer(20).timeout
self.closeScreenDoorAndTrainLeave()
peopleTakeTheSubway = false
currentNeedGenerate = 32
$AllTimer/generatePeopleDownPlatformTimer.start()
func peopleAtDownPlatformDecreased() -> void:
$AllScreenDoorWaitArea.queue_free()
var allPeopleAtDownPlatform = $"AllDecoration /AllPeopleAtDownPlatform".get_children()
for child in allPeopleAtDownPlatform :
child.position.y = 0.85
child.get_node('Player').state_machine.change_state("Idle")
allGeneratePeopleAtDownPlatform = allGeneratePeopleAtDownPlatform.slice(16, allGeneratePeopleAtDownPlatform.size())
for child in allGeneratePeopleAtDownPlatform :
child.queue_free()
func temporaryTicketOfficeComing() -> void:
$platform.get_node('TemporaryTicketOffice').temporaryTicketOfficeComing()
func allTimerStopAndShowRedStripe() -> void:
$platform.get_node('ShortcutToolModel2').allTimerStopAndShowRedStripe()
func _ready():
$platform.showCameraAndShortcutTool()
$platform.screenDoorOpenAndCloseNoMusic()