30 lines
730 B
GDScript
30 lines
730 B
GDScript
extends Node2D
|
|
|
|
signal playerDamage
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
|
|
|
|
func _on_area_2d_area_trigger_signal(effect: String, body: Node2D) -> void:
|
|
if body.name == "world-boundary":
|
|
return
|
|
if body is Player && effect == "player_hurt":
|
|
playerDamage.emit()
|
|
body.health -= 1
|
|
print(body.health)
|
|
return
|
|
print("GC sees trigger " + effect + " on " + body.name)
|
|
body.queue_free()
|
|
|
|
func bulletDamage(target: Node2D, bullet: Node2D):
|
|
print("game controller sees hit")
|
|
target.queue_free()
|
|
bullet.visible = false
|