1
Fork 0
mirror of https://github.com/Steffo99/nanogolf.git synced 2024-11-21 23:54:21 +00:00
algodist-steffo-nanogolf/scenes/game_hud.gd
2024-03-16 05:25:23 +01:00

50 lines
1.6 KiB
GDScript

extends Control
class_name GameHUD
@export var strokes_label: Label
@export var scores_panel: PanelContainer
@export var scores_container: Control
const score_scene = preload("res://scenes/player_score_label.tscn")
func _on_level_completed(_level: GolfLevel) -> void:
strokes_label.text = "0"
for child in scores_container.get_children():
child.queue_free()
scores_panel.hide()
func _on_playernode_name_changed(old: String, new: String, playernode: PlayerNode) -> void:
var instance = get_node_or_null("PlayerScoreLabel__%s" % old)
if instance != null:
instance.from_score(playernode)
instance.name = "PlayerScoreLabel__%s" % new
func _on_playernode_color_changed(old: Color, new: Color, playernode: PlayerNode) -> void:
var instance = get_node_or_null("PlayerScoreLabel__%s" % playernode.player_name)
if instance != null:
instance.from_score(playernode)
func _on_playernode_possessed(old: int, new: int, playernode: PlayerNode) -> void:
var instance = get_node_or_null("PlayerScoreLabel__%s" % playernode.player_name)
if instance != null:
instance.from_score(playernode)
func _on_playernode_score_reported(strokes: int, playernode: PlayerNode) -> void:
var score_instance = score_scene.instantiate()
score_instance.from_score(strokes, playernode)
score_instance.name = "PlayerScoreLabel__%s" % playernode.player_name
scores_container.add_child(score_instance)
scores_panel.show()
func _on_playernode_scores_changed(old: Array, new: Array, playernode: PlayerNode) -> void:
pass
func _on_strokes_changed(strokes: int) -> void:
strokes_label.text = "%s" % strokes