Skip bf45bf404c Huge Update
Changes abound on pretty much everything.
2022-07-16 18:09:42 -04:00

51 lines
1.7 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 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
$Timer.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_Hitbox_area_exited(area: Area2D) -> void:
if area.is_in_group("Tank"):
queue_free()
#func _process(delta: float) -> void:
# if direction: