feat: Add core game scene with manager initialization, a dynamic message bar, scarcity-based tile respawn, and a new star tile asset.
This commit is contained in:
@@ -121,6 +121,22 @@ func get_max_points() -> int:
|
||||
func get_fill_percentage() -> float:
|
||||
return current_boost / MAX_BOOST
|
||||
|
||||
func get_time_until_full() -> float:
|
||||
if current_boost >= MAX_BOOST:
|
||||
return 0.0
|
||||
|
||||
# Calculate remaining points needed
|
||||
var remaining = MAX_BOOST - current_boost
|
||||
|
||||
# Get current fill rate
|
||||
var level_idx = clamp(current_level - 1, 0, FILL_TIMES.size() - 1)
|
||||
var fill_time = FILL_TIMES[level_idx]
|
||||
var current_rate = MAX_BOOST / fill_time
|
||||
|
||||
if current_rate <= 0: return 0.0
|
||||
|
||||
return remaining / current_rate
|
||||
|
||||
func get_bars() -> int:
|
||||
"""Returns the number of filled segments (0-4)."""
|
||||
# Each bar is 25 points (100 / 4)
|
||||
|
||||
@@ -26,6 +26,7 @@ var victory_ui_instance
|
||||
var playerboard_ui
|
||||
var action_menu_instance
|
||||
var powerup_inventory_ui
|
||||
var timer_label: Label
|
||||
|
||||
var local_player_character
|
||||
var _previous_playerboard_state: Array = []
|
||||
@@ -235,6 +236,8 @@ func _connect_powerup_manager_deferred(player):
|
||||
powerup_manager.points_changed.connect(_on_powerup_points_changed)
|
||||
# Initialize bar with current values
|
||||
update_powerup_bar(powerup_manager.get_points(), powerup_manager.get_max_points())
|
||||
# Force initial label update
|
||||
_on_powerup_points_changed(powerup_manager.get_points(), powerup_manager.get_max_points())
|
||||
else:
|
||||
push_warning("[UIManager] PowerUpManager not found on player after 0.8s wait")
|
||||
|
||||
@@ -294,6 +297,7 @@ func update_powerup_bar(current_points: int, _max_points: int):
|
||||
var _previous_bars: int = 0
|
||||
|
||||
func _on_powerup_points_changed(current: int, max_points: int):
|
||||
if current % 10 == 0: print("[UIManager] Points changed: ", current)
|
||||
# Calculate based on max points (100) / 4 segments = 25 points per segment
|
||||
var new_bars = int(current / 25.0)
|
||||
|
||||
@@ -307,6 +311,17 @@ func _on_powerup_points_changed(current: int, max_points: int):
|
||||
|
||||
_previous_bars = new_bars
|
||||
update_powerup_bar(current, max_points)
|
||||
|
||||
# Update Safety: Check if timer_label is valid
|
||||
if timer_label and local_player_character and local_player_character.powerup_manager:
|
||||
var time_left = local_player_character.powerup_manager.get_time_until_full()
|
||||
if time_left <= 0:
|
||||
timer_label.text = " READY "
|
||||
timer_label.add_theme_color_override("font_color", Color(0.3, 0.9, 0.3)) # Green
|
||||
else:
|
||||
# User request: "Do it on int not float"
|
||||
timer_label.text = str(int(ceil(time_left))) + "s"
|
||||
timer_label.add_theme_color_override("font_color", Color(1.0, 0.85, 0.2)) # Gold
|
||||
|
||||
func _pulse_segment(segment: Panel):
|
||||
"""Create a visual pulse effect on a powerup segment."""
|
||||
@@ -371,13 +386,13 @@ func setup_timer_labels(main_node):
|
||||
goals_timer.add_theme_stylebox_override("panel", style)
|
||||
|
||||
# Style the timer label
|
||||
var timer_label = goals_timer.get_node_or_null("VBox/TimerLabel")
|
||||
if timer_label:
|
||||
timer_label.add_theme_color_override("font_color", Color(1.0, 0.85, 0.2))
|
||||
|
||||
var suffix_label = goals_timer.get_node_or_null("VBox/SuffixLabel")
|
||||
if suffix_label:
|
||||
suffix_label.add_theme_color_override("font_color", Color(0.7, 0.7, 0.7))
|
||||
var t_label = goals_timer.get_node_or_null("TimerLabel")
|
||||
if t_label:
|
||||
timer_label = t_label # Store reference
|
||||
t_label.add_theme_color_override("font_color", Color(1.0, 0.85, 0.2))
|
||||
print("[UIManager] SUCCESS: Found and stored TimerLabel reference.")
|
||||
else:
|
||||
print("[UIManager] ERROR: GoalsTimer found but TimerLabel NOT found at node/TimerLabel")
|
||||
|
||||
# Method to update leaderboard with all players in match
|
||||
func initialize_leaderboard_with_players(players: Array):
|
||||
|
||||
Reference in New Issue
Block a user