feat: implement special tiles manager for power-ups, including inventory, levels, cooldowns, and effect activation.

This commit is contained in:
Yogi Wiguna
2026-03-16 14:40:28 +08:00
parent 07387e67af
commit ab3ca7661f
3 changed files with 16 additions and 4 deletions
+14 -2
View File
@@ -94,7 +94,7 @@ var blocked_tiles: Array[Dictionary] = [] # {position: Vector3i, original_item:
var freeze_zones: Array[Dictionary] = [] # {position: Vector2i, timer: float}
var active_freeze_zones: Array = [] # Array of {center, radius, timer}
var invisible_timer: float = 0.0
var global_cooldown_timer: float = 0.0
# INVENTORY SYSTEM
# Stores count of each power-up type. Max 1 per type as per user request?
@@ -202,6 +202,11 @@ func activate_effect(effect: int, target_player: Node3D = null):
print("PowerUp %s not found in inventory or false. Inventory: %s" % [effect, inventory])
return
# Check Cooldown
if global_cooldown_timer > 0:
NotificationManager.send_message(player, "Skill in Cooldown! (%.1fs)" % global_cooldown_timer, NotificationManager.MessageType.WARNING)
return
# Check Attack Mode Restriction
if player.get("is_attack_mode") and effect == SpecialEffect.INVISIBLE_MODE:
NotificationManager.send_message(player, "Cannot enter Ghost mode while in Attack Mode!", NotificationManager.MessageType.WARNING)
@@ -213,7 +218,7 @@ func activate_effect(effect: int, target_player: Node3D = null):
return
var level = powerup_levels.get(effect, 1)
print("[SpecialTiles] Player %s activated %s (Lvl %d). No cooldown applied." % [player.name, SpecialEffect.keys()[effect], level])
print("[SpecialTiles] Player %s activated %s (Lvl %d)." % [player.name, SpecialEffect.keys()[effect], level])
match effect:
SpecialEffect.FASTER_SPEED:
@@ -227,6 +232,9 @@ func activate_effect(effect: int, target_player: Node3D = null):
SpecialEffect.INVISIBLE_MODE:
_execute_invisible_mode(player)
# Apply 5s cooldown globally
global_cooldown_timer = 5.0
# Play generic cast animation or sound?
if player.is_multiplayer_authority() and multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
player.rpc("trigger_screen_shake", "light")
@@ -541,6 +549,10 @@ func _check_for_icy_floor():
pass
func _process(delta):
# Update Global Cooldown
if global_cooldown_timer > 0:
global_cooldown_timer -= delta
# Update Active Buffs (Speed)
if active_buffs.has(SpecialEffect.FASTER_SPEED):
active_buffs[SpecialEffect.FASTER_SPEED] -= delta