57 lines
1.4 KiB
GDScript
57 lines
1.4 KiB
GDScript
class_name HUD extends Control
|
|
|
|
@export var icon: TextureRect
|
|
@export var progress_bar: ProgressBar
|
|
|
|
|
|
@export var serverd_label: Label
|
|
@export var round_customer: Label
|
|
|
|
@export var icon_sprites:Array[CompressedTexture2D]
|
|
|
|
var BG_color:Color
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
Global.change_customer_count.connect(on_costomer_served)
|
|
Global.change_social_score.connect(on_social_score_changed)
|
|
|
|
var style_fill: StyleBoxFlat = progress_bar.get_theme_stylebox("fill")
|
|
BG_color = style_fill.bg_color
|
|
|
|
|
|
func on_costomer_served()->void:
|
|
serverd_label.text = str(Global.get_served_customer())
|
|
|
|
func on_social_score_changed(new_score:int)->void:
|
|
update_social_score(new_score)
|
|
|
|
|
|
func set_round_customer_count(value:int)->void:
|
|
round_customer.text = "/" +str(value)
|
|
|
|
func set_served_customer_label_for_round()->void:
|
|
serverd_label.text = "0"
|
|
|
|
func update_social_score(value:int)->void:
|
|
progress_bar.value = value
|
|
if progress_bar.value < 35:
|
|
icon.texture = icon_sprites[0]
|
|
await change_color_smooth(Color.RED)
|
|
|
|
elif progress_bar.value < 65:
|
|
icon.texture = icon_sprites[1]
|
|
await change_color_smooth(Color.CORAL)
|
|
|
|
|
|
else:
|
|
icon.texture = icon_sprites[2]
|
|
await change_color_smooth(Color.GREEN)
|
|
|
|
|
|
func change_color_smooth(new_color:Color)->void:
|
|
var tewen = create_tween()
|
|
tewen.tween_property(progress_bar.get_theme_stylebox("fill"),"bg_color",new_color,1.0)
|
|
await tewen.finished
|
|
|