Skip 78f8174384 New Squid Scene
Added the squid.
2022-07-16 19:56:19 -04:00

52 lines
1.8 KiB
GDScript

extends RigidBody2D
export var poisoned_color : Color = Color(0,200,0,255)
var fish : Node
var direction
var friendly = false
func _ready():
fish = get_node("/root/Tank/Fish")
$AnimatedSprite.frame = choose([0,1,2])
func _on_Hitbox_area_entered(area: Area2D) -> void:
if area.is_in_group("TankFloor"):
$DissolveTimer.start()
if not friendly:
if area.is_in_group("Fish") and fish.poisoned == false and not fish.poison_mutation:
print("A poison pellet has inflicted poison on the fish.")
fish.poisoned = true
visible = false
$PoisonTimer.start()
$TweenPoison.interpolate_property(area.get_parent(), "modulate", modulate, poisoned_color, 2.0, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenPoison.start()
elif area.is_in_group("Fish") and fish.poison_mutation and fish.pellets < 10:
fish.pellets += 1
#$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/MouthInhale").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN, 0.5)
$TweenEat.interpolate_property(self, "position", position, get_node("/root/Tank/Fish/Positions/Mouth").get_global_position(), 0.5, Tween.TRANS_EXPO, Tween.EASE_IN)
$TweenEat.interpolate_property(self, "scale", scale, Vector2(0.1, 0.1), 0.5, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenEat.start()
print(get_node("/root/Tank/Fish/Positions/Mouth").get_global_position())
yield($TweenEat, "tween_completed")
queue_free()
static func choose(choices):
return choices[randi() % choices.size()]
func _on_Timer_timeout() -> void:
if fish:
print("Fish died of poison.")
fish.kill("poison")
func _on_DissolveTimer_timeout() -> void:
print(modulate.a)
$TweenDissolve.interpolate_property(self, "modulate:a", modulate.a, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_IN)
$TweenDissolve.start()
yield($TweenDissolve, "tween_completed")
queue_free()