точно есть дэшм
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
void fragment() {
|
||||
// Вычисляем расстояние от центра экрана (от 0.0 до 1.0)
|
||||
vec2 uv = UV - 0.5;
|
||||
float dist = length(uv);
|
||||
|
||||
// Плавное размытие к краям экрана
|
||||
float vignette = smoothstep(0.3, 0.6, dist);
|
||||
|
||||
// Применяем красный цвет только к краям виньетки
|
||||
COLOR = vec4(1.0, 0.0, 0.0, vignette * 0.4); // 0.4 — это максимальная яркость краев
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://jffp0g42qpmg
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,62 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var health_text = $HealthText
|
||||
@onready var vignette = $Vignette
|
||||
|
||||
var health_component: Node = null
|
||||
|
||||
func _ready() -> void:
|
||||
# Ищем HealthComponent у нашего игрока (родителя)
|
||||
if get_parent():
|
||||
health_component = get_parent().find_child("HealthComponent", true, false)
|
||||
|
||||
if health_component == null:
|
||||
print("[UI ЗДОРОВЬЯ] КРИТИЧЕСКАЯ ОШИБКА: HealthComponent игрока не найден!")
|
||||
|
||||
# Изначально принудительно настраиваем видимость
|
||||
if health_text:
|
||||
health_text.visible = true
|
||||
if vignette:
|
||||
vignette.visible = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if health_component == null:
|
||||
return
|
||||
|
||||
var current_health = health_component.current_health
|
||||
|
||||
# 1. ОБНОВЛЯЕМ ЦИФРЫ НА ЭКРАНЕ
|
||||
if health_text:
|
||||
health_text.text = str(clamp(int(current_health), 0, 100))
|
||||
|
||||
# Красим цифры при низком здоровье
|
||||
if current_health <= 30:
|
||||
health_text.add_theme_color_override("font_color", Color.RED)
|
||||
else:
|
||||
health_text.add_theme_color_override("font_color", Color.WHITE)
|
||||
|
||||
# 2. УПРАВЛЯЕМ КРАСНОЙ ВИНЬЕТКОЙ
|
||||
if vignette:
|
||||
if current_health <= 30 and current_health > 0:
|
||||
vignette.visible = true
|
||||
|
||||
# Эффект плавного биения сердца (пульсация)
|
||||
var color_rect = vignette.get_node_or_null("ColorRect")
|
||||
if color_rect:
|
||||
color_rect.visible = true
|
||||
var pulse = (sin(Time.get_ticks_msec() * 0.005) + 1.0) / 2.0
|
||||
color_rect.modulate.a = lerp(0.3, 1.0, pulse)
|
||||
else:
|
||||
vignette.visible = false
|
||||
|
||||
# 3. АВТОРЕСТАРТ ПРИ СМЕРТИ (Перезагрузка уровня)
|
||||
if current_health <= 0:
|
||||
print("[UI ЗДОРОВЬЯ] Игрок погиб! Перезагружаю уровень через 2 секунды...")
|
||||
# Отключаем процесс, чтобы не спамить перезагрузкой
|
||||
set_process(false)
|
||||
|
||||
# Ждем 2 секунды, чтобы игрок успел понять, что умер
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
|
||||
# Мягко перезапускаем текущую сцену
|
||||
get_tree().reload_current_scene()
|
||||
@@ -0,0 +1 @@
|
||||
uid://ccjc1yqh1eb0k
|
||||
Reference in New Issue
Block a user