Les voiture maintenant suivent des coordonnées fournies par un AStarGrid2D au lieu de bétement faire une diagonale vers le prochain point du lapin ce qui fait que, maintenant elle ne peuvent plus vraiment monter sur les troitoirs car ils ne font pas partis du calque de navigation.
32 lines
766 B
GDScript
32 lines
766 B
GDScript
extends Node2D
|
|
class_name LightSemaphore
|
|
|
|
@export var dependantSemaphore : LightSemaphore = null
|
|
@export var hasOwnTimerEnabled = true
|
|
@onready var lights := [$Sempahore/green, $Sempahore/yellow, $Sempahore/red ];
|
|
var light = 0;
|
|
|
|
func _ready() -> void:
|
|
$brakeZone.get_child(1).disabled = !light;
|
|
for i in range (lights.size()):
|
|
lights[i].visible = i == light
|
|
|
|
func change_light():
|
|
light += 1;
|
|
if light > 2:
|
|
light = 0;
|
|
$brakeZone.get_child(1).disabled = !light;
|
|
for i in range (lights.size()):
|
|
lights[i].visible = i == light
|
|
|
|
func _on_timer_timeout() -> void:
|
|
if hasOwnTimerEnabled:
|
|
if light == 0:
|
|
$Timer.wait_time = 1;
|
|
else:
|
|
$Timer.wait_time = 5;
|
|
$Timer.start()
|
|
change_light();
|
|
if dependantSemaphore:
|
|
dependantSemaphore.change_light();
|