1
Fork 0
mirror of https://github.com/Steffo99/nanogolf.git synced 2024-11-24 17:14:19 +00:00
algodist-steffo-nanogolf/scenes/game_hud.gd

50 lines
1.5 KiB
GDScript3
Raw Normal View History

2024-03-16 04:25:23 +00:00
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:
2024-03-18 05:08:31 +00:00
var instance = get_node_or_null(old)
2024-03-16 04:25:23 +00:00
if instance != null:
instance.from_score(playernode)
2024-03-18 05:08:31 +00:00
instance.name = new
2024-03-16 04:25:23 +00:00
2024-03-16 04:55:02 +00:00
func _on_playernode_color_changed(_old: Color, _new: Color, playernode: PlayerNode) -> void:
2024-03-18 05:08:31 +00:00
var instance = get_node_or_null(playernode.player_name)
2024-03-16 04:25:23 +00:00
if instance != null:
instance.from_score(playernode)
2024-03-16 04:55:02 +00:00
func _on_playernode_possessed(_old: int, _new: int, playernode: PlayerNode) -> void:
2024-03-18 05:08:31 +00:00
var instance = get_node_or_null(playernode.player_name)
2024-03-16 04:25:23 +00:00
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)
2024-03-18 05:08:31 +00:00
score_instance.name = playernode.player_name
2024-03-16 04:25:23 +00:00
scores_container.add_child(score_instance)
scores_panel.show()
2024-03-16 04:55:02 +00:00
func _on_playernode_scores_changed(_old: Array, _new: Array, _playernode: PlayerNode) -> void:
2024-03-16 04:25:23 +00:00
pass
2024-03-18 05:08:31 +00:00
func _on_playernode_putt_performed(ball: GolfBall, playernode: PlayerNode) -> void:
if playernode.is_multiplayer_authority():
strokes_label.text = "%s" % ball.strokes