save
This commit is contained in:
parent
ad95711535
commit
2e310f4053
25 changed files with 852 additions and 74 deletions
6
entities/checkpoint/CheckPointManager.tscn
Normal file
6
entities/checkpoint/CheckPointManager.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cu5r7oxtqa2c0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dp4qacjfhtyul" path="res://entities/checkpoint/check_point_manager.gd" id="1_g2cn0"]
|
||||
|
||||
[node name="CheckPointManager" type="Node"]
|
||||
script = ExtResource("1_g2cn0")
|
29
entities/checkpoint/check_point_manager.gd
Normal file
29
entities/checkpoint/check_point_manager.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
extends Node
|
||||
|
||||
@export var nb_checkpoints := 5
|
||||
@export var max_lap := 3
|
||||
|
||||
var current_checkpoint := 0
|
||||
var current_lap := 0
|
||||
|
||||
func checkPointEnter(check_point_id):
|
||||
if check_point_id != current_checkpoint:
|
||||
print("not good checkpoint")
|
||||
return
|
||||
|
||||
if check_point_id == 0:
|
||||
current_lap += 1
|
||||
current_checkpoint = 1
|
||||
print("new lap")
|
||||
else:
|
||||
current_checkpoint += 1
|
||||
print(current_checkpoint)
|
||||
|
||||
if (current_lap == max_lap):
|
||||
endTrack()
|
||||
return
|
||||
|
||||
func endTrack():
|
||||
print("end")
|
||||
current_lap = 0
|
||||
current_checkpoint = 0
|
1
entities/checkpoint/check_point_manager.gd.uid
Normal file
1
entities/checkpoint/check_point_manager.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dp4qacjfhtyul
|
14
entities/checkpoint/checkpoint.gd
Normal file
14
entities/checkpoint/checkpoint.gd
Normal file
|
@ -0,0 +1,14 @@
|
|||
extends Area3D
|
||||
class_name CheckPoint
|
||||
@export var check_point_id : int = 0
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if body is not Car:
|
||||
return
|
||||
|
||||
CheckPointManager.checkPointEnter(check_point_id)
|
||||
|
||||
|
||||
|
1
entities/checkpoint/checkpoint.gd.uid
Normal file
1
entities/checkpoint/checkpoint.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dxswi3yuxexve
|
22
entities/checkpoint/checkpoint.tscn
Normal file
22
entities/checkpoint/checkpoint.tscn
Normal file
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://caolvlv4uvi04"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dxswi3yuxexve" path="res://entities/checkpoint/checkpoint.gd" id="1_ywa0e"]
|
||||
[ext_resource type="Material" uid="uid://5vg20wpsk85u" path="res://entities/checkpoint/checkpoint_mat.tres" id="2_ha6r5"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gkifo"]
|
||||
size = Vector3(15, 5, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ywa0e"]
|
||||
material = ExtResource("2_ha6r5")
|
||||
size = Vector3(15, 5, 1)
|
||||
|
||||
[node name="Checkpoint" type="Area3D"]
|
||||
script = ExtResource("1_ywa0e")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("BoxShape3D_gkifo")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("BoxMesh_ywa0e")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
5
entities/checkpoint/checkpoint_mat.tres
Normal file
5
entities/checkpoint/checkpoint_mat.tres
Normal file
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="StandardMaterial3D" format=3 uid="uid://5vg20wpsk85u"]
|
||||
|
||||
[resource]
|
||||
transparency = 1
|
||||
albedo_color = Color(0.396078, 1, 0.686275, 0.270588)
|
Loading…
Add table
Add a link
Reference in a new issue