feat: Implement core player character logic and input handling, including movement, actions, and manager integration.
This commit is contained in:
@@ -828,6 +828,34 @@ func attempt_target_action(target_index: int):
|
||||
st_manager.activate_effect(effect, target_player)
|
||||
inventory_ui.deselect()
|
||||
|
||||
func activate_powerup(effect_id: int):
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if not main or not main.ui_manager:
|
||||
return
|
||||
|
||||
# Try to find the UI button directly if possible, or simulate the click
|
||||
# The goal is to Select it (if it requires targeting) OR Activate it (if instant)
|
||||
|
||||
# Since PowerUpInventoryUI manages selection state, we should route through it if possible
|
||||
# or directly tell SpecialTilesManager to prepare?
|
||||
|
||||
# Let's try to mimic the button press
|
||||
var inventory_ui = main.ui_manager.get_node_or_null("PowerUpInventoryUI") # Or wherever it lives
|
||||
if not inventory_ui:
|
||||
# Fallback: Find it in scene
|
||||
inventory_ui = main.get_node_or_null("PowerUpInventoryUI")
|
||||
|
||||
if inventory_ui:
|
||||
# Inventory UI handles: "activate_effect(effect_id)" on click
|
||||
# Which then calls SpecialTilesManager.activate_effect
|
||||
# This handles both "Instant" effects (Speed) and "Targeting" effects (Wall)
|
||||
inventory_ui._on_btn_pressed(effect_id)
|
||||
else:
|
||||
# Fallback if UI not found
|
||||
var st_manager = get_node_or_null("SpecialTilesManager")
|
||||
if st_manager:
|
||||
st_manager.activate_effect(effect_id)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
if is_multiplayer_authority():
|
||||
|
||||
@@ -46,50 +46,7 @@ func _process(delta):
|
||||
if target_position != player.current_position:
|
||||
movement_manager.simple_move_to(target_position)
|
||||
|
||||
# === KEYBOARD SHORTCUTS (User Request) ===
|
||||
|
||||
# Numpad 1: Speed (Enum 0)
|
||||
if Input.is_key_pressed(KEY_KP_1):
|
||||
player.attempt_target_action(0) # FASTER_SPEED
|
||||
|
||||
# Numpad 2: Wall (Enum 2)
|
||||
elif Input.is_key_pressed(KEY_KP_2):
|
||||
player.attempt_target_action(2) # BLOCK_FLOOR
|
||||
|
||||
# Numpad 3: Freeze (Enum 1)
|
||||
elif Input.is_key_pressed(KEY_KP_3):
|
||||
player.attempt_target_action(1) # AREA_FREEZE
|
||||
|
||||
# Numpad 4: Ghost (Enum 3)
|
||||
elif Input.is_key_pressed(KEY_KP_4):
|
||||
player.attempt_target_action(3) # INVISIBLE_MODE
|
||||
|
||||
# C: Special Attack (Attack Mode) - Boost
|
||||
elif Input.is_key_pressed(KEY_C):
|
||||
if player.powerup_manager:
|
||||
player.powerup_manager.use_special_effect()
|
||||
|
||||
# V: Spawn Boost Item
|
||||
elif Input.is_key_pressed(KEY_V):
|
||||
if player.powerup_manager:
|
||||
# Verify the method exists first (it was added recently/confirmed available)
|
||||
if player.powerup_manager.has_method("spawn_boost_reward"):
|
||||
player.powerup_manager.spawn_boost_reward()
|
||||
else:
|
||||
# Fallback if method missing
|
||||
player.powerup_manager.use_special_effect()
|
||||
|
||||
# Original 1-4 keys (Succession order 0-3) - Keeping as fallback?
|
||||
# User didn't ask to remove them, but new Numpad bindings are specific.
|
||||
# We can leave them for now unless they conflict.
|
||||
if Input.is_key_pressed(KEY_1):
|
||||
player.attempt_target_action(0)
|
||||
elif Input.is_key_pressed(KEY_2):
|
||||
player.attempt_target_action(1)
|
||||
elif Input.is_key_pressed(KEY_3):
|
||||
player.attempt_target_action(2)
|
||||
elif Input.is_key_pressed(KEY_4):
|
||||
player.attempt_target_action(3)
|
||||
|
||||
# Targeting Mode Preview
|
||||
var main = player.get_node_or_null("/root/Main")
|
||||
@@ -130,7 +87,26 @@ func handle_unhandled_input(event):
|
||||
if not player.is_multiplayer_authority() or (TurnManager.turn_based_mode and (not player.is_my_turn or movement_manager.is_moving)):
|
||||
return
|
||||
|
||||
# --- Real-time Keyboard/Touch Input moved to _process ---
|
||||
# --- Keyboard Shortcuts (Event-based) ---
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
match event.keycode:
|
||||
KEY_KP_1, KEY_1:
|
||||
player.activate_powerup(0) # FASTER_SPEED
|
||||
KEY_KP_2, KEY_2:
|
||||
player.activate_powerup(2) # BLOCK_FLOOR
|
||||
KEY_KP_3, KEY_3:
|
||||
player.activate_powerup(1) # AREA_FREEZE
|
||||
KEY_KP_4, KEY_4:
|
||||
player.activate_powerup(3) # INVISIBLE_MODE
|
||||
KEY_C:
|
||||
if player.powerup_manager:
|
||||
player.powerup_manager.use_special_effect()
|
||||
KEY_V:
|
||||
if player.powerup_manager:
|
||||
if player.powerup_manager.has_method("spawn_boost_reward"):
|
||||
player.powerup_manager.spawn_boost_reward()
|
||||
else:
|
||||
player.powerup_manager.use_special_effect()
|
||||
|
||||
# Handle spawn point selection if not yet selected
|
||||
|
||||
|
||||
Reference in New Issue
Block a user