This repository has been archived on 2022-01-09. You can view files and clone it, but cannot push or open issues/pull-requests.
liblast/Game/Assets/HUD/HUD.gd

52 lines
1.6 KiB
GDScript

extends Control
@onready var main = get_tree().get_root().get_node("Main")
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func update_scoretab():
$ScoreTable/VBoxContainer/ScoreTab.text = ''
var scores = []
for i in main.player_list.players.keys():
scores.append(main.player_list.get(i).score)
scores.sort()
scores.reverse()
for i in scores:
for j in main.player_list.players.keys():
if main.player_list.get(j).score == i:
$ScoreTable/VBoxContainer/ScoreTab.text += str(i) + " - " + main.player_list.get(j).name + "\n"
func scoretab(show := true):
if show:
update_scoretab()
$ScoreTable.show()
else:
$ScoreTable.hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
# if main.local_player == null: # player is dead ATM
# print("local_player is null; PID is ", get_tree().multiplayer.get_multiplayer_unique_id(),"; respawn queue: ", main.respawn_queue)
if not get_tree().multiplayer.has_multiplayer_peer(): # don't do anything if we're offline
return
if main.spawn_queue.has(get_tree().multiplayer.get_unique_id()):
var countdown = main.spawn_queue[get_tree().multiplayer.get_unique_id()] - main.uptime
# countdown = round(countdown * 10) / 10
$RespawnCountdown.text = "RESPAWNING IN " + str("%1.2f" % countdown) + " SECONDS..."
$RespawnCountdown.visible = true
else:
$RespawnCountdown.visible = false
if $ScoreTable.visible: # update the scores every frame when player is watching the score table
update_scoretab()