2024-01-26 19:53:36 +00:00
|
|
|
extends Node2D
|
|
|
|
|
2024-01-27 11:02:06 +00:00
|
|
|
@export_enum("angry", "neutral", "happy", "laugh") var expression
|
2024-01-26 19:53:36 +00:00
|
|
|
|
2024-01-27 11:02:06 +00:00
|
|
|
var person_controller : AudienceMember
|
2024-01-27 11:40:54 +00:00
|
|
|
var expression_map = {}
|
2024-01-27 11:02:06 +00:00
|
|
|
|
|
|
|
const expression_change_speed : float = 1.5
|
2024-01-26 19:53:36 +00:00
|
|
|
const color_transparent : Color = Color(1, 1, 1, 0)
|
|
|
|
const color_visible : Color = Color(1, 1, 1, 1)
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2024-01-27 11:40:54 +00:00
|
|
|
expression_map = {
|
|
|
|
"angry" : $Unhappy,
|
|
|
|
"neutral" : $Neutral,
|
|
|
|
"happy" : $Happy,
|
|
|
|
"laugh" : $Laugh,
|
|
|
|
}
|
|
|
|
person_controller = get_node("../../../Person")
|
2024-01-27 11:02:06 +00:00
|
|
|
expression = person_controller.expression
|
|
|
|
reset_face()
|
|
|
|
|
2024-01-26 19:53:36 +00:00
|
|
|
func _process(_delta):
|
2024-01-27 11:02:06 +00:00
|
|
|
if expression != person_controller.expression:
|
|
|
|
update_face(person_controller.expression)
|
2024-01-27 11:40:54 +00:00
|
|
|
expression = person_controller.expression
|
2024-01-27 11:02:06 +00:00
|
|
|
|
|
|
|
func reset_face():
|
|
|
|
for expr in expression_map:
|
2024-01-27 11:40:54 +00:00
|
|
|
expression_map[expr].modulate = color_transparent.lerp(color_visible, expr == expression)
|
2024-01-27 11:02:06 +00:00
|
|
|
|
|
|
|
func update_face(new_expression: String):
|
2024-01-27 12:30:02 +00:00
|
|
|
var trans_speed = expression_change_speed
|
|
|
|
if new_expression == "laugh":
|
|
|
|
trans_speed = 0
|
|
|
|
#var trans_speed = lerpf(0, expression_change_speed, new_expression != "laugh")
|
2024-01-27 11:02:06 +00:00
|
|
|
var tween = get_tree().create_tween().bind_node(self).set_parallel().set_trans(Tween.TRANS_LINEAR)
|
2024-01-27 12:30:02 +00:00
|
|
|
tween.tween_property(expression_map[expression], "modulate", color_transparent, trans_speed)
|
|
|
|
tween.tween_property(expression_map[new_expression], "modulate", color_visible, trans_speed)
|