2020-07-17 13:15:52 -05:00
|
|
|
extends KinematicBody2D
|
|
|
|
class_name Projectile
|
|
|
|
|
2020-07-17 15:31:11 -05:00
|
|
|
export var speed = 300
|
2020-07-17 13:15:52 -05:00
|
|
|
var velocity = Vector2.ZERO
|
2020-07-19 19:15:43 -05:00
|
|
|
var energy_cost = 1
|
2020-07-20 00:06:53 -05:00
|
|
|
var damage = 1
|
2020-07-19 17:19:31 -05:00
|
|
|
onready var Hit = get_node("Node/Hit")
|
|
|
|
onready var Hit_Wall = get_node("Node/Hit Wall")
|
2020-07-17 13:15:52 -05:00
|
|
|
|
|
|
|
func _physics_process(delta):
|
|
|
|
var collision = move_and_collide(velocity * delta)
|
|
|
|
if collision != null:
|
2020-07-17 19:18:59 -05:00
|
|
|
on_impact(collision)
|
2020-07-18 17:07:40 -05:00
|
|
|
|
2020-07-19 18:36:36 -05:00
|
|
|
func launch(wand, effect):
|
2020-07-17 15:21:22 -05:00
|
|
|
velocity = (Vector2(speed, 0)).rotated(rotation)
|
2020-07-19 19:15:43 -05:00
|
|
|
return energy_cost
|
2020-07-17 13:15:52 -05:00
|
|
|
|
2020-07-17 19:18:59 -05:00
|
|
|
func on_impact(collision):
|
2020-07-20 00:06:53 -05:00
|
|
|
if collision.collider.has_method("get_type") && collision.collider.get_type() == "enemy":
|
|
|
|
var c = collision.collider
|
|
|
|
print(c.health)
|
|
|
|
c.health -= damage
|
2020-07-17 14:10:02 -05:00
|
|
|
queue_free()
|