1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- extends HBoxContainer
- var player_labels = {}
- func _process(_delta):
- var rocks_left = $"../Rocks".get_child_count()
- if rocks_left == 0:
- var winner_name = ""
- var winner_score = 0
- for p in player_labels:
- if player_labels[p].score > winner_score:
- winner_score = player_labels[p].score
- winner_name = player_labels[p].name
- $"../Winner".set_text("THE WINNER IS:\n" + winner_name)
- $"../Winner".show()
- remotesync func increase_score(for_who):
- assert(for_who in player_labels)
- var pl = player_labels[for_who]
- pl.score += 1
- pl.label.set_text(pl.name + "\n" + str(pl.score))
- func add_player(id, new_player_name):
- var l = Label.new()
- l.set_align(Label.ALIGN_CENTER)
- l.set_text(new_player_name + "\n" + "0")
- l.set_h_size_flags(SIZE_EXPAND_FILL)
- var font = DynamicFont.new()
- font.set_size(18)
- font.set_font_data(preload("res://montserrat.otf"))
- l.add_font_override("font", font)
- add_child(l)
- player_labels[id] = { name = new_player_name, label = l, score = 0 }
- func _ready():
- $"../Winner".hide()
- set_process(true)
- func _on_exit_game_pressed():
- gamestate.end_game()
|