This commit is contained in:
2026-01-29 03:04:24 +08:00
parent 6949e20a1f
commit e66ba7542c
12 changed files with 687 additions and 549 deletions
+90 -12
View File
@@ -20,6 +20,15 @@ var is_frozen: bool = false
var is_invisible: bool = false
var original_movement_range: int = 1
var is_attack_mode: bool = false:
set(value):
is_attack_mode = value
# Visual feedback for attack mode (Red Tint)
if is_attack_mode:
_apply_tint_recursive(self, Color(1.0, 0.5, 0.5))
else:
_apply_tint_recursive(self, Color.WHITE)
@export var is_bot: bool = false
@export var enhanced_gridmap_path: NodePath = "/root/Main/EnhancedGridMap"
@@ -668,11 +677,31 @@ func drop_random_item():
rpc("display_message", "Dropped item!", 4)
print("Player %s dropped item %d at %s" % [name, item_id, drop_pos])
func playerboard_is_empty() -> bool:
for item in playerboard:
if item != -1:
return false
return true
@rpc("any_peer", "call_local")
func drop_all_tiles():
"""Drops all tiles from playerboard. Used by Super Push."""
var dropped_count = 0
for i in range(playerboard.size()):
if playerboard[i] != -1:
var item_id = playerboard[i]
playerboard[i] = -1
# Find a spot to drop? Or just destroy?
# User: "drop all tiles on playerboard" -> usually implies they scatter on floor
# But scattering 25 tiles is chaotic.
# Let's drop a few random ones and destroy rest?
# Or per user "spawn nearby tiles into power up" -> Maybe the dropped tiles BECOME powerups?
# User request: "victim drops all tiles... and spawn / replace your nearby tiles into power up"
# I will just clear the board here. Spawning is handled by spawn_powerups_around.
dropped_count += 1
if dropped_count > 0:
rpc("sync_playerboard", playerboard)
rpc("trigger_screen_shake", "targeted")
rpc("display_message", "CRITICALLY HIT!", 4)
print("Player %s dropped %d tiles due to Super Push" % [name, dropped_count])
func _find_valid_drop_position() -> Vector2i:
# Try random adjacent cells
@@ -681,16 +710,65 @@ func _find_valid_drop_position() -> Vector2i:
for neighbor in neighbors:
var pos = neighbor.position
if enhanced_gridmap.get_cell_item(Vector3i(pos.x, 0, pos.y)) == -1: # Empty floor? No, 0 is floor. -1 is void?
# Wait, items are on layer 1 usually?
# Check logic: grab_item uses y=1?
var item_cell = Vector3i(pos.x, 1, pos.y)
if enhanced_gridmap.get_cell_item(item_cell) == -1:
if not is_position_occupied(pos):
return pos
# Check item layer
var item_cell = Vector3i(pos.x, 1, pos.y)
if enhanced_gridmap.get_cell_item(item_cell) == -1:
if not is_position_occupied(pos):
return pos
return Vector2i(-1, -1)
# =============================================================================
# Targeting Action
# =============================================================================
func attempt_target_action(target_index: int):
# 1. Get Selected Effect from UI
var main = get_tree().get_root().get_node_or_null("Main")
if not main or not main.ui_manager:
return
# Quick check if UI exists and has a selection
# We need to access the script variable 'selected_effect' from the dynamically created/loaded UI.
# Let's assume ui_manager has a reference or we find it.
# Based on previous step, we haven't integrated PowerUpInventoryUI into UIManager yet.
# So we might fail here if not wired up.
# For now, let's look for "PowerUpInventoryUI" in CanvasLayer.
var inventory_ui = main.ui_manager.get_node_or_null("PowerUpInventoryUI")
# Or check if ui_manager tracks it.
# Note: We haven't instantiated it yet in UIManager. We will need to do that.
if not inventory_ui or inventory_ui.selected_effect == -1:
return # No effect selected using mouse/touch first
var effect = inventory_ui.selected_effect
# 2. Find Target Player
var player_manager = main.get_node_or_null("PlayerManager")
if not player_manager:
return
if target_index < 0 or target_index >= player_manager.connected_peer_ids.size():
return
var target_id = player_manager.connected_peer_ids[target_index]
var target_player = main.get_node_or_null(str(target_id))
if not target_player:
return
if target_player == self and effect != 4: # 4 = INVISIBLE (Self)
# Trying to target self with harmful effect?
rpc("display_message", "Can't target self!", 3)
return
# 3. Activate Effect
var st_manager = get_node_or_null("SpecialTilesManager")
if st_manager:
st_manager.activate_effect(effect, target_player)
inventory_ui.deselect()
func _process(delta):
if is_multiplayer_authority():