added blocking doors to paths.

This commit is contained in:
2026-01-10 19:46:55 +01:00
parent 24ea2f3c60
commit 25be2c00bd
33 changed files with 4383 additions and 455 deletions

View File

@@ -107,6 +107,9 @@ var coins: int:
if character_stats:
character_stats.coin = value
# Key inventory
var keys: int = 0 # Number of keys the player has
# Animation system
enum Direction {
DOWN = 0,
@@ -2065,7 +2068,10 @@ func take_damage(amount: float, attacker_position: Vector2):
tween.tween_property(sprite_body, "modulate", Color.RED, 0.1)
tween.tween_property(sprite_body, "modulate", Color.WHITE, 0.1)
# Sync damage visual effects to other clients
# Show damage number (red, using dmg_numbers.png font)
_show_damage_number(amount, attacker_position)
# Sync damage visual effects to other clients (including damage numbers)
if multiplayer.has_multiplayer_peer() and can_send_rpcs and is_inside_tree():
_sync_damage.rpc(amount, attacker_position)
@@ -2351,7 +2357,59 @@ func heal(amount: float):
current_health = min(current_health + amount, max_health)
print(name, " healed for ", amount, " HP! Health: ", current_health, "/", max_health)
func add_key(amount: int = 1):
keys += amount
print(name, " picked up ", amount, " key(s)! Total keys: ", keys)
func has_key() -> bool:
return keys > 0
func use_key():
if keys > 0:
keys -= 1
print(name, " used a key! Remaining keys: ", keys)
return true
return false
@rpc("authority", "reliable")
func _show_damage_number(amount: float, from_position: Vector2):
# Show damage number (red, using dmg_numbers.png font) above player
# Only show if damage > 0
if amount <= 0:
return
var damage_number_scene = preload("res://scenes/damage_number.tscn")
if not damage_number_scene:
return
var damage_label = damage_number_scene.instantiate()
if not damage_label:
return
# Set damage text and red color
damage_label.label = str(int(amount))
damage_label.color = Color.RED
# Calculate direction from attacker (slight upward variation)
var direction_from_attacker = (global_position - from_position).normalized()
# Add slight upward bias
direction_from_attacker = direction_from_attacker.lerp(Vector2(0, -1), 0.5).normalized()
damage_label.direction = direction_from_attacker
# Position above player's head
var game_world = get_tree().get_first_node_in_group("game_world")
if game_world:
var entities_node = game_world.get_node_or_null("Entities")
if entities_node:
entities_node.add_child(damage_label)
damage_label.global_position = global_position + Vector2(0, -16) # Above player head
else:
get_tree().current_scene.add_child(damage_label)
damage_label.global_position = global_position + Vector2(0, -16)
else:
get_tree().current_scene.add_child(damage_label)
damage_label.global_position = global_position + Vector2(0, -16)
func _sync_damage(_amount: float, attacker_position: Vector2):
# This RPC only syncs visual effects, not damage application
# (damage is already applied via rpc_take_damage)