Arreglados los pickups
This commit is contained in:
1 parent
5c3d16951e
commit
1fbfdf3f8a
9 files changed
+41
-38
No files matched your search
+21
-28
@@ -200,7 +200,6 @@ var jumps_remaining: int = 2
|
||||
|
||||
var _speed_boost_timer: float = 0.0
|
||||
var _speed_boost_multiplier: float = 0.0
|
||||
var _original_move_speed: float = 0.0
|
||||
|
||||
var _floating_texts: Array = []
|
||||
|
||||
@@ -226,7 +225,6 @@ func _ready() -> void:
|
||||
if character_data.sprite_frames != null:
|
||||
animated_sprite.sprite_frames = character_data.sprite_frames
|
||||
|
||||
_original_move_speed = character_data.move_speed
|
||||
jumps_remaining = max_jumps
|
||||
|
||||
_setup_attack_hitboxes()
|
||||
@@ -234,7 +232,6 @@ func _ready() -> void:
|
||||
_update_animation()
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
special_charge_changed.emit(special_charge, special_max_charge)
|
||||
_connect_pickups()
|
||||
# Conecta a los enemigos que ya estén en el árbol. Si se añaden más tarde,
|
||||
# se conectarán cuando mueran mediante el grupo "enemy".
|
||||
_connect_to_enemies()
|
||||
@@ -253,7 +250,6 @@ func _physics_process(delta: float) -> void:
|
||||
_apply_gravity(delta)
|
||||
_handle_horizontal_movement(delta)
|
||||
_update_punch_damage()
|
||||
_update_speed_boost(delta)
|
||||
_update_floating_texts(delta)
|
||||
|
||||
move_and_slide()
|
||||
@@ -521,31 +517,28 @@ func _apply_special_attack(charge_used: int = special_max_charge) -> void:
|
||||
enemy.take_damage(damage, global_position)
|
||||
|
||||
|
||||
func _connect_pickups() -> void:
|
||||
for pickup in get_tree().get_nodes_in_group("pickup"):
|
||||
if is_instance_valid(pickup) and pickup.has_signal(&"picked_up"):
|
||||
pickup.picked_up.connect(_on_pickup_picked_up)
|
||||
func collect_pickup(data: PickupData) -> bool:
|
||||
if is_dead or data == null or character_data == null:
|
||||
return false
|
||||
|
||||
|
||||
func _on_pickup_picked_up(pickup: Node, data: PickupData) -> void:
|
||||
if is_dead or data == null:
|
||||
return
|
||||
if data.effect_type == "heal":
|
||||
var heal_amount: int = int(data.value)
|
||||
current_health = min(current_health + heal_amount, character_data.max_health)
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
_spawn_floating_text("+" + str(heal_amount), Color(0.2, 1.0, 0.3))
|
||||
elif data.effect_type == "speed_boost":
|
||||
_speed_boost_multiplier = data.value
|
||||
_speed_boost_timer = data.duration
|
||||
_spawn_floating_text("SPEED UP", Color(1.0, 0.8, 0.2))
|
||||
|
||||
|
||||
func _update_speed_boost(delta: float) -> void:
|
||||
if _speed_boost_timer > 0.0:
|
||||
_speed_boost_timer = max(_speed_boost_timer - delta, 0.0)
|
||||
else:
|
||||
_speed_boost_multiplier = 0.0
|
||||
match data.effect_type:
|
||||
"heal":
|
||||
var heal_amount: int = mini(int(data.value), character_data.max_health - current_health)
|
||||
if heal_amount <= 0:
|
||||
return false
|
||||
current_health += heal_amount
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
_spawn_floating_text("+" + str(heal_amount), Color(0.2, 1.0, 0.3))
|
||||
"speed_boost":
|
||||
if data.value <= 0.0 or data.duration <= 0.0:
|
||||
return false
|
||||
_speed_boost_multiplier = data.value
|
||||
_speed_boost_timer = data.duration
|
||||
_spawn_floating_text("SPEED UP", Color(1.0, 0.8, 0.2))
|
||||
_:
|
||||
push_warning("Unknown pickup effect: %s" % data.effect_type)
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _spawn_floating_text(text: String, color: Color) -> void:
|
||||
|
||||
Reference in new issue
Block a user