Fronter/RectangleBoss.gd

142 lines
3.1 KiB
GDScript

extends Area2D
signal dead
signal flash
export (PackedScene) var Laser
#### MAYBE ADD A HEALTH BAR TO MAIN ITSELF ####
#var health = 4000
# DEFAULT:
var health = 20000
var hit_timer = 1000
var health_multi = 1
var move_down = true
var small_move_down = true
var speed_multiplier = 3
var flashed = false
func _ready():
connect("area_entered", self, "hit")
pass
func hit(who):
health -= 3/health_multi
if health > 1500:
$Inside/InsideBadSprite.frame = 1
hit_timer = 0
else:
$Inside/InsideBadSprite.frame = 2
updateOutsideSprite()
if get_tree().is_network_server():
rpc("bossHealth", health)
func _process(delta):
# Entering view
if position.x > 0:
position.x -= delta*((100+(position.x))/20)
#### BIG WOBBLE ####
if position.y > 4:
move_down = false
if position.y <= -4:
move_down = true
if abs(position.y) > 4:
speed_multiplier = 1
elif abs(position.y) > 3:
speed_multiplier = 1
elif abs(position.y) > 2:
speed_multiplier = 2
elif abs(position.y) <= 2:
speed_multiplier = 3
if move_down:
if health > 1000:
position.y += delta*speed_multiplier
else:
if health > 1000:
position.y -= delta*speed_multiplier
if health <= 0 && $BigBadSprite.position.x < 5000:
$BigBadSprite.position.x += delta*75
#### SMALL WOBBLE ####
if $Inside/InsideBadSprite.position.y > 1200:
small_move_down = false
if $Inside/InsideBadSprite.position.y <= 1182:
small_move_down = true
if small_move_down:
$Inside/InsideBadSprite.position.y += delta*6
else:
$Inside/InsideBadSprite.position.y -= delta*6
#### DOES LOW HEALTH RELEASE THE INSIDE OR NO HEALTH? ####
if health <= 0 && !flashed:
emit_signal("flash")
emit_signal("dead", 1000)
prints("flash")
flashed = true
#queue_free()
if hit_timer < 0.15:
hit_timer += delta
elif hit_timer < 0.25:
hit_timer += delta
else:
if health > 1500:
$Inside/InsideBadSprite.frame = 0
var health_bar = Vector2(((health * 6) - 157), -273)
#$Line2D.set_point_position( 1, health_bar )
func _on_Inside_area_entered(area):
health -= 15/health_multi
updateOutsideSprite()
if health > 1500:
$Inside/InsideBadSprite.frame = 1
hit_timer = 0
else:
$Inside/InsideBadSprite.frame = 2
if get_tree().is_network_server():
rpc("bossHealth", health)
else:
pass
func updateOutsideSprite():
if health > 18000:
$BigBadSprite.frame = 0
elif health > 16000:
$BigBadSprite.frame = 1
elif health > 14000:
$BigBadSprite.frame = 2
elif health > 12000:
$BigBadSprite.frame = 3
elif health > 10000:
$BigBadSprite.frame = 4
elif health > 9000:
$BigBadSprite.frame = 5
elif health > 8000:
$BigBadSprite.frame = 6
elif health > 7000:
$BigBadSprite.frame = 7
elif health > 6000:
$BigBadSprite.frame = 8
elif health > 5000:
$BigBadSprite.frame = 9
elif health > 4000:
$BigBadSprite.frame = 10
elif health > 3000:
$BigBadSprite.frame = 11
elif health > 2000:
$BigBadSprite.frame = 12
elif health > 1500:
$BigBadSprite.frame = 13
$Inside/InsideBadSprite.frame = 2
elif health <= 0:
$BigBadSprite.frame = 14
slave func bossHealth(host_health):
health = host_health