-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.gd
54 lines (40 loc) · 1.66 KB
/
GUI.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
42
43
44
45
46
47
48
49
50
51
52
53
54
extends MarginContainer
onready var player = get_tree().get_root().get_node("World/Navigation2D/Human")
onready var scorekeeper = get_tree().get_root().get_node("World/ScoreKeeper")
func _input(event):
if event.is_action_pressed("menu"):
if get_tree().paused:
$CanvasLayer/PauseMenu.visible = false
get_tree().paused = false
else:
$CanvasLayer/PauseMenu.visible = true
get_tree().paused = true
func _ready():
get_node("CanvasLayer/LifeBar").max_value = player.HEALTH
get_node("CanvasLayer/LifeBar").value = player.current_health
get_node("CanvasLayer/VBoxContainer2/HBoxContainer/WoodAmount").text = str(player.wood)
func _on_Human_health_changed():
get_node("CanvasLayer/LifeBar").value = player.current_health
func _on_Human_wood_changed():
get_node("CanvasLayer/VBoxContainer2/HBoxContainer/WoodAmount").text = str(player.wood)
func _on_Restart_pressed():
$CanvasLayer/PauseMenu.visible = false
get_tree().paused = false
get_tree().reload_current_scene()
func _on_ExitToDesktop_pressed():
get_tree().quit()
func _on_ScoreKeeper_score_changed():
get_node("CanvasLayer/VBoxContainer3/ScoreAmount").text = str(scorekeeper.score)
func _on_ScoreKeeper_game_lost():
get_tree().paused = true
get_node("CanvasLayer/VBoxContainer3/ScoreAmount").text = "0"
$CanvasLayer/PauseMenu.visible = true
$CanvasLayer/PauseMenu/Paused.visible = false
$CanvasLayer/PauseMenu/GameOver.visible = true
func _on_ScoreKeeper_game_won():
get_tree().paused = true
$CanvasLayer/PauseMenu.visible = true
$CanvasLayer/PauseMenu/Paused.visible = false
$CanvasLayer/PauseMenu/GameWon.visible = true
func _on_ExitToMainMenu_pressed():
get_tree().change_scene("res://MainMenu.tscn")