-
Notifications
You must be signed in to change notification settings - Fork 2
/
Level.gd
41 lines (25 loc) · 896 Bytes
/
Level.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extends CanvasLayer
signal level_changed(level_name)
export (String) var level_name = "level"
var level_parameters := {
"clicks": 0
}
func load_level_parameters(new_level_parameters: Dictionary):
level_parameters = new_level_parameters
$ClickLabel.text = "Clicks: " + str(level_parameters.clicks)
func play_loaded_sound() -> void:
$LevelLoadedSound.play()
$ChangeSceneButton.disabled = false
func cleanup():
if $ButtonClickedSound.playing:
yield($ButtonClickedSound, "finished")
queue_free()
func set_clicks(new_click_amount: int):
level_parameters.clicks = new_click_amount
$ClickLabel.text = "Clicks: " + str(level_parameters.clicks)
func _on_ChangeSceneButton_pressed() -> void:
$ButtonClickedSound.play()
$ChangeSceneButton.disabled = true
emit_signal("level_changed", level_name)
func _on_ClickButton_pressed() -> void:
set_clicks(level_parameters.clicks + 1)