feat: implement UIManager for player board, action buttons, and power-up bar UI.

This commit is contained in:
Yogi Wiguna
2026-02-10 11:53:35 +08:00
parent 2c1f6746d4
commit a27ff8634d
2 changed files with 39 additions and 1 deletions
+39
View File
@@ -12,6 +12,7 @@ var touch_controls
# Minimal local state
var _connection_check_timer: float = 0.0
var tile_respawn_timers = {} # Tracks removed tiles: {Vector2i(x,z): respawn_time_msec}
func _ready():
# Initialize scene managers
@@ -49,6 +50,14 @@ func _ready():
randomize_game_grid()
_setup_tile_respawn_timer()
# Targeted 5s Respawn Timer for empty spots
var respawn_check_timer = Timer.new()
respawn_check_timer.name = "RespawnCheckTimer"
respawn_check_timer.wait_time = 0.5
respawn_check_timer.autostart = true
respawn_check_timer.timeout.connect(_check_respawns)
add_child(respawn_check_timer)
func _on_goal_count_updated(peer_id: int, count: int):
# Only update for local player
if peer_id == multiplayer.get_unique_id():
@@ -1120,11 +1129,41 @@ func request_randomize_item(grid_position: Vector2i):
if multiplayer.is_server():
randomize_item_at_position(grid_position)
func _check_respawns():
"""Check tile respawn timers and spawn items if ready."""
if not multiplayer.is_server():
return
var current_time = Time.get_ticks_msec()
var tiles_to_respawn = []
for pos in tile_respawn_timers.keys():
if current_time >= tile_respawn_timers[pos]:
tiles_to_respawn.append(pos)
for pos in tiles_to_respawn:
print("[Main] Respawning tile at ", pos)
randomize_item_at_position(pos)
tile_respawn_timers.erase(pos)
@rpc("any_peer", "call_local", "reliable")
func sync_grid_item(x: int, y: int, z: int, item: int):
var enhanced_gridmap = $EnhancedGridMap
if enhanced_gridmap:
enhanced_gridmap.set_cell_item(Vector3i(x, y, z), item)
# Server logic for respawns
if multiplayer.is_server() and y == 1:
var pos = Vector2i(x, z)
if item == -1:
# Item removed - schedule respawn 5s later
tile_respawn_timers[pos] = Time.get_ticks_msec() + 10000
print("[Main] Scheduled respawn for tile at %s in 10s" % pos)
else:
# Item placed - cancel pending respawn
if tile_respawn_timers.has(pos):
tile_respawn_timers.erase(pos)
print("[Main] Cancelled respawn for tile at %s (occupied)" % pos)
# Sync grid update (no need to sync whole grid if we do it at start, but if we do it late we might need to sync)
# For simplicity, we trust the grid syncs via normal mechanisms or initial state.
-1
View File
@@ -63,7 +63,6 @@ func initialize(player_node):
# Connect PlayerName label (Level/XP/Name UI)
player_name_label = player_node.get_node_or_null("PlayerName")
# ... (skipping unchanged functions) ...
func set_local_player(player):
local_player_character = player