This commit is contained in:
Yogi Wiguna
2026-03-17 17:38:30 +08:00
parent 1b8e411657
commit efdd8f4969
32 changed files with 320 additions and 22 deletions
+1
View File
@@ -254,6 +254,7 @@ func on_goal_completed(player: Node, time_remaining: float):
# Randomize 9 tiles around player
_randomize_tiles_around_player(player)
SfxManager.rpc("play_rpc", "complete_mission")
print("[GoalsCycle] Player %d completed goal! +%d points (base: %d, time bonus: %d)" % [peer_id, score_earned, BASE_SCORE, time_bonus])
@rpc("authority", "call_local", "reliable")
@@ -211,8 +211,10 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
# Visual Feedback: Attack Bump
if _can_rpc():
player.rpc("sync_bump", target_pos, false) # Attack bump
SfxManager.rpc("play_rpc", "attack_mode")
elif player.has_method("sync_bump"):
player.sync_bump(target_pos, false)
SfxManager.play("attack_mode")
# 1. 3-Floor Knockback towards Starting Line (X=0)
var push_direction = Vector2i(-1, 0) # Backwards
+1
View File
@@ -95,6 +95,7 @@ func grab_item(grid_position: Vector2i) -> bool:
if special_tiles_manager:
special_tiles_manager.add_powerup_from_item(item)
SfxManager.play("pick_up_power_tile")
# Animation for powerup?
# ...
+45
View File
@@ -0,0 +1,45 @@
extends Node
# SFXManager - Global singleton for playing sound effects
# Autoloaded as "SfxManager"
var sounds: Dictionary = {}
func _ready():
_load_sounds()
func _load_sounds():
var sfx_path = "res://assets/sfx/"
var dir = DirAccess.open(sfx_path)
if dir:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
if not dir.current_is_dir() and (file_name.ends_with(".mp3") or file_name.ends_with(".wav") or file_name.ends_with(".ogg")):
var base_name = file_name.get_basename()
sounds[base_name] = load(sfx_path + file_name)
# print("[SfxManager] Loaded: ", base_name)
file_name = dir.get_next()
dir.list_dir_end()
else:
push_error("[SfxManager] Could not open sfx directory: " + sfx_path)
func play(sound_name: String, pitch_range: float = 0.0):
if not sounds.has(sound_name):
# push_warning("[SfxManager] Sound not found: " + sound_name)
return
var player = AudioStreamPlayer.new()
add_child(player)
player.stream = sounds[sound_name]
player.bus = "SFX"
if pitch_range > 0:
player.pitch_scale = 1.0 + randf_range(-pitch_range, pitch_range)
player.play()
player.finished.connect(player.queue_free)
@rpc("any_peer", "call_local", "unreliable")
func play_rpc(sound_name: String, pitch_range: float = 0.0):
play(sound_name, pitch_range)
+1
View File
@@ -0,0 +1 @@
uid://dqq36uawrnpwd
@@ -262,6 +262,7 @@ func _execute_faster_speed():
if player.movement_manager:
player.movement_manager.set_speed_multiplier(1.5) # 50% faster
active_buffs[SpecialEffect.FASTER_SPEED] = FASTER_DURATION
SfxManager.rpc("play_rpc", "speed")
NotificationManager.send_message(player, "Speed Boost! (5s)", NotificationManager.MessageType.POWERUP)
func _execute_area_freeze(target_pos: Vector2i = Vector2i.ZERO):
@@ -317,6 +318,8 @@ func _execute_area_freeze(target_pos: Vector2i = Vector2i.ZERO):
NotificationManager.send_message(p, "Caught in Freeze Zone!", NotificationManager.MessageType.WARNING)
if p != player: # Don't score for freezing self (unless desired?) - Assuming enemies
hit_count += 1
SfxManager.rpc("play_rpc", "freeze")
if hit_count > 0 and player.is_multiplayer_authority():
var is_sng = LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO)
@@ -418,6 +421,7 @@ func _execute_block_floor(target_pos: Vector2i = Vector2i.ZERO):
main.rpc("sync_grid_items_batch", batch_data)
# Notify
SfxManager.rpc("play_rpc", "wall")
NotificationManager.send_message(player, "Defensive Wall Deployed!", NotificationManager.MessageType.POWERUP)
func _execute_invisible_mode(target: Node3D):
@@ -428,6 +432,7 @@ func _execute_invisible_mode(target: Node3D):
if target.has_method("sync_modulate"):
target.rpc("sync_modulate", Color(1.0, 1.0, 1.0, 0.4)) # 40% Opacity
SfxManager.rpc("play_rpc", "ghost")
NotificationManager.send_message(target, "Invisible Mode!", NotificationManager.MessageType.POWERUP)
@@ -438,6 +443,7 @@ func _execute_invisible_mode(target: Node3D):
func spawn_powerups_around(center: Vector2i, force_powerups: bool = true, only_common: bool = false, full_density: bool = false):
# "spawn / replace your nearby tiles into power up ( special tiles )"
# New PowerUp Tiles are 11, 12, 13, 14
SfxManager.rpc("play_rpc", "generate_tile")
var radius = 2
for x in range(-radius, radius + 1):
for y in range(-radius, radius + 1):
+1
View File
@@ -586,6 +586,7 @@ func _scatter_player_tiles(player_node: Node):
main.rpc("sync_playerboard", peer_id, playerboard)
# Notify the player
SfxManager.rpc("play_rpc", "tile_scatter")
NotificationManager.send_message(player_node, "Not in Safe Zone! Tiles scattered!", NotificationManager.MessageType.WARNING)
# Screen shake