feat: Create player input and powerup managers to handle player interactions, movement, actions, targeting, and boost meter mechanics.

This commit is contained in:
Yogi Wiguna
2026-03-05 14:29:34 +08:00
parent ebfa8f99a7
commit fb6d9df5db
7 changed files with 51 additions and 48 deletions
+3 -2
View File
@@ -125,8 +125,9 @@ func handle_unhandled_input(event):
if player.powerup_manager.has_method("spawn_boost_reward"):
player.powerup_manager.spawn_boost_reward()
KEY_G:
if not player.is_carrying_tekton:
player.grab_tekton()
if not player.is_carrying_tekton and player.powerup_manager:
if player.powerup_manager.can_use_special():
player.grab_tekton()
# Handle spawn point selection if not yet selected
+9 -3
View File
@@ -156,6 +156,11 @@ func use_special_effect() -> bool:
if not can_use_special():
return false
# Restriction: Cannot use attack mode while carrying a Tekton
if player.is_carrying_tekton:
NotificationManager.send_message(player, "Cannot enter Attack Mode while carrying a Tekton!", NotificationManager.MessageType.WARNING)
return false
# Enable Attack Mode explicitly
player.is_attack_mode = true
# Do NOT consume boost here. Boost acts as "fuel" for the attacks.
@@ -183,14 +188,15 @@ func spawn_boost_reward() -> bool:
return false
if player.special_tiles_manager and player.special_tiles_manager.has_method("spawn_powerups_around"):
# Spawn only common tiles (7-10) with 100% density
player.special_tiles_manager.spawn_powerups_around(player.current_position, true, true, true)
# Spawn tiles (Stop N Go gets only common, Free Mode gets 60/40 ratio)
player.special_tiles_manager.spawn_powerups_around(player.current_position, true, false, true)
# Drop the Tekton after spawning
if player.has_method("drop_tekton"):
player.drop_tekton()
print("[PowerUp] %s used Tekton to SPAWN TILES (100%% Density Common)." % player.name)
reset_boost()
print("[PowerUp] %s used Tekton to SPAWN TILES and consumed Boost." % player.name)
return true
return false
+3 -3
View File
@@ -441,14 +441,14 @@ func spawn_powerups_around(center: Vector2i, force_powerups: bool = true, only_c
var mode = LobbyManager.get_game_mode()
if only_common or LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO):
# Spawn ONLY goals (7-10) for Stop n Go or if forced
# Spawn ONLY common tiles (7-10) for Stop n Go or if forced
item_id = rng.randi_range(7, 10)
else:
# Free mode: 60% Chance for Normal Tile (7-10), 40% for PowerUp
# Free mode: 60% Chance for Common Tile (7-10), 40% for PowerUp
if rng.randf() < 0.6:
item_id = rng.randi_range(7, 10)
else:
# 30% Chance for PowerUp (Speed 11, Freeze 12, Ghost 14 - Exclude Wall 13 in restricted modes)
# 40% Chance for PowerUp
var is_restricted = GameMode.is_restricted(mode)
if is_restricted:
item_id = [11, 14].pick_random()
+6 -2
View File
@@ -524,13 +524,17 @@ func _on_boost_points_changed(current_points: int, max_points: int):
# User Request: Disable Special & SpawnBoost if < 100%
var is_full = current_points >= (max_points - 1) # Tolerance
_update_boost_button_state(attack_mode_button, is_full)
# Attack Mode (⚡) is only enabled if full AND not carrying a Tekton
var can_attack = is_full and not (local_player and local_player.is_carrying_tekton)
_update_boost_button_state(attack_mode_button, can_attack)
# SpawnBoost depends on carrying a Tekton, not boost points
var can_spawn = local_player and local_player.is_carrying_tekton
_update_boost_button_state(spawn_boost_button, can_spawn)
_update_boost_button_state(tekton_grab_button, true) # Always enabled (logic handles grab-ability)
# Tekton Grab (👋) is only enabled if full AND not already carrying one
var can_grab = is_full and not (local_player and local_player.is_carrying_tekton)
_update_boost_button_state(tekton_grab_button, can_grab)
func _on_tekton_carried_changed(_is_carrying: bool):
# Refresh button states when player grabs/throws a tekton
+2 -5
View File
@@ -387,12 +387,9 @@ func spawn_tiles_around(count: int = 4):
if roll < 0.6:
# 60% Normal Tile (7-10)
item_id = rng.randi_range(7, 10)
elif roll < 0.9:
# 30% PowerUp (11-14)
item_id = rng.randi_range(11, 14)
else:
# 10% Obstacle/Trap (optional)
item_id = -1 # Clear?
# 40% PowerUp (11-14)
item_id = rng.randi_range(11, 14)
if item_id != -1:
var main = get_tree().get_root().get_node_or_null("Main")