mejoras en interfaz y movimento de personaje
This commit is contained in:
1 parent
7a8b03e760
commit
f0fa01607c
29 files changed
+504320
-280
No files matched your search
+28
-20
@@ -84,8 +84,9 @@ enum AttackState {
|
||||
## Recuperacion tras el golpe antes de poder iniciar otro.
|
||||
@export var attack_recovery_duration: float = 0.30
|
||||
|
||||
## Posicion inicial del area de ataque cuando el enemigo mira a la derecha.
|
||||
@export var attack_start_offset: Vector2 = Vector2(34.0, 0.0)
|
||||
## Posicion inicial del punetazo alto (a la altura de hombros).
|
||||
## Una variante con ataque bajo puede ajustar Y y su forma sin dar inmunidad al agachado.
|
||||
@export var attack_start_offset: Vector2 = Vector2(34.0, -20.0)
|
||||
|
||||
## Distancia horizontal maxima que alcanza el barrido ofensivo.
|
||||
@export var attack_reach: float = 120.0
|
||||
@@ -676,24 +677,31 @@ func _reset_attack_hitbox_position() -> void:
|
||||
|
||||
## Aplica un solo impacto por objetivo y evita golpear a traves del escenario.
|
||||
func _update_attack_damage() -> void:
|
||||
for area in attack_hitbox.get_overlapping_areas():
|
||||
var damage_target: Node = area.get_parent()
|
||||
if damage_target == null or not damage_target.has_method("take_damage"):
|
||||
continue
|
||||
|
||||
var target_id: int = damage_target.get_instance_id()
|
||||
if attack_hit_targets.has(target_id):
|
||||
continue
|
||||
|
||||
# El barrido no atraviesa paredes. El origen del empuje es el cuerpo enemigo, no su area adelantada.
|
||||
var query := PhysicsRayQueryParameters2D.create(
|
||||
global_position, (damage_target as Node2D).global_position,
|
||||
collision_mask, [get_rid()]
|
||||
)
|
||||
if not get_world_2d().direct_space_state.intersect_ray(query).is_empty():
|
||||
continue
|
||||
attack_hit_targets[target_id] = true
|
||||
damage_target.take_damage(attack_damage, global_position, attack_knockback_multiplier)
|
||||
# Solo hay un jugador por partida. Comprobar las formas con sus transformaciones
|
||||
# actuales evita usar un solapamiento de Area2D del fotograma fisico anterior.
|
||||
if not is_instance_valid(target) or not target.has_method("take_damage"):
|
||||
return
|
||||
var target_id: int = target.get_instance_id()
|
||||
if attack_hit_targets.has(target_id):
|
||||
return
|
||||
var area := target.get_node_or_null("Hurtbox") as Area2D
|
||||
if area == null or not area.monitorable or (area.collision_layer & PLAYER_HURTBOX_MASK) == 0:
|
||||
return
|
||||
var target_collision := area.get_node_or_null("CollisionShape2D") as CollisionShape2D
|
||||
if target_collision == null or target_collision.disabled or target_collision.shape == null:
|
||||
return
|
||||
if attack_collision.disabled or attack_collision.shape == null or not attack_collision.shape.collide(
|
||||
attack_collision.global_transform, target_collision.shape, target_collision.global_transform
|
||||
):
|
||||
return
|
||||
# El barrido no atraviesa paredes. El empuje sigue saliendo del cuerpo enemigo.
|
||||
var query := PhysicsRayQueryParameters2D.create(
|
||||
global_position, target_collision.global_position, collision_mask, [get_rid()]
|
||||
)
|
||||
if not get_world_2d().direct_space_state.intersect_ray(query).is_empty():
|
||||
return
|
||||
attack_hit_targets[target_id] = true
|
||||
target.call("take_damage", attack_damage, global_position, attack_knockback_multiplier)
|
||||
|
||||
|
||||
## Cancela el ataque y vacia su registro de impactos.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
size = Vector2(28, 52)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="AttackShape"]
|
||||
size = Vector2(32, 40)
|
||||
size = Vector2(32, 20)
|
||||
|
||||
[node name="Walker" type="CharacterBody2D" groups=["enemy"]]
|
||||
collision_layer = 4
|
||||
|
||||
Reference in new issue
Block a user