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
+39 -20
View File
@@ -32,29 +32,48 @@ func _init_client():
client = Nakama.create_client(nakama_server_key, nakama_host, nakama_port, nakama_scheme)
func set_server(host: String, port: int = 7350):
nakama_host = host
# Clean up the host string
var clean_host = host.strip_edges()
# Auto-detect secure tunnels (Tailscale, ngrok, playit, cloudflare)
if host.ends_with(".ts.net") or host.ends_with(".gg") or host.begins_with("https://"):
if host.begins_with("https://"):
nakama_host = host.replace("https://", "")
if host.begins_with("http://"):
nakama_host = host.replace("http://", "")
if nakama_host.ends_with("/"):
nakama_host = nakama_host.substr(0, nakama_host.length() - 1)
nakama_port = 443
# Extract protocol if present (override everything else)
var forced_scheme = ""
if clean_host.begins_with("https://"):
forced_scheme = "https"
clean_host = clean_host.replace("https://", "")
elif clean_host.begins_with("http://"):
forced_scheme = "http"
clean_host = clean_host.replace("http://", "")
# Handle trailing slashes
if clean_host.ends_with("/"):
clean_host = clean_host.substr(0, clean_host.length() - 1)
# Extract port if explicitly provided in host string (e.g. host:port)
var explicit_port = -1
if ":" in clean_host:
var parts = clean_host.split(":")
clean_host = parts[0]
explicit_port = parts[1].to_int()
# DETECT SETTINGS
nakama_host = clean_host
if forced_scheme != "":
nakama_scheme = forced_scheme
nakama_port = explicit_port if explicit_port != -1 else (443 if forced_scheme == "https" else port)
elif clean_host.ends_with(".ts.net") and explicit_port == -1:
# Tailscale Funnel Case (No port provided, .ts.net domain)
nakama_scheme = "https"
else:
# Extract port if they typed something like 192.168.1.1:7350
if ":" in host and not host.begins_with("http"):
var parts = host.split(":")
nakama_host = parts[0]
nakama_port = parts[1].to_int()
else:
nakama_port = port
nakama_port = 443
elif clean_host.begins_with("100."):
# Standard Tailscale IP Case
nakama_scheme = "http"
nakama_port = explicit_port if explicit_port != -1 else port
else:
# Generic Case (e.g. localhost, public IP)
nakama_scheme = "http"
nakama_port = explicit_port if explicit_port != -1 else port
_init_client()
print("[NakamaManager] Server updated to: ", nakama_scheme, "://", nakama_host, ":", nakama_port)