diff --git a/Tiles/Tile.gd b/Tiles/Tile.gd index 63857e6..23b9157 100644 --- a/Tiles/Tile.gd +++ b/Tiles/Tile.gd @@ -2,16 +2,22 @@ extends Node3D class_name Tile -@onready var follow = $MainPath/Follow as PathFollow3D @onready var spawn_point = $SpawnPoint as Marker3D -@onready var progress_marker = $MainPath/Follow/ProgressMarker as Marker3D -var paths: Array[Path3D] +var paths: Array[TilePath] var path_index: int = 0 -var path: Path3D: +var path: TilePath: get = get_current_path +var follow: PathFollow3D: + get: + return path.follow + +var progress_marker: Marker3D: + get: + return path.marker + var marker_position: Vector3: get: return progress_marker.global_position @@ -27,12 +33,11 @@ func _ready(): func _process(delta): if is_equal_approx(follow.progress_ratio, 1) and has_next_path(): + get_next_path().receive_marker(progress_marker) path_index += 1 - follow = Utils.get_first_node_of_type(path, PathFollow3D) as PathFollow3D - progress_marker.reparent(follow) -func get_current_path() -> Path3D: +func get_current_path() -> TilePath: return paths[path_index] @@ -40,7 +45,7 @@ func has_next_path() -> bool: return path_index + 1 < paths.size() -func get_next_path() -> Path3D: +func get_next_path() -> TilePath: if has_next_path(): return paths[path_index+1] return null diff --git a/Tiles/Tile1.tscn b/Tiles/Tile1.tscn index 3f8aaf9..bdec0dc 100644 --- a/Tiles/Tile1.tscn +++ b/Tiles/Tile1.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://cvtgigpmwwv4g"] +[gd_scene load_steps=7 format=3 uid="uid://cvtgigpmwwv4g"] -[ext_resource type="Script" path="res://Tiles/Tile.gd" id="1_wu32c"] +[ext_resource type="Script" path="res://Tiles/tile.gd" id="1_wu32c"] +[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_ij0mq"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] cull_mode = 2 @@ -13,9 +14,9 @@ size = Vector2(10, 10) material = SubResource("StandardMaterial3D_cwetn") size = Vector2(2, 10) -[sub_resource type="Curve3D" id="Curve3D_q1k88"] +[sub_resource type="Curve3D" id="Curve3D_q1142"] _data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, -5), +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10), "tilts": PackedFloat32Array(0, 0) } point_count = 2 @@ -24,26 +25,19 @@ point_count = 2 script = ExtResource("1_wu32c") [node name="Floor" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) mesh = SubResource("PlaneMesh_jju0s") [node name="Wall1" type="MeshInstance3D" parent="."] -transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, 0) +transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, -5) mesh = SubResource("PlaneMesh_rsriu") [node name="Wall2" type="MeshInstance3D" parent="."] -transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 5, 1, 0) +transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 5, 1, -5) mesh = SubResource("PlaneMesh_rsriu") [node name="SpawnPoint" type="Marker3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10) -[node name="MainPath" type="Path3D" parent="."] -curve = SubResource("Curve3D_q1k88") - -[node name="Follow" type="PathFollow3D" parent="MainPath"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"] +[node name="MainPath" parent="." instance=ExtResource("2_ij0mq")] +curve = SubResource("Curve3D_q1142") diff --git a/Tiles/TilePath.tscn b/Tiles/TilePath.tscn new file mode 100644 index 0000000..b922e7a --- /dev/null +++ b/Tiles/TilePath.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://dh2nm1sphyfqx"] + +[ext_resource type="Script" path="res://Tiles/tile_path.gd" id="1_6jxwt"] + +[node name="TilePath" type="Path3D"] +script = ExtResource("1_6jxwt") + +[node name="Follow" type="PathFollow3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5) +rotation_mode = 1 +loop = false +tilt_enabled = false diff --git a/Tiles/TileRamp1.tscn b/Tiles/TileRamp1.tscn index f53a188..e35910c 100644 --- a/Tiles/TileRamp1.tscn +++ b/Tiles/TileRamp1.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://fafw4evt372"] +[gd_scene load_steps=7 format=3 uid="uid://fafw4evt372"] -[ext_resource type="Script" path="res://Tiles/Tile.gd" id="1_qgvt0"] +[ext_resource type="Script" path="res://Tiles/tile.gd" id="1_qgvt0"] +[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_66bgp"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] cull_mode = 2 @@ -13,9 +14,9 @@ size = Vector2(10, 10) material = SubResource("StandardMaterial3D_cwetn") size = Vector2(2, 10) -[sub_resource type="Curve3D" id="Curve3D_q1k88"] +[sub_resource type="Curve3D" id="Curve3D_8f65e"] _data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, -2.40419, 3.96713, 0, 0, 0, 0, 0, 0, 0, 2.60463, -4.68416), +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0.00492096, 0.00431776, 0, 0, 0, 0, 0, 0, 0, 4.99628, -8.66443), "tilts": PackedFloat32Array(0, 0) } point_count = 2 @@ -24,27 +25,19 @@ point_count = 2 script = ExtResource("1_qgvt0") [node name="Floor" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 0.0893164, -0.333333) +transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 2.48097, -4.33106) mesh = SubResource("PlaneMesh_jju0s") [node name="Wall1" type="MeshInstance3D" parent="."] -transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, -5, 0.955342, 0.166667) +transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, -5, 3.347, -3.83106) mesh = SubResource("PlaneMesh_rsriu") [node name="Wall2" type="MeshInstance3D" parent="."] -transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, 5, 0.955342, 0.166667) +transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, 5, 3.347, -3.83106) mesh = SubResource("PlaneMesh_rsriu") [node name="SpawnPoint" type="Marker3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.56806, -4.67077) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.95971, -8.6685) -[node name="MainPath" type="Path3D" parent="."] -curve = SubResource("Curve3D_q1k88") - -[node name="Follow" type="PathFollow3D" parent="MainPath"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.40419, 3.96713) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"] +[node name="MainPath" parent="." instance=ExtResource("2_66bgp")] +curve = SubResource("Curve3D_8f65e") diff --git a/Tiles/TileTurn1.tscn b/Tiles/TileTurn1.tscn deleted file mode 100644 index 5f1dbbd..0000000 --- a/Tiles/TileTurn1.tscn +++ /dev/null @@ -1,110 +0,0 @@ -[gd_scene load_steps=11 format=3 uid="uid://b88nuwe42bhc1"] - -[ext_resource type="Script" path="res://Tiles/TileTurn.gd" id="1_wj6en"] -[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/obstacle.tscn" id="2_tnkvo"] - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] -cull_mode = 2 - -[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"] -material = SubResource("StandardMaterial3D_cwetn") -size = Vector2(10, 10) - -[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"] -material = SubResource("StandardMaterial3D_cwetn") -size = Vector2(2, 10) - -[sub_resource type="Curve3D" id="Curve3D_q1k88"] -_data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1), -"tilts": PackedFloat32Array(0, 0) -} -point_count = 2 - -[sub_resource type="Curve3D" id="Curve3D_5ouye"] -_data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -6), -"tilts": PackedFloat32Array(0, 0) -} -point_count = 2 - -[sub_resource type="Curve3D" id="Curve3D_dgywf"] -_data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0), -"tilts": PackedFloat32Array(0, 0, 0) -} -point_count = 3 - -[sub_resource type="Curve3D" id="Curve3D_25twk"] -_data = { -"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0), -"tilts": PackedFloat32Array(0, 0, 0) -} -point_count = 3 - -[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"] -size = Vector3(9.80943, 5.486, 17.6183) - -[node name="Tile1" type="Node3D"] -script = ExtResource("1_wj6en") - -[node name="Floor" type="MeshInstance3D" parent="."] -mesh = SubResource("PlaneMesh_jju0s") - -[node name="Wall1" type="MeshInstance3D" parent="."] -transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, 0) -mesh = SubResource("PlaneMesh_rsriu") - -[node name="Wall2" type="MeshInstance3D" parent="."] -transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -5) -mesh = SubResource("PlaneMesh_rsriu") - -[node name="SpawnPoint" type="Marker3D" parent="."] -transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5, 0, 0) - -[node name="MainPath" type="Path3D" parent="."] -curve = SubResource("Curve3D_q1k88") - -[node name="Follow" type="PathFollow3D" parent="MainPath"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"] - -[node name="PathForward" type="Path3D" parent="."] -curve = SubResource("Curve3D_5ouye") - -[node name="Follow" type="PathFollow3D" parent="PathForward"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="PathRight" type="Path3D" parent="."] -curve = SubResource("Curve3D_dgywf") - -[node name="Follow" type="PathFollow3D" parent="PathRight"] -transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 1) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="PathLeft" type="Path3D" parent="."] -curve = SubResource("Curve3D_25twk") - -[node name="Follow" type="PathFollow3D" parent="PathLeft"] -transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 1) -rotation_mode = 1 -loop = false -tilt_enabled = false - -[node name="Area3D" type="Area3D" parent="."] - -[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, 4.34685) -shape = SubResource("BoxShape3D_uvh3q") - -[node name="Obstacle" parent="." instance=ExtResource("2_tnkvo")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5.14771) diff --git a/Tiles/TileTurnLeft1.tscn b/Tiles/TileTurnLeft1.tscn new file mode 100644 index 0000000..a0faf76 --- /dev/null +++ b/Tiles/TileTurnLeft1.tscn @@ -0,0 +1,86 @@ +[gd_scene load_steps=12 format=3 uid="uid://c0xv7v6ako25a"] + +[ext_resource type="Script" path="res://Tiles/tile_turn.gd" id="1_f1mql"] +[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_yvi2s"] +[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/Obstacle.tscn" id="3_us011"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] +cull_mode = 2 + +[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"] +material = SubResource("StandardMaterial3D_cwetn") +size = Vector2(10, 10) + +[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"] +material = SubResource("StandardMaterial3D_cwetn") +size = Vector2(2, 10) + +[sub_resource type="Curve3D" id="Curve3D_r80si"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4), +"tilts": PackedFloat32Array(0, 0) +} +point_count = 2 + +[sub_resource type="Curve3D" id="Curve3D_gpbgb"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -11), +"tilts": PackedFloat32Array(0, 0) +} +point_count = 2 + +[sub_resource type="Curve3D" id="Curve3D_f5rtl"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 5, 0, -5), +"tilts": PackedFloat32Array(0, 0, 0) +} +point_count = 3 + +[sub_resource type="Curve3D" id="Curve3D_a3s3y"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, -5, 0, -5), +"tilts": PackedFloat32Array(0, 0, 0) +} +point_count = 3 + +[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"] +size = Vector3(9.80943, 5.486, 17.6183) + +[node name="Tile1" type="Node3D"] +script = ExtResource("1_f1mql") + +[node name="Floor" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) +mesh = SubResource("PlaneMesh_jju0s") + +[node name="Wall1" type="MeshInstance3D" parent="."] +transform = Transform3D(4.37114e-08, -1, -8.74228e-08, -1, -4.37114e-08, 0, -3.82137e-15, 8.74228e-08, -1, 5, 1, -5) +mesh = SubResource("PlaneMesh_rsriu") + +[node name="Wall2" type="MeshInstance3D" parent="."] +transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -10) +mesh = SubResource("PlaneMesh_rsriu") + +[node name="MainPath" parent="." instance=ExtResource("2_yvi2s")] +curve = SubResource("Curve3D_r80si") + +[node name="PathForward" parent="." instance=ExtResource("2_yvi2s")] +curve = SubResource("Curve3D_gpbgb") + +[node name="PathRight" parent="." instance=ExtResource("2_yvi2s")] +curve = SubResource("Curve3D_f5rtl") + +[node name="PathLeft" parent="." instance=ExtResource("2_yvi2s")] +curve = SubResource("Curve3D_a3s3y") + +[node name="SpawnPoint" type="Marker3D" parent="."] +transform = Transform3D(1.31134e-07, 0, 1, 0, 1, 0, -1, 0, 1.31134e-07, -5, 0, -5) + +[node name="Area3D" type="Area3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, -0.65315) +shape = SubResource("BoxShape3D_uvh3q") + +[node name="Obstacle" parent="." instance=ExtResource("3_us011")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -10.1477) diff --git a/Tiles/TileTurnRight1.tscn b/Tiles/TileTurnRight1.tscn new file mode 100644 index 0000000..9faf1b5 --- /dev/null +++ b/Tiles/TileTurnRight1.tscn @@ -0,0 +1,86 @@ +[gd_scene load_steps=12 format=3 uid="uid://b88nuwe42bhc1"] + +[ext_resource type="Script" path="res://Tiles/tile_turn.gd" id="1_wj6en"] +[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/Obstacle.tscn" id="2_tnkvo"] +[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="3_e2l5m"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] +cull_mode = 2 + +[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"] +material = SubResource("StandardMaterial3D_cwetn") +size = Vector2(10, 10) + +[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"] +material = SubResource("StandardMaterial3D_cwetn") +size = Vector2(2, 10) + +[sub_resource type="Curve3D" id="Curve3D_r80si"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4), +"tilts": PackedFloat32Array(0, 0) +} +point_count = 2 + +[sub_resource type="Curve3D" id="Curve3D_gpbgb"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -11), +"tilts": PackedFloat32Array(0, 0) +} +point_count = 2 + +[sub_resource type="Curve3D" id="Curve3D_f5rtl"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 5, 0, -5), +"tilts": PackedFloat32Array(0, 0, 0) +} +point_count = 3 + +[sub_resource type="Curve3D" id="Curve3D_jhtrd"] +_data = { +"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, -5, 0, -5), +"tilts": PackedFloat32Array(0, 0, 0) +} +point_count = 3 + +[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"] +size = Vector3(9.80943, 5.486, 17.6183) + +[node name="Tile1" type="Node3D"] +script = ExtResource("1_wj6en") + +[node name="Floor" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) +mesh = SubResource("PlaneMesh_jju0s") + +[node name="Wall1" type="MeshInstance3D" parent="."] +transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, -5) +mesh = SubResource("PlaneMesh_rsriu") + +[node name="Wall2" type="MeshInstance3D" parent="."] +transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -10) +mesh = SubResource("PlaneMesh_rsriu") + +[node name="MainPath" parent="." instance=ExtResource("3_e2l5m")] +curve = SubResource("Curve3D_r80si") + +[node name="PathForward" parent="." instance=ExtResource("3_e2l5m")] +curve = SubResource("Curve3D_gpbgb") + +[node name="PathRight" parent="." instance=ExtResource("3_e2l5m")] +curve = SubResource("Curve3D_f5rtl") + +[node name="PathLeft" parent="." instance=ExtResource("3_e2l5m")] +curve = SubResource("Curve3D_jhtrd") + +[node name="SpawnPoint" type="Marker3D" parent="."] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5, 0, 0) + +[node name="Area3D" type="Area3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, -0.65315) +shape = SubResource("BoxShape3D_uvh3q") + +[node name="Obstacle" parent="." instance=ExtResource("2_tnkvo")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -10.1477) diff --git a/Tiles/tile_path.gd b/Tiles/tile_path.gd new file mode 100644 index 0000000..0ab6d6d --- /dev/null +++ b/Tiles/tile_path.gd @@ -0,0 +1,26 @@ +extends Path3D +class_name TilePath + +@onready var follow = $Follow as PathFollow3D + +var _marker: Marker3D +var marker: Marker3D: + get: + if not has_progress_marker(): + create_marker() + return _marker + + +func has_progress_marker() -> bool: + return _marker != null + + +func create_marker() -> Marker3D: + _marker = Marker3D.new() + follow.add_child(_marker) + return _marker + + +func receive_marker(node: Marker3D) -> void: + node.reparent(follow) + _marker = node diff --git a/Tiles/TileTurn.gd b/Tiles/tile_turn.gd similarity index 57% rename from Tiles/TileTurn.gd rename to Tiles/tile_turn.gd index 4847512..44cde17 100644 --- a/Tiles/TileTurn.gd +++ b/Tiles/tile_turn.gd @@ -2,13 +2,17 @@ extends Tile class_name TileTurn @onready var area_3d = $Area3D as Area3D -@onready var path_forward = $PathForward as Path3D -@onready var path_right = $PathRight as Path3D -@onready var path_left = $PathLeft as Path3D +@onready var path_forward = $PathForward as TilePath +@onready var path_right = $PathRight as TilePath +@onready var path_left = $PathLeft as TilePath var connected = false var current_direction = "forward" -var on_main_path = true +var character: Character + +var on_main_path: bool: + get: + return path_index == 0 func _ready(): @@ -17,11 +21,18 @@ func _ready(): func _process(delta): + var character_found = false for area in area_3d.get_overlapping_areas(): - if area is Character and not connected: - var character = area as Character + if area is Character: + character_found = true + if connected: + break + character = area as Character character.turn.connect(turn) connected = true + if not character_found and connected: + character.turn.disconnect(turn) + connected = false super(delta) @@ -31,7 +42,7 @@ func turn(direction): paths[path_index+1] = get_path_by_direction(current_direction) -func get_path_by_direction(direction) -> Path3D: +func get_path_by_direction(direction) -> TilePath: if direction == "forward" and path_forward != null: return path_forward elif direction == "right" and path_right != null: diff --git a/obstacles/obstacle.tscn b/obstacles/obstacle.tscn index 9eaf5ff..a90a389 100644 --- a/obstacles/obstacle.tscn +++ b/obstacles/obstacle.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=3 format=3 uid="uid://dkcjoccsgbggg"] -[ext_resource type="Script" path="res://obstacles/obstacle.gd" id="1_ab8so"] +[ext_resource type="Script" path="res://obstacles/obstacle.gd" id="1_78mjh"] [sub_resource type="BoxShape3D" id="BoxShape3D_c6wik"] size = Vector3(10, 2, 0.5) [node name="Obstacle" type="Area3D"] -script = ExtResource("1_ab8so") +script = ExtResource("1_78mjh") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("BoxShape3D_c6wik") diff --git a/project.godot b/project.godot index bb3738b..68a1089 100644 --- a/project.godot +++ b/project.godot @@ -18,6 +18,7 @@ config/icon="res://icon.svg" [autoload] Utils="*res://utils.gd" +TileGenerator="*res://tile_generator.gd" [rendering] diff --git a/tile_generator.gd b/tile_generator.gd new file mode 100644 index 0000000..67c03a2 --- /dev/null +++ b/tile_generator.gd @@ -0,0 +1,54 @@ +extends Node + +var tile_set = preload("res://tile_set1.tres") as FR_TileSet + +var tiles: Array[Tile] +var run_started = false +var tile_parent: Node + +func _ready(): + pass + + +func _process(delta): + if not run_started: + return + if tiles.size() == 0: + return + if tiles.size() < 15: + add_tile() + #if is_equal_approx(current_tile.follow.progress_ratio, 1) and has_next_tile(): + #if current_tile.has_next_path(): + #return + #tile_index += 1 + #character.tile = current_tile + + +func start_run(tile_parent: Node) -> void: + self.tile_parent = tile_parent + get_current_tiles() + if tiles.size() == 0: + var tile = generate_tile() + tiles.append(tile) + tile_parent.add_child(tile) + run_started = true + + +func get_current_tiles() -> void: + tiles.assign(Utils.get_nodes_of_class(get_tree().root, Tile)) + + +func generate_tile() -> Tile: + var index = randi_range(0, tile_set.strait_tiles.size()-1) + var tile_scene: PackedScene = tile_set.strait_tiles[index] + var tile = tile_scene.instantiate() + return tile + + +func add_tile() -> void: + var last_tile = tiles[tiles.size()-1] + var tile = generate_tile() + tiles.append(tile) + tile_parent.add_child(tile) + tile.global_position = last_tile.spawn_point.global_position + tile.global_rotation = last_tile.spawn_point.global_rotation diff --git a/tile_set.gd b/tile_set.gd new file mode 100644 index 0000000..1cbb598 --- /dev/null +++ b/tile_set.gd @@ -0,0 +1,6 @@ +extends Resource +class_name FR_TileSet + +@export var strait_tiles: Array[PackedScene] +@export var ramp_tiles: Array[PackedScene] +@export var turn_tiles: Array[PackedScene] diff --git a/tile_set1.tres b/tile_set1.tres new file mode 100644 index 0000000..3d41a43 --- /dev/null +++ b/tile_set1.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="FR_TileSet" load_steps=5 format=3 uid="uid://b1bl33xgipadd"] + +[ext_resource type="Script" path="res://tile_set.gd" id="1_oesq8"] +[ext_resource type="PackedScene" uid="uid://cvtgigpmwwv4g" path="res://Tiles/Tile1.tscn" id="3_4xf43"] +[ext_resource type="PackedScene" uid="uid://c0xv7v6ako25a" path="res://Tiles/TileTurnLeft1.tscn" id="4_xn546"] +[ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurnRight1.tscn" id="5_tir2o"] + +[resource] +script = ExtResource("1_oesq8") +strait_tiles = Array[PackedScene]([ExtResource("3_4xf43")]) +ramp_tiles = Array[PackedScene]([null]) +turn_tiles = Array[PackedScene]([ExtResource("4_xn546"), ExtResource("5_tir2o")]) diff --git a/world.gd b/world.gd index 6b73839..6aa7d40 100644 --- a/world.gd +++ b/world.gd @@ -17,6 +17,7 @@ func _ready() -> void: return if character.tile == null: character.tile = current_tile + TileGenerator.start_run(self) func _process(delta: float) -> void: diff --git a/world.tscn b/world.tscn index b664e58..d1d59e1 100644 --- a/world.tscn +++ b/world.tscn @@ -1,14 +1,31 @@ -[gd_scene load_steps=6 format=3 uid="uid://blupjt2ulo2g1"] +[gd_scene load_steps=10 format=3 uid="uid://blupjt2ulo2g1"] -[ext_resource type="PackedScene" uid="uid://vamte52rvfhy" path="res://character/character.tscn" id="1_nfwx6"] +[ext_resource type="PackedScene" uid="uid://vamte52rvfhy" path="res://character/Character.tscn" id="1_nfwx6"] [ext_resource type="Script" path="res://world.gd" id="1_oloil"] [ext_resource type="PackedScene" uid="uid://cvtgigpmwwv4g" path="res://Tiles/Tile1.tscn" id="3_vddfn"] [ext_resource type="PackedScene" uid="uid://fafw4evt372" path="res://Tiles/TileRamp1.tscn" id="4_uxk3v"] -[ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurn1.tscn" id="5_ynp1e"] +[ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurnRight1.tscn" id="5_ynp1e"] +[ext_resource type="PackedScene" uid="uid://c0xv7v6ako25a" path="res://Tiles/TileTurnLeft1.tscn" id="6_327qh"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_dhu5e"] +sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) +ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) + +[sub_resource type="Sky" id="Sky_16rbt"] +sky_material = SubResource("ProceduralSkyMaterial_dhu5e") + +[sub_resource type="Environment" id="Environment_c08wk"] +background_mode = 2 +sky = SubResource("Sky_16rbt") +tonemap_mode = 2 +glow_enabled = true [node name="World" type="Node3D"] script = ExtResource("1_oloil") +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_c08wk") + [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] transform = Transform3D(0.763207, -0.546639, 0.344531, 0.296667, 0.770123, 0.564712, -0.574024, -0.328781, 0.749933, 3.45982, 2.03445, -6.78341) shadow_enabled = true @@ -22,13 +39,22 @@ tile = NodePath("../Tile1") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10) [node name="Tile3" parent="." instance=ExtResource("4_uxk3v")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.49484, -19.3201) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0861304, -19.3201) [node name="Tile4" parent="." instance=ExtResource("3_vddfn")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -28.6473) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -27.9971) [node name="Tile5" parent="." instance=ExtResource("5_ynp1e")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -38.641) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -37.9673) [node name="Tile6" parent="." instance=ExtResource("3_vddfn")] -transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 10, 5, -38.6473) +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5.01222, 5, -42.9558) + +[node name="Tile7" parent="." instance=ExtResource("5_ynp1e")] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 15.0122, 5, -42.9555) + +[node name="Tile8" parent="." instance=ExtResource("3_vddfn")] +transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 20, 5, -37.9705) + +[node name="Tile9" parent="." instance=ExtResource("6_327qh")] +transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 20, 5, -27.9764)