2022-07-18 02:42:00 -04:00

49 lines
1.3 KiB
GDScript

extends Node2D
var hp = 5
var immune = false
var immune_timer = 0
onready var fish = get_node("/root/Tank/Fish")
func _ready():
# $Piranha.set_process(false)
$Wire/AnimatedSprite.frame = 0
_spawn_piranha() #delete me later
func _on_Hitbox_area_entered(area):
if area.is_in_group("Fish") and $InvulnTimer.time_left == 0:
$AnimationPlayer.play("recoil")
hp -= 1
if hp == 4:
$Wire/AnimatedSprite.frame = 0
elif hp == 3:
_spawn_piranha()
# var piranha_scene = load("res://Hazards/Piranha/Piranha.tscn")
# var piranha = piranha_scene.instance()
# get_parent().add_child(piranha)
# piranha.position = Vector2(300, -300)
elif hp > 0 and hp < 3:
$Wire/AnimatedSprite.frame = 1
elif hp < 1:
$Wire/AnimatedSprite.frame = 2
get_parent().blackout()
func _spawn_piranha():
#$AnimationPlayer.play("drop")
#yield($AnimationPlayer, "animation_finished")
var piranha_scene = load("res://Hazards/Piranha/Piranha.tscn")
var piranha = piranha_scene.instance()
# piranha.set_process(false)
get_parent().add_child(piranha)
piranha.position = Vector2(300, -300)
$TweenDrop.interpolate_property(piranha, "position:y", piranha.get_global_position().y, 600, 0.5, Tween.TRANS_BACK, Tween.EASE_IN)
$TweenDrop.start()
yield($TweenDrop, "tween_completed")
print("dropped")
# piranha.set_process(true)