2018-05-23 03:57:15 -04:00
|
|
|
extends Area2D
|
|
|
|
|
|
|
|
signal hit
|
|
|
|
|
|
|
|
export (int) var SPEED
|
|
|
|
export (int) var DAMAGE
|
|
|
|
var plasma = false
|
|
|
|
var current_pen = 0
|
2018-05-26 02:55:17 -04:00
|
|
|
var friendly_laser = true
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
func _on_Visibility_screen_exited():
|
2018-05-23 21:35:16 -04:00
|
|
|
prints("byebye laser boi")
|
|
|
|
queue_free()
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
$AnimatedSprite.play()
|
|
|
|
connect("area_entered", self, "hit")
|
|
|
|
pass
|
|
|
|
|
|
|
|
func hit(who):
|
2018-05-26 02:55:17 -04:00
|
|
|
prints(who)
|
2018-05-23 04:31:03 -04:00
|
|
|
if plasma == true:
|
|
|
|
pass
|
|
|
|
elif current_pen > 0:
|
2018-05-23 03:57:15 -04:00
|
|
|
current_pen -= 1
|
|
|
|
else:
|
|
|
|
hide()
|
|
|
|
queue_free()
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
var velocity = Vector2()
|
2018-05-26 02:55:17 -04:00
|
|
|
if friendly_laser == true:
|
|
|
|
velocity.x += 1
|
|
|
|
else:
|
|
|
|
velocity.x -= 1
|
2018-05-23 03:57:15 -04:00
|
|
|
velocity = velocity.normalized() * SPEED
|
|
|
|
position += velocity * delta
|
|
|
|
|
|
|
|
func _on_Laser_body_entered(body):
|
|
|
|
emit_signal("hit")
|
|
|
|
if plasma == false:
|
|
|
|
$CollisionShape2D.disabled = true
|
|
|
|
queue_free()
|
|
|
|
else:
|
|
|
|
var timer = null
|
|
|
|
timer = Timer.new()
|
|
|
|
timer.set_one_shot(true)
|
|
|
|
timer.set_wait_time(0.1)
|
|
|
|
timer.connect("timeout", self, "on_timeout_complete")
|
|
|
|
add_child(timer)
|
|
|
|
$CollisionShape2D.disabled = true
|
|
|
|
|
|
|
|
func on_timeout_complete():
|
|
|
|
$CollisionShape2D.disabled = false
|