-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHUD.gd
77 lines (56 loc) · 1.98 KB
/
HUD.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
extends CanvasLayer
# used to tell that button is pressed
signal start_game
# when called show text for the timer duration
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()
# what happens when game ends. show game over message, then show start game message, pause a bit then show button
func show_game_over():
#show_message("")
# wait until timer counts down
#yield($MessageTimer, "timeout")
$Message.text = "Game Over :( \nTry again! Save the Sheep!"
$Message.show()
# Make a oneshot timer and wait for it to finish
yield(get_tree().create_timer(0.5), "timeout") # for adding a delay
$StartButton.show()
# when we land on moon
func show_next_stage(sheep_score):
show_message("The Sheep is Safe!")
# wait until timer counts down
yield($MessageTimer, "timeout")
$Message.text = "Save more Sheep!"
# Message to show will depend on sheep score
if(sheep_score == 1):
$LevelMessage.text = "(Next target: Let's reach 5 sheep safe!)"
elif (sheep_score == 5):
$LevelMessage.text = "(Next target: Let's reach 10 sheep safe!)"
elif (sheep_score == 10):
$LevelMessage.text = "(Next target: Let's reach 15 sheep safe!)"
elif (sheep_score == 15):
$LevelMessage.text = "(Next target: Let's reach 20 sheep safe!)"
elif (sheep_score == 20):
$LevelMessage.text = "(Next target: Let's reach 25 sheep safe!)"
elif (sheep_score >= 25):
$LevelMessage.text = "All sheep are safe now! Celebrate!"
$Message.show()
$LevelMessage.show()
# Make a oneshot timer and wait for it to finish
yield(get_tree().create_timer(1), "timeout") # for adding a delay
$StartButton.show()
func update_score(score):
$ScoreLabel.text = str(score)
func update_sheep_score(score):
$SheepScore.text = str(score)
# when button is pressed hide the button and emit the signal
func _on_StartButton_pressed():
$StartButton.hide()
emit_signal("start_game")
pass
# hide the message label on timeout
func _on_MessageTimer_timeout():
$Message.hide()
$LevelMessage.hide()
pass