make the enemies use the event bus

This commit is contained in:
Martin Araneda 2022-09-01 21:59:21 -04:00
parent 1f63f5e00a
commit 011a1b8007
3 changed files with 3 additions and 12 deletions

View File

@ -1,9 +1,6 @@
extends KinematicBody2D
signal player_touched
var velocity = Vector2()
export var direction = -1
export var detect_edges = true
@ -32,7 +29,7 @@ func _physics_process(_delta: float) -> void:
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == "Player":
emit_signal("player_touched")
Event.emit_signal("player_touched", 3)
Event.emit_signal("object_updated", self.get_name(), "Walking", global_position, velocity)

View File

@ -1,9 +1,6 @@
extends KinematicBody2D
signal player_touched
export var direction = -1
export var speed = 50
export var follow_path = false
@ -82,7 +79,7 @@ func get_velocity_towards_target(delta: float) -> Vector2:
func wall_checker_collided(wall_checker: RayCast2D) -> void:
if wall_checker.get_collider().name == "Player":
emit_signal("player_touched")
Event.emit_signal("player_touched", 3)
direction *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h

View File

@ -1,9 +1,6 @@
extends KinematicBody2D
signal player_touched
onready var start_position = position
var velocity = Vector2()
export var speed = 50.0
@ -25,7 +22,7 @@ func _physics_process(delta: float) -> void:
return_to_start = true
$AnimatedSprite.play("normal")
if collision.collider.name == "Player":
emit_signal("player_touched")
Event.emit_signal("player_touched", 3)
Event.emit_signal("object_updated", self.get_name(), "Falling", global_position, velocity)
if position.y <= start_position.y: