feat: implement Candy Cannon mechanics, CI/CD pipelines, and version 2.3.7 updates

This commit is contained in:
2026-05-25 18:17:00 +08:00
parent 7380161743
commit f2f90f98e2
20 changed files with 952 additions and 36 deletions
+31 -4
View File
@@ -86,6 +86,8 @@ var trapped_players: Dictionary = {} # player_id → true
var main_scene: Node = null
var gridmap: Node = null
var candy_cannon_scene: PackedScene = preload("res://scenes/candy_cannon.tscn")
var cannon_instance: Node3D = null
# HUD
var hud_layer: CanvasLayer
@@ -250,6 +252,14 @@ func _apply_arena_setup() -> void:
gridmap.update_grid_data()
gridmap.initialize_astar()
if not cannon_instance and main_scene:
cannon_instance = candy_cannon_scene.instantiate()
cannon_instance.name = "CandyCannon"
var cx = NPC_CENTER.x * gridmap.cell_size.x + gridmap.cell_size.x / 2.0
var cz = NPC_CENTER.y * gridmap.cell_size.z + gridmap.cell_size.z / 2.0
cannon_instance.position = Vector3(cx, 0, cz)
main_scene.add_child(cannon_instance)
print("[Gauntlet] Arena setup complete. Center NPC at (%d,%d), size %dx%d" % [
NPC_CENTER.x, NPC_CENTER.y, NPC_SIZE, NPC_SIZE
])
@@ -336,6 +346,13 @@ func _fire_volley() -> void:
# Telegraph phase — show warning
if _can_rpc():
rpc("sync_telegraph", targets)
# Shoot projectiles visually
if cannon_instance and cannon_instance.has_method("spawn_projectile_rpc") and cannon_instance.can_rpc():
var cs = gridmap.cell_size
for target in targets:
var target_pos = Vector3(target.x * cs.x + cs.x / 2.0, 0, target.y * cs.z + cs.z / 2.0)
cannon_instance.rpc("spawn_projectile_rpc", target_pos, telegraph_time)
# Wait telegraph duration, then apply impact
await get_tree().create_timer(telegraph_time).timeout
@@ -443,24 +460,34 @@ func _check_all_players_trapped() -> void:
var all_players = get_tree().get_nodes_in_group("Players")
for player in all_players:
var pos = player.current_position if player.get("current_position") else Vector2i(-1, -1)
if is_sticky_cell(pos) and not trapped_players.has(player.get("peer_id", -1)):
if is_sticky_cell(pos) and not trapped_players.has(player.get("peer_id") if "peer_id" in player else -1):
_trap_player(player)
func _trap_player(player: Node) -> void:
var pid = player.get("peer_id", -1)
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid == -1: return
trapped_players[pid] = true
print("[Gauntlet] Player %d TRAPPED at %s" % [pid, str(player.current_position)])
emit_signal("player_trapped", pid)
# TODO: Apply movement lockout, score penalty, visual feedback
# For now, just mark as trapped — will be expanded in Task #4
# Apply visual feedback and notify
if player.has_method("apply_stagger"):
if _can_rpc():
player.rpc("apply_stagger", 999.0) # Basically infinite until cleansed
else:
player.apply_stagger(999.0)
NotificationManager.send_message(player, "Stuck in Candy!", NotificationManager.MessageType.WARNING)
func clear_sticky_cell(pos: Vector2i) -> void:
"""Used by Cleanser power-up to remove a sticky cell."""
sticky_cells.erase(pos)
if gridmap:
gridmap.set_cell_item(Vector3i(pos.x, 2, pos.y), -1)
# Sync removal to clients
if main_scene and _can_rpc():
main_scene.rpc("sync_grid_item", pos.x, 2, pos.y, -1)
# =============================================================================
# HUD
@@ -131,6 +131,18 @@ func simple_move_to(grid_position: Vector2i) -> bool:
if not try_push(grid_position, push_dir):
return false
var gm = null
var main = player.get_tree().root.get_node_or_null("Main")
if main and main.get("gauntlet_manager"):
gm = main.gauntlet_manager
# Check if currently trapped
if gm and gm.is_active:
var pid = player.get("peer_id") if "peer_id" in player else -1
if pid != -1 and gm.trapped_players.has(pid):
print("[Move] Failed: Player is trapped in a sticky cell")
return false
# Check for Tekton interaction (Knock Mode)
# If moving into a Tekton's space while in Knock Mode, trigger knock
if player.get("is_knock_mode"):
@@ -142,6 +154,12 @@ func simple_move_to(grid_position: Vector2i) -> bool:
player.knock_tekton()
return false # Don't move into the tile, just knock
# If moving into a sticky cell, trigger trap
if gm and gm.is_active and gm.is_sticky_cell(grid_position):
print("[Move] Player stepping into sticky cell at %s" % grid_position)
movement_queue.clear()
if player.is_multiplayer_authority() or multiplayer.is_server():
gm._trap_player(player)
rotate_towards_target(grid_position)
@@ -249,6 +267,15 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
other_player.target_position = pushed_to_pos # Logical update
# Check if landing spot is sticky
var main = player.get_tree().root.get_node_or_null("Main")
if main and main.get("gauntlet_manager"):
var gm = main.gauntlet_manager
if gm.is_active and gm.is_sticky_cell(pushed_to_pos):
print("[Move] Player pushed into sticky cell at %s" % pushed_to_pos)
if multiplayer.is_server() or other_player.is_multiplayer_authority():
gm._trap_player(other_player)
# 2. Apply freeze/stun effect (blue tint)
if _can_rpc():
other_player.rpc("apply_stagger", 1.5)