2018-05-29 00:08:30 -04:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Sage Vaillancourt, sagev9000@gmail.com
|
|
|
|
#
|
|
|
|
# This file is part of Fronter.
|
|
|
|
#
|
|
|
|
# Fronter is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Fronter is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Fronter. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2018-05-23 03:57:15 -04:00
|
|
|
extends Area2D
|
|
|
|
|
|
|
|
signal hit
|
|
|
|
|
2018-06-03 11:11:27 -04:00
|
|
|
const DEFAULT_DAMAGE = 10
|
|
|
|
|
2018-05-23 03:57:15 -04:00
|
|
|
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-06-03 11:11:27 -04:00
|
|
|
var damage = DEFAULT_DAMAGE
|
2018-06-05 16:31:55 -04:00
|
|
|
var boss = false
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
$AnimatedSprite.play()
|
|
|
|
connect("area_entered", self, "hit")
|
|
|
|
pass
|
|
|
|
|
|
|
|
func hit(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
|
2018-05-29 02:51:40 -04:00
|
|
|
|
|
|
|
if position.x > 2000:
|
|
|
|
queue_free()
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
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
|