feat: Establish initial game structure including lobby, UI, and core gameplay managers.

This commit is contained in:
Yogi Wiguna
2026-02-02 15:01:30 +08:00
parent 9201c99d42
commit 66d34d0d29
21 changed files with 1688 additions and 1475 deletions
+63 -13
View File
@@ -3,13 +3,17 @@ extends Node
# PowerUpManager - Handles Boost Meter (Time-based logic)
# Note: Inventory logic is now in SpecialTilesManager + PlayerboardManager
const MAX_BOOST: float = 100.0
const BASE_FILL_RATE: float = 4.0 # 4 points per second baseline (25s to full)
const MAX_BOOST: float = 100.0 # Fills to 100. Activation requires FULL bar (>= 100).
const BASE_FILL_RATE: float = 10.0 # 10 points per second (10s to full) - user requested faster/simpler
var player: Node3D
var enhanced_gridmap: Node
var goal_manager: Node
# Progressive Difficulty Settings
const FILL_TIMES: Array = [2.0, 3.0, 4.0, 5.0, 6.0, 7.5, 8.5, 10.0] # Seconds to full for Lvl 1-8 (2s to 10s)
var current_level: int = 1
# Boost State
var current_boost: float = 0.0
@@ -49,7 +53,13 @@ func _process(delta):
# Use authority ID for lookup
multiplier = goal_manager.get_boost_multiplier(player.get_multiplayer_authority())
current_boost += BASE_FILL_RATE * multiplier * delta
# Calculate Dynamic Fill Rate based on Level
# Level 1 (Index 0) -> Level 8 (Index 7)
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 # e.g. 100/10 = 10/s, 100/60 = 1.66/s
current_boost += current_rate * multiplier * delta
current_boost = min(current_boost, MAX_BOOST)
# Update UI (Cast to int for compatibility with existing UI slider/bar)
@@ -59,7 +69,7 @@ func _process(delta):
_on_boost_full()
func _on_boost_full():
player.is_attack_mode = true
# player.is_attack_mode = true # Removed auto-activate
emit_signal("bar_filled")
NotificationManager.send_message(player, NotificationManager.MESSAGES.ATTACK_MODE_READY, NotificationManager.MessageType.POWERUP)
print("[PowerUp] Player %s Boost Full! Entering Attack Mode." % player.name)
@@ -69,7 +79,7 @@ func _on_boost_full():
func reset_boost():
current_boost = 0.0
player.is_attack_mode = false
# player.is_attack_mode = false # Do not auto-disable here, managed by usage
emit_signal("points_changed", 0, int(MAX_BOOST))
emit_signal("boost_reset")
@@ -104,15 +114,51 @@ func get_fill_percentage() -> float:
return current_boost / MAX_BOOST
func can_use_special() -> bool:
return current_boost >= MAX_BOOST
# Use small epsilon for float comparison to avoid "99.999" issues
return current_boost >= (MAX_BOOST - 0.1)
func enable_attack_mode():
"""Enable Attack Mode without consuming boost."""
player.is_attack_mode = true
NotificationManager.send_message(player, NotificationManager.MESSAGES.ATTACK_MODE_READY, NotificationManager.MessageType.POWERUP)
print("[PowerUp] Attack Mode Enabled (Free).")
func use_special_effect() -> bool:
if not can_use_special():
return false
# Consume boost
reset_boost()
# Enable Attack Mode explicitly
player.is_attack_mode = true
# Do NOT consume boost here. Boost acts as "fuel" for the attacks.
# Notification check handled by caller or signal
return true
func consume_boost(amount: float):
"""Consume a specific amount of boost."""
current_boost -= amount
if current_boost <= 0:
current_boost = 0.0
player.is_attack_mode = false # Out of fuel
emit_signal("boost_reset") # UI update for empty
print("[PowerUp] Boost depleted. Attack Mode OFF.")
emit_signal("points_changed", int(current_boost), int(MAX_BOOST))
if player.is_multiplayer_authority():
rpc("sync_boost", current_boost)
func spawn_boost_reward() -> bool:
"""Alternative Boost Usage: Spawn a PowerUp Tile properly."""
if not can_use_special():
return false
if player.special_tiles_manager and player.special_tiles_manager.has_method("spawn_powerups_around"):
player.special_tiles_manager.spawn_powerups_around(player.current_position)
reset_boost() # Consumes full bar
print("[PowerUp] %s used Boost to SPAWN ITEM." % player.name)
return true
return false
func acquire_smash_bonus():
current_boost += 25.0 # Add 25% boost
@@ -122,8 +168,12 @@ func acquire_smash_bonus():
_on_boost_full()
func add_goal_completion_reward():
current_boost += 50.0 # Reward for completing goal
current_boost = min(current_boost, MAX_BOOST)
emit_signal("points_changed", int(current_boost), int(MAX_BOOST))
if current_boost >= MAX_BOOST:
_on_boost_full()
"""Called when player completes a goal board. Increases difficulty level."""
current_level += 1
if current_level > 8:
current_level = 8
var level_idx = clamp(current_level - 1, 0, FILL_TIMES.size() - 1)
print("[PowerUp] Player %s Completed Goal. Boost Level Up! Now: %d (Fill Time: %.1fs)" % [player.name, current_level, FILL_TIMES[level_idx]])
# Optional: Notify user of difficulty increase?