feat: Implement Stop n Go game mode with phase management, missions, dynamic safe zones, and associated UI and managers.

This commit is contained in:
Yogi Wiguna
2026-03-06 16:01:12 +08:00
parent edd5051106
commit 0fb1397d11
8 changed files with 106 additions and 71 deletions
+40 -23
View File
@@ -40,9 +40,16 @@ func _ready():
_setup_btn(2, wall_btn)
_setup_btn(3, ghost_btn)
# All skills available with new logic
if wall_btn: wall_btn.visible = true
if freeze_btn: freeze_btn.visible = true
# All skills available with new logic, but restricted in Stop n Go
if is_restricted:
if wall_btn: wall_btn.visible = false
if freeze_btn: freeze_btn.visible = false
# Re-setup shortcut labels for restricted mode
_update_shortcuts_for_mode(true)
else:
if wall_btn: wall_btn.visible = true
if freeze_btn: freeze_btn.visible = true
_update_shortcuts_for_mode(false)
print("[PowerUpUI] UI Initialization Complete. Mapped %d buttons." % icon_containers.size())
@@ -91,39 +98,49 @@ func _setup_btn(effect_id: int, btn: Button):
var sc_lbl = Label.new()
sc_lbl.name = "ShortcutLabel"
sc_lbl.mouse_filter = Control.MOUSE_FILTER_IGNORE
# Position: Top Left of the button
sc_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
sc_lbl.vertical_alignment = VERTICAL_ALIGNMENT_TOP
# Anchor to top left
sc_lbl.set_anchors_preset(Control.PRESET_TOP_LEFT)
# Offset to be close to the corner
sc_lbl.offset_left = 0
sc_lbl.offset_top = -5 # Close to the button top
sc_lbl.offset_top = -5
sc_lbl.add_theme_font_size_override("font_size", 16)
sc_lbl.add_theme_color_override("font_outline_color", Color.BLACK)
sc_lbl.add_theme_constant_override("outline_size", 4)
# Add color override to make it distinct (optional, but good for visibility)
sc_lbl.add_theme_color_override("font_color", Color(0.9, 0.9, 0.9))
# Determine Label Text based on Effect ID
var key_text = ""
# Consistent mapping: 1, 2, 3, 4
btn.add_child(sc_lbl)
_update_btn_shortcut(effect_id, btn)
# Connect click
if not btn.pressed.is_connected(_on_btn_pressed):
btn.pressed.connect(_on_btn_pressed.bind(effect_id))
func _update_shortcuts_for_mode(is_restricted: bool):
for effect_id in icon_containers:
var btn = icon_containers[effect_id]
_update_btn_shortcut(effect_id, btn)
func _update_btn_shortcut(effect_id: int, btn: Button):
var sc_lbl = btn.get_node_or_null("ShortcutLabel")
if not sc_lbl: return
var mode = LobbyManager.get_game_mode()
var is_sng = mode == GameMode.Mode.STOP_N_GO
var key_text = ""
if is_sng:
match effect_id:
0: key_text = "1" # Speed
3: key_text = "2" # Ghost
_: key_text = "" # Others hidden/disabled
else:
match effect_id:
0: key_text = "1" # Speed
2: key_text = "2" # Wall
1: key_text = "3" # Freeze
3: key_text = "4" # Ghost
sc_lbl.text = key_text
btn.add_child(sc_lbl)
# Connect click
if not btn.pressed.is_connected(_on_btn_pressed):
btn.pressed.connect(_on_btn_pressed.bind(effect_id))
sc_lbl.text = key_text
func _on_btn_pressed(effect_id: int):
print("[PowerUpUI] Clicked Button %d" % effect_id)