diff --git a/ai/Enemy.gd b/ai/Enemy.gd index 72dc6b6..753ef10 100644 --- a/ai/Enemy.gd +++ b/ai/Enemy.gd @@ -8,6 +8,7 @@ var health = 5 const UP = Vector2(0, -1) var velocity = Vector2() + func get_type(): return "enemy" diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index 06b8f0e..3c279c8 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -4,6 +4,7 @@ class_name Projectile export var speed = 300 var velocity = Vector2.ZERO var energy_cost = 1 +var damage = 1 onready var Hit = get_node("Node/Hit") onready var Hit_Wall = get_node("Node/Hit Wall") @@ -17,4 +18,8 @@ func launch(wand, effect): return energy_cost func on_impact(collision): + if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy": + var c = collision.collider + print(c.health) + c.health -= damage queue_free() diff --git a/project.godot b/project.godot index 7773123..3f85285 100644 --- a/project.godot +++ b/project.godot @@ -100,6 +100,7 @@ texture={ up={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) ] } down={