大客流total提供人的生成和运动(待完善)

This commit is contained in:
joylink_zhaoerwei 2024-06-20 13:36:15 +08:00
parent 3cceffb4f8
commit c18d06aac4
3 changed files with 157 additions and 3 deletions

View File

@ -3,14 +3,14 @@
[ext_resource type="Script" path="res://sceen/Area3D/ScreenDoorWaitArea.gd" id="1_4a0gs"]
[sub_resource type="BoxShape3D" id="BoxShape3D_np60e"]
size = Vector3(1.6, 0.095, 10)
size = Vector3(1.6, 0.095, 7)
[node name="ScreenDoorWaitArea" type="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 5.93628)
script = ExtResource("1_4a0gs")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.187478)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.609196)
shape = SubResource("BoxShape3D_np60e")
[connection signal="area_entered" from="." to="." method="_on_area_entered"]

View File

@ -49,3 +49,129 @@ enum Camera_name{
##切换相机
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()

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=11 format=3 uid="uid://dmlksr5k23wwk"]
[gd_scene load_steps=12 format=3 uid="uid://dmlksr5k23wwk"]
[ext_resource type="Script" path="res://sceen/totalOfLargePassengerFlow.gd" id="1_5iiv2"]
[ext_resource type="PackedScene" uid="uid://cmnsn2joxo68l" path="res://sceen/platform/platform.tscn" id="1_rjva4"]
[ext_resource type="AudioStream" uid="uid://dgqmfnjgrea07" path="res://Assets/training_speech/trainComing.mp3" id="4_6ctdm"]
[ext_resource type="PackedScene" uid="uid://bo4j7dptpf7ne" path="res://UI/CameraSwitch/CameraSwitchUi.tscn" id="5_efwd0"]
[ext_resource type="PackedScene" uid="uid://bylj0hfttmmqf" path="res://sceen/Area3D/ScreenDoorWaitArea.tscn" id="6_1spme"]
[ext_resource type="PackedScene" uid="uid://nx6xnwcuq8cf" path="res://sceen/train/train.tscn" id="14_g0uwl"]
[sub_resource type="Environment" id="Environment_ux83q"]
@ -109,6 +110,16 @@ one_shot = true
[node name="openAllwindow" type="Timer" parent="AllTimer"]
one_shot = true
[node name="generatePeopleTimer" type="Timer" parent="AllTimer"]
wait_time = 2.0
[node name="generatePeopleTimer2" type="Timer" parent="AllTimer"]
wait_time = 2.0
[node name="trainComeAndLeace" type="Timer" parent="AllTimer"]
wait_time = 35.0
autostart = true
[node name="CameraSwitchUi" parent="." instance=ExtResource("5_efwd0")]
[node name="AllCamera" type="Node3D" parent="."]
@ -123,6 +134,17 @@ current = true
[node name="StationHall" type="Camera3D" parent="AllCamera"]
transform = Transform3D(0.549621, 0, -0.835414, 0, 1, 0, 0.835414, 0, 0.549621, 2.03598, 1.21341, 6.60578)
[node name="AllScreenDoorWaitArea" type="Node3D" parent="."]
[node name="ScreenDoorWaitArea1" parent="AllScreenDoorWaitArea" instance=ExtResource("6_1spme")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.40432, 1.1, 6.5)
[node name="ScreenDoorWaitArea2" parent="AllScreenDoorWaitArea" instance=ExtResource("6_1spme")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.15874, 1.1, 6.5)
[node name="ScreenDoorWaitArea3" parent="AllScreenDoorWaitArea" instance=ExtResource("6_1spme")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.00535, 1.1, 6.5)
[connection signal="allClickPlatformSignal" from="platform" to="." method="_on_platform_all_click_platform_signal"]
[connection signal="allScreenDoorLcbStateSignal" from="platform" to="." method="emitScreenDoorLcbStateChangeSignal"]
[connection signal="animation_finished" from="trainAnimationPlayer" to="train" method="_on_train_animation_player_animation_finished"]
@ -131,3 +153,9 @@ transform = Transform3D(0.549621, 0, -0.835414, 0, 1, 0, 0.835414, 0, 0.549621,
[connection signal="timeout" from="AllTimer/trainComeDelay" to="." method="_on_train_come_delay_timeout"]
[connection signal="timeout" from="AllTimer/trainLeaveDelay" to="." method="_on_train_leave_delay_timeout"]
[connection signal="timeout" from="AllTimer/openAllwindow" to="." method="_on_open_allwindow_timeout"]
[connection signal="timeout" from="AllTimer/generatePeopleTimer" to="." method="_on_generate_people_timer_timeout"]
[connection signal="timeout" from="AllTimer/generatePeopleTimer2" to="." method="_on_generate_people_timer_2_timeout"]
[connection signal="timeout" from="AllTimer/trainComeAndLeace" to="." method="_on_train_come_and_leace_timeout"]
[connection signal="ScreenDoorAreaEnter" from="AllScreenDoorWaitArea/ScreenDoorWaitArea1" to="." method="_on_screen_door_wait_area_screen_door_area_enter"]
[connection signal="ScreenDoorAreaEnter" from="AllScreenDoorWaitArea/ScreenDoorWaitArea2" to="." method="_on_screen_door_wait_area_screen_door_area_enter"]
[connection signal="ScreenDoorAreaEnter" from="AllScreenDoorWaitArea/ScreenDoorWaitArea3" to="." method="_on_screen_door_wait_area_screen_door_area_enter"]