80 lines
3.7 KiB
GDScript
80 lines
3.7 KiB
GDScript
extends CanvasLayer
|
|
|
|
var target_scene_path: String = ""
|
|
|
|
func _ready() -> void:
|
|
# Ставим максимальный слой отрисовки, чтобы HUD игры не перекрывал меню
|
|
layer = 120
|
|
if has_node("Panel"):
|
|
$Panel.visible = true
|
|
print("[РЕЗУЛЬТАТЫ] Экран итогов успешно создан прямо на карте!")
|
|
|
|
func show_results(next_scene: String) -> void:
|
|
target_scene_path = next_scene
|
|
print("[РЕЗУЛЬТАТЫ] Данные получены. Путь к следующей сцене: ", target_scene_path)
|
|
|
|
# Останавливаем таймер уровня
|
|
if LevelStats:
|
|
LevelStats.stop_level_tracking()
|
|
|
|
# БРОНЕБОЙНОЕ ОБНОВЛЕНИЕ ТЕКСТА: Ищем узлы прямо в момент вызова функции
|
|
var kills_label = find_child("KillsLabel", true, false)
|
|
if kills_label == null: kills_label = find_child("kills_label", true, false)
|
|
if kills_label:
|
|
kills_label.text = "Убито врагов: " + str(LevelStats.current_kills)
|
|
print("[РЕЗУЛЬТАТЫ] Текст убийств обновлен: ", kills_label.text)
|
|
|
|
var time_label = find_child("TimeLabel", true, false)
|
|
if time_label == null: time_label = find_child("time_label", true, false)
|
|
if time_label:
|
|
time_label.text = "Время прохождения: " + LevelStats.get_formatted_time()
|
|
print("[РЕЗУЛЬТАТЫ] Текст времени обновлен: ", time_label.text)
|
|
|
|
# ПРИНУДИТЕЛЬНО РАЗРЕШАЕМ ДВИГАТЬ КУРСОР МЫШИ
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
func _on_continue_button_pressed() -> void:
|
|
print("[РЕЗУЛЬТАТЫ] Кнопка 'Далее' зафиксирована! Запускаю плавное затемнение...")
|
|
|
|
if target_scene_path == "":
|
|
print("[РЕЗУЛЬТАТЫ] ОШИБКА: Путь к следующей сцене пустой!")
|
|
return
|
|
|
|
# --- НАШЕ КРИТИЧЕСКОЕ ДОБАВЛЕНИЕ: СОХРАНЯЕМ ИГРОКА ПЕРЕД УХОДОМ В ЗАТЕМНЕНИЕ ---
|
|
var player = get_tree().current_scene.find_child("PlayerCharacter", true, false)
|
|
if player and GameTransfer:
|
|
GameTransfer.save_player_data(player)
|
|
# --------------------------------------------------------------------------------
|
|
|
|
# Твой старый код затемнения и смены сцены...
|
|
var fade_rect = find_child("FadeRect", true, false)
|
|
if fade_rect and "visible" in fade_rect:
|
|
fade_rect.visible = true
|
|
fade_rect.modulate.a = 0.0
|
|
var tween = create_tween()
|
|
tween.tween_property(fade_rect, "modulate:a", 1.0, 1.0)
|
|
await tween.finished
|
|
|
|
_set_ui_elements_visible(false)
|
|
if LevelStats: LevelStats.start_level_tracking()
|
|
|
|
queue_free()
|
|
get_tree().change_scene_to_file(target_scene_path)
|
|
|
|
# Полностью замени функцию в самом конце results_screen.gd на этот код:
|
|
func _set_ui_elements_visible(is_visible: bool) -> void:
|
|
# Находим и переключаем надпись убийств
|
|
var k_label = find_child("KillsLabel", true, false)
|
|
if k_label == null: k_label = find_child("kills_label", true, false)
|
|
if k_label: k_label.visible = is_visible
|
|
|
|
# Находим и переключаем надпись времени
|
|
var t_label = find_child("TimeLabel", true, false)
|
|
if t_label == null: t_label = find_child("time_label", true, false)
|
|
if t_label: t_label.visible = is_visible
|
|
|
|
# Находим и переключаем кнопку продолжения
|
|
var c_button = find_child("ContinueButton", true, false)
|
|
if c_button == null: c_button = find_child("continue_button", true, false)
|
|
if c_button: c_button.visible = is_visible
|