fix(candy-survival): implement stagger (knockdown), lunge visual bump, and target stealing/backfire animations for Knock (Q)

This commit is contained in:
2026-07-08 17:40:01 +08:00
parent 5cf08f249b
commit f060a2f4b8
2 changed files with 37 additions and 10 deletions
+22 -9
View File
@@ -119,22 +119,35 @@ func handle_unhandled_input(event):
if LobbyManager.game_mode == "Candy Survival":
var gm = player.get_node_or_null("/root/Main/CandySurvivalManager")
if gm and gm.active:
var att_id = player.get("peer_id") if "peer_id" in player else player.name.to_int()
if gm.player_knocks.get(att_id, 0) <= 0:
NotificationManager.send_message(player, "No Knock charges left!", NotificationManager.MessageType.WARNING)
get_viewport().set_input_as_handled()
return
# Find a target to knock (first adjacent player)
var p_pos = player.current_position
var all_players = get_tree().get_nodes_in_group("Players")
var target_found = null
for other in all_players:
if other == player: continue
var other_pos = other.current_position
if abs(p_pos.x - other_pos.x) + abs(p_pos.y - other_pos.y) == 1:
# Adjacent
var att_id = player.get("peer_id") if "peer_id" in player else player.name.to_int()
var tgt_id = other.get("peer_id") if "peer_id" in other else other.name.to_int()
if multiplayer.is_server():
gm.try_knock(att_id, tgt_id)
else:
gm.rpc_id(1, "try_knock", att_id, tgt_id)
get_viewport().set_input_as_handled()
return
target_found = other
break
if target_found:
var tgt_id = target_found.get("peer_id") if "peer_id" in target_found else target_found.name.to_int()
if multiplayer.is_server():
gm.try_knock(att_id, tgt_id)
else:
gm.rpc_id(1, "try_knock", att_id, tgt_id)
else:
# No target, but play the bump animation anyway in place
player.rpc("sync_bump", p_pos)
get_viewport().set_input_as_handled()
return
if player.powerup_manager:
player.powerup_manager.use_special_effect()