Run out when there's no time
This commit is contained in:
parent
78b7015eea
commit
c14b9cf8d2
10
ui/Hud.gd
10
ui/Hud.gd
@ -14,9 +14,11 @@ func add_coin(amount: int):
|
||||
|
||||
var hp: int = 3
|
||||
|
||||
func _lose():
|
||||
func _lose(due_to_slugs: bool):
|
||||
get_tree().paused = true
|
||||
$HudInner/GameOverDialogue.visible = true
|
||||
$HudInner/GameOverDialogue/SlugSorrowLabel.visible = due_to_slugs
|
||||
$HudInner/GameOverDialogue/NoTimeLabel.visible = not due_to_slugs
|
||||
return
|
||||
|
||||
func _win():
|
||||
@ -25,7 +27,7 @@ func _win():
|
||||
func remove_hp():
|
||||
if hp == 0:
|
||||
# Lose game
|
||||
self._lose()
|
||||
self._lose(true)
|
||||
return
|
||||
|
||||
hp -= 1
|
||||
@ -53,3 +55,7 @@ func _on_TryAgainButton_pressed() -> void:
|
||||
# restart the level
|
||||
print("reload ", get_tree().reload_current_scene())
|
||||
get_tree().paused = false
|
||||
|
||||
|
||||
func _on_Scheduler_ran_out_of_time() -> void:
|
||||
self._lose(false)
|
||||
|
29
ui/Hud.tscn
29
ui/Hud.tscn
@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://ui/normal_font.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://ui/coin.png" type="Texture" id=2]
|
||||
[ext_resource path="res://ui/Hud.gd" type="Script" id=3]
|
||||
[ext_resource path="res://ui/Scheduler.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://ui/hp.png" type="Texture" id=5]
|
||||
[ext_resource path="res://ui/normal_theme.tres" type="Theme" id=6]
|
||||
|
||||
[node name="Hud" type="Node2D"]
|
||||
z_index = 50
|
||||
@ -59,23 +60,33 @@ texture = ExtResource( 5 )
|
||||
pause_mode = 2
|
||||
margin_left = 544.0
|
||||
margin_top = 360.0
|
||||
margin_right = 901.0
|
||||
margin_bottom = 480.0
|
||||
margin_right = 1064.0
|
||||
margin_bottom = 496.0
|
||||
theme = ExtResource( 6 )
|
||||
|
||||
[node name="SlugSorrowLabel" type="Label" parent="HudInner/GameOverDialogue"]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 349.0
|
||||
margin_bottom = 84.0
|
||||
text = "Those pesky slugs may have gotten the better of you.
|
||||
margin_bottom = 40.0
|
||||
theme = ExtResource( 6 )
|
||||
text = "Those pesky slugs may have gotten the better of you."
|
||||
|
||||
Try again?"
|
||||
[node name="NoTimeLabel" type="Label" parent="HudInner/GameOverDialogue"]
|
||||
margin_left = 8.0
|
||||
margin_top = 40.0
|
||||
margin_right = 349.0
|
||||
margin_bottom = 72.0
|
||||
theme = ExtResource( 6 )
|
||||
text = "Out of time."
|
||||
|
||||
[node name="TryAgainButton" type="Button" parent="HudInner/GameOverDialogue"]
|
||||
margin_left = 136.0
|
||||
margin_left = 208.0
|
||||
margin_top = 96.0
|
||||
margin_right = 204.0
|
||||
margin_bottom = 116.0
|
||||
margin_right = 306.0
|
||||
margin_bottom = 129.0
|
||||
theme = ExtResource( 6 )
|
||||
text = "Try again"
|
||||
|
||||
[connection signal="ran_out_of_time" from="HudInner/Panel/Scheduler" to="." method="_on_Scheduler_ran_out_of_time"]
|
||||
[connection signal="pressed" from="HudInner/GameOverDialogue/TryAgainButton" to="." method="_on_TryAgainButton_pressed"]
|
||||
|
@ -32,10 +32,14 @@ var postie_length = .3
|
||||
var day_num = 0
|
||||
var time_of_day = 0.0
|
||||
|
||||
signal ran_out_of_time
|
||||
|
||||
func _start_schedule():
|
||||
# schedule all events for the day...
|
||||
for _day in range(days_on_this_level):
|
||||
for day in range(days_on_this_level):
|
||||
var days_left = days_on_this_level - day
|
||||
$Calendar/LabelDays.text = "|".repeat(days_left)
|
||||
|
||||
var parent = find_parent("Level*").get_node("World/YSort")
|
||||
for postie_time in postie_times:
|
||||
# 5s early so the postie has time to drive there.
|
||||
@ -43,6 +47,13 @@ func _start_schedule():
|
||||
|
||||
$Timer.start(1 / DAY_PER_SEC)
|
||||
yield($Timer, "timeout")
|
||||
|
||||
$Calendar/LabelDays.text = "end..."
|
||||
|
||||
$Timer.start(0.01 / DAY_PER_SEC)
|
||||
yield($Timer, "timeout")
|
||||
# Lose due to no time
|
||||
emit_signal("ran_out_of_time")
|
||||
|
||||
|
||||
func _postie_in(parent: Node2D, time: float, idling_time: float):
|
||||
|
@ -17,6 +17,20 @@ position = Vector2( 139, 119 )
|
||||
texture = ExtResource( 1 )
|
||||
offset = Vector2( -91, -87 )
|
||||
|
||||
[node name="LabelDays" type="Label" parent="Calendar"]
|
||||
margin_left = -139.0
|
||||
margin_top = -93.0
|
||||
margin_right = -45.0
|
||||
margin_bottom = -66.0
|
||||
rect_pivot_offset = Vector2( 139, 53 )
|
||||
theme = ExtResource( 3 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
text = "out"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_editor_description_": "temporary day representation for the calendar..."
|
||||
}
|
||||
|
||||
[node name="LabelCalendar" type="Label" parent="."]
|
||||
margin_top = 66.0
|
||||
margin_right = 94.0
|
||||
|
Loading…
Reference in New Issue
Block a user