extends Control var roundTimer := 600.0 var minutes var seconds var scores: Array[int] = [] var scoresInitalized = false func _ready(): minutes = roundTimer / 60 seconds = fmod(roundTimer, 60) $timer.text = "%02d:%02d" % [minutes, seconds] func _process(delta): $startLabel.text = Global.HUDStartLabelText $Fatigue.value = Global.fatigue $Health.value = Global.playerHealth if Global.roundInSession == true and roundTimer >= 0: if scoresInitalized == false: scoresInitalized = true fill_scores_with_zeros(Global.connectedPlayers.size()) $startLabel.text = "" roundTimer -= delta minutes = roundTimer / 60 seconds = fmod(roundTimer, 60) $timer.text = "%02d:%02d" % [minutes, seconds] if roundTimer <= 0.0: Global.HUDStartLabelText = "GAME OVER" if Global.HUDPlayerDied: Global.HUDPlayerDied = false rpc("update_scores", Global.lastPersonToHitMe) update_scores(Global.lastPersonToHitMe) if Global.roundInSession == false: for i in range(Global.connectedPlayers.size()): if Global.connectedPlayers[i]: var objectLabel = "player" + str(i) + "Label" var numlabel = i + 1 get_node("player" + str(numlabel) + "Label").text = Global.connectedPlayers[i] + ": " + "0" @rpc("any_peer", "reliable") func update_scores(name): for i in range(Global.connectedPlayers.size()): if Global.connectedPlayers[i] == str(name): var objectLabel = "player" + str(i) + "Label" var numlabel = i + 1 var currentScore = scores[i] + 1 scores[i] += 1 get_node("player" + str(numlabel) + "Label").text = Global.connectedPlayers[i] + ": " + str(currentScore) else: print("Name ", i, " wasn't found in the list!") func fill_scores_with_zeros(num_of_players): scores.resize(num_of_players) for i in num_of_players: scores[i] = 0