Entre les niveaux et à la mort il y a maintenant un fondu au noir qui se met en place pour éviter d'avoir la gerbe sur les mouvements de caméra. la physique est en pause pendant la transition.
88 lines
2.7 KiB
GDScript
88 lines
2.7 KiB
GDScript
class_name Game extends Node
|
|
|
|
@onready var hud := $HUD as HUD
|
|
|
|
var current_scene : Node
|
|
var level0 = preload("res://levels/level_0.tscn")
|
|
var level1 = preload("res://levels/level_1.tscn")
|
|
|
|
var scene_name = "level_0"
|
|
var current_scence
|
|
var prev_scene
|
|
var last_spawn_point = null
|
|
|
|
var princesse : Princess = null
|
|
|
|
var goto_destination
|
|
var goto_spawn_point
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
go_to(scene_name, null)
|
|
|
|
func reload_current_scene() -> void:
|
|
go_to(scene_name, last_spawn_point)
|
|
hud.reset()
|
|
|
|
func enter_door(destination : String, other_side_position : Vector2):
|
|
call_deferred("go_to", destination, other_side_position)
|
|
|
|
func go_to(destination : String, spawn_point):
|
|
goto_destination = destination
|
|
goto_spawn_point = spawn_point
|
|
hud.begin_scene_transition()
|
|
|
|
func _on_hud_screen_is_black() -> void:
|
|
var destination = goto_destination
|
|
var spawn_point = goto_spawn_point
|
|
|
|
var old_princesse :Princess = null
|
|
if current_scence:
|
|
old_princesse = current_scence.find_child("Princesse")
|
|
old_princesse.disconnect("cheese_collected", hud_load_cheese)
|
|
old_princesse.disconnect("dash_fart", hud_unload_cheese)
|
|
#old_princesse.disconnect("princess_is_dead", princess_death)
|
|
remove_child(current_scence)
|
|
|
|
if destination == "level_1":
|
|
current_scence = level1.instantiate()
|
|
scene_name = "level_1"
|
|
elif destination == "level_0":
|
|
current_scence = level0.instantiate()
|
|
scene_name = "level_0"
|
|
|
|
current_scence.connect("reload_me", reload_current_scene, ConnectFlags.CONNECT_ONE_SHOT)
|
|
var doors :Node = current_scence.find_child("Doors")
|
|
if doors:
|
|
for door in doors.get_children():
|
|
door.connect("door_openned", enter_door, ConnectFlags.CONNECT_ONE_SHOT)
|
|
add_child(current_scence)
|
|
|
|
princesse= current_scence.find_child("Princesse")
|
|
if spawn_point:
|
|
princesse.position = spawn_point
|
|
last_spawn_point = spawn_point
|
|
if old_princesse:
|
|
princesse.copy_from(old_princesse)
|
|
princesse.connect("cheese_collected", hud_load_cheese)
|
|
princesse.connect("dash_fart", hud_unload_cheese)
|
|
#princesse.connect("princess_is_dead", princess_death)
|
|
hud.end_scene_transition()
|
|
|
|
|
|
# vient de la princesse quand elle a ramassé un fromage
|
|
func hud_load_cheese():
|
|
Input.start_joy_vibration(0, 0, 1, 0.1)
|
|
hud.load_cheese()
|
|
|
|
# vient de la princesse quand elle ^ète
|
|
func hud_unload_cheese():
|
|
hud.dash_fart()
|
|
|
|
# quand le fromage est chargé, le jeu le signale à la princesse
|
|
func _on_hud_fart_reloaded() -> void:
|
|
princesse.reload_fart()
|
|
|
|
func _on_hud_screen_is_ready() -> void:
|
|
princesse.go_out_and_play()
|