fishtank/src/NPCs/ooze.gd

39 lines
923 B
GDScript3
Raw Normal View History

2024-06-09 15:51:43 +00:00
extends KinematicBody2D
2024-07-02 21:32:18 +00:00
onready var immunity = 500
2024-06-09 15:51:43 +00:00
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
func _physics_process(_delta):
2024-07-02 21:32:18 +00:00
if immunity > 0:
immunity = immunity - 1
2024-06-09 15:51:43 +00:00
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
2024-06-09 17:22:49 +00:00
func _on_Hurtbox_area_entered(_area):
2024-07-02 21:32:18 +00:00
if immunity == 0:
$Hurtbox/death.play()
2024-07-02 11:25:34 +00:00
func _on_death_finished():
2024-07-02 21:32:18 +00:00
var smallooze = load("res://NPCs/smallooze.tscn")
var instance1 = smallooze.instance()
var instance2 = smallooze.instance()
instance1.position = position
instance2.position = position
get_parent().add_child(instance1)
get_parent().add_child(instance2)
queue_free()
func _on_Hitbox_area_entered(_area):
yield(get_tree().create_timer(2.0),"timeout")
var bigooze = load("res://NPCs/big_ooze.tscn")
var instance = bigooze.instance()
instance.position = position
get_parent().add_child(instance)
2024-06-09 17:22:49 +00:00
queue_free()