Projectiles do damage

This commit is contained in:
Logan 2020-07-20 00:06:53 -05:00
parent 1e9336a11d
commit 7faf33349c
3 changed files with 7 additions and 0 deletions

View file

@ -8,6 +8,7 @@ var health = 5
const UP = Vector2(0, -1)
var velocity = Vector2()
func get_type():
return "enemy"

View file

@ -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()

View file

@ -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={