2024-01-26 21:10:03 +00:00
|
|
|
extends Sprite2D
|
|
|
|
|
|
|
|
@export var head : Node2D
|
|
|
|
@export var face : Node2D
|
2024-01-27 14:50:20 +00:00
|
|
|
@export var mood : float = 0.0
|
2024-01-26 21:10:03 +00:00
|
|
|
|
|
|
|
var known_faces : Array[String] = [
|
2024-01-27 14:50:20 +00:00
|
|
|
"res://scenes/faces/face_curly.tscn",
|
|
|
|
"res://scenes/faces/face_moritz.tscn",
|
|
|
|
"res://scenes/faces/face_ronald.tscn",
|
|
|
|
# Add more scenes as needed
|
2024-01-26 21:10:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2024-01-27 14:50:20 +00:00
|
|
|
pass # Replace with function body.
|
|
|
|
if face == null:
|
|
|
|
set_random_face()
|
2024-01-26 21:10:03 +00:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(_delta):
|
2024-01-27 14:50:20 +00:00
|
|
|
if mood < -9.9:
|
|
|
|
throw_bottle()
|
2024-01-26 21:10:03 +00:00
|
|
|
|
|
|
|
func set_random_face():
|
2024-01-27 14:50:20 +00:00
|
|
|
var face_res = load(known_faces[randi() % known_faces.size()])
|
|
|
|
face = face_res.instantiate()
|
|
|
|
head.add_child(face)
|
|
|
|
|
|
|
|
func throw_bottle():
|
|
|
|
mood += 2.0
|
|
|
|
|
|
|
|
var bottle_scene = preload("res://scenes/objects/bottle.tscn")
|
|
|
|
var bottle = bottle_scene.instantiate()
|
|
|
|
|
|
|
|
add_child(bottle);
|
|
|
|
|
|
|
|
|
|
|
|
func _on_debug_timer_timeout():
|
|
|
|
mood -= 1
|