Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions scenes/globals/gui_manager.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -236,25 +236,6 @@ offset_right = 633.0
offset_bottom = 146.0
text = "You are a God!"

[node name="LevelUpNotificationLabel" type="Label" parent="GameHud"]
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -52.5
offset_top = -17.0
offset_right = 52.5
offset_bottom = 17.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
theme_override_font_sizes/font_size = 24
text = "Level UP!"
horizontal_alignment = 1
vertical_alignment = 1

[node name="BlackHoleWarningLabel" type="Label" parent="GameHud"]
modulate = Color(1, 0, 0, 1)
anchors_preset = 8
Expand Down
2 changes: 1 addition & 1 deletion scripts/game/level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func _physics_process(delta):
if time_left < 1:
if portal_active == false:
portal_active = true
portal_timer = portal_duration_seconds ### GPT
portal_timer = portal_duration_seconds
Singleton.gui_manager.hud_portal_active.visible = true
Singleton.gui_manager.hud_timer_bar.get("theme_override_styles/fill").bg_color = Color.hex(0xb4b542ff)
_open_portal()
Expand Down
30 changes: 0 additions & 30 deletions scripts/globals/gui_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const STATS_TABLE_GROUP := "stats_table_layer"
@onready var hud_timer_text: Label = $GameHud/HudTimerText
@onready var hud_portal_active: Label = $GameHud/HudPortalActive
@onready var hud_god_mode: Label = $GameHud/HudGodMode
@onready var level_up_notification_label: Label = $GameHud/LevelUpNotificationLabel
@onready var black_hole_warning_label: Label = $GameHud/BlackHoleWarningLabel

# Elementos exibidos na tela de Game Over.
Expand Down Expand Up @@ -484,35 +483,6 @@ func show_pause_overlay_only() -> void:
pause_menu_layer.visible = true


## Exibe uma notificação de "Level Up" no HUD.
## Parâmetros:
## - message: Texto a ser mostrado na notificação.
## Comportamento:
## - Garante que o Label `level_up_notification_label` é válido.
## - Atualiza o texto do Label e o torna visível, mas inicialmente
## com alpha = 0 (invisível).
## - Cria uma animação (Tween) que faz:
## 1. Fade in rápido (0.15s).
## 2. Pausa (1.0s).
## 3. Fade out suave (0.35s).
## - Quando o Tween termina, esconde novamente o Label
## para evitar que permaneça visível.
func show_level_up_notice(message: String) -> void:
if not is_instance_valid(level_up_notification_label):
return
level_up_notification_label.text = message
level_up_notification_label.visible = true
level_up_notification_label.modulate.a = 0.0
var fade_tween := get_tree().create_tween()
fade_tween.tween_property(level_up_notification_label, "modulate:a", 1.0, 0.15)
fade_tween.tween_interval(1.0)
fade_tween.tween_property(level_up_notification_label, "modulate:a", 0.0, 0.35)
fade_tween.finished.connect(func ():
if is_instance_valid(level_up_notification_label):
level_up_notification_label.visible = false
)


## Abre o seletor de upgrades (picker).
## - Garante existência de `upgrades_menu` e do nó `SelectUpgrades`.
## - Torna-os visíveis/ativos, repopula as cartas e pausa o jogo.
Expand Down
27 changes: 6 additions & 21 deletions scripts/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ func _init_level_progress() -> void:
if is_instance_valid(Singleton.level) and Singleton.level.has_method("get_score"):
var score = Singleton.level.get_score()
var level_index := _level_for_score(score)
_apply_level_up_to(level_index, false)

_apply_level_up_to(level_index)
current_level_index = level_index


Expand All @@ -154,11 +155,11 @@ func _init_level_progress() -> void:
func _update_level_from_score(score: int) -> void:
var target_index := _level_for_score(score)
if current_level_index < 0:
_apply_level_up_to(target_index, false)
_apply_level_up_to(target_index)
current_level_index = target_index
return
if target_index > current_level_index:
_apply_level_up_to(target_index, true)
_apply_level_up_to(target_index)
current_level_index = target_index
if target_index >= 1:
Singleton.gui_manager.open_upgrades_picker()
Expand All @@ -182,35 +183,19 @@ func _level_for_score(current_score: int) -> int:


## Aplica os desbloqueios de turrets até o nível especificado.
## Parâmetros:
## - target_level_index: índice máximo de nível a ser aplicado.
## - notify: se true, mostra uma mensagem de Level Up ao desbloquear.
## Comportamento:
## - Itera por todos os níveis do índice 0 até `target_level_index`.
## - Para cada nível, percorre a lista de turrets em `unlock` e habilita
## (define `current_bullet = 1`) as turrets correspondentes no dicionário `turrets`.
## - Se `notify` for true e o nível possuir `min_score > 0`, gera uma mensagem
## descrevendo quais turrets foram adicionadas e chama `show_level_up_notice`
## no `gui_manager` para exibir o aviso na tela.
func _apply_level_up_to(target_level_index: int, notify: bool = true) -> void:
func _apply_level_up_to(target_level_index: int) -> void:
for level_index in range(target_level_index + 1):
var turrets_to_unlock: Array = PLAYER_LEVELS[level_index]["unlock"]
for turret_direction in turrets_to_unlock:
var turret_node = turrets.get(turret_direction, null)
if is_instance_valid(turret_node):
if turret_node.current_bullet == 0:
turret_node.current_bullet = selected_weapon_id
if (
notify
and int(PLAYER_LEVELS[level_index]["min_score"]) > 0
and is_instance_valid(Singleton.gui_manager)
and Singleton.gui_manager.has_method("show_level_up_notice")
):
var unlocked_parts: Array[String] = []
for turret_direction in turrets_to_unlock:
unlocked_parts.append("Turret " + String(turret_direction) + " Added!")
var message := "Level up! " + ", ".join(unlocked_parts)
Singleton.gui_manager.show_level_up_notice(message)
turret_node.current_bullet = 1


## Atualiza a física e o estado geral do Player a cada frame.
Expand Down