Add winning condition
This commit is contained in:
parent
c14b9cf8d2
commit
cc5cb04f0f
@ -120,3 +120,4 @@ navpoly = SubResource( 4 )
|
|||||||
navpoly = SubResource( 3 )
|
navpoly = SubResource( 3 )
|
||||||
|
|
||||||
[node name="Hud" parent="." instance=ExtResource( 8 )]
|
[node name="Hud" parent="." instance=ExtResource( 8 )]
|
||||||
|
needed_coins = 20
|
||||||
|
@ -8,9 +8,14 @@ export var num_days = 5
|
|||||||
|
|
||||||
export var next_level = ""
|
export var next_level = ""
|
||||||
|
|
||||||
|
export var needed_coins = 50
|
||||||
|
|
||||||
func add_coin(amount: int):
|
func add_coin(amount: int):
|
||||||
coin += amount
|
coin += amount
|
||||||
$HudInner/Panel/LabelCoin.text = str(coin)
|
$HudInner/Panel/LabelCoin.text = str(coin)
|
||||||
|
|
||||||
|
if coin >= needed_coins:
|
||||||
|
self._win()
|
||||||
|
|
||||||
var hp: int = 3
|
var hp: int = 3
|
||||||
|
|
||||||
@ -46,9 +51,11 @@ func _ready():
|
|||||||
sch.postie_times = postie_times
|
sch.postie_times = postie_times
|
||||||
sch.days_on_this_level = num_days
|
sch.days_on_this_level = num_days
|
||||||
|
|
||||||
|
$HudInner/Panel/LabelCoinNeed.text = "need: " + str(needed_coins)
|
||||||
|
|
||||||
var w2d: World2D = get_world_2d()
|
var w2d: World2D = get_world_2d()
|
||||||
# random place to put it, but needed to get our navigation working:
|
|
||||||
Navigation2DServer.map_set_edge_connection_margin(w2d.navigation_map, 10.0)
|
Navigation2DServer.map_set_edge_connection_margin(w2d.navigation_map, 10.0)
|
||||||
|
# random place to put it, but needed to get our navigation working:
|
||||||
|
|
||||||
|
|
||||||
func _on_TryAgainButton_pressed() -> void:
|
func _on_TryAgainButton_pressed() -> void:
|
||||||
|
13
ui/Hud.tscn
13
ui/Hud.tscn
@ -29,9 +29,19 @@ margin_left = 50.0
|
|||||||
margin_top = 24.0
|
margin_top = 24.0
|
||||||
margin_right = 90.0
|
margin_right = 90.0
|
||||||
margin_bottom = 51.0
|
margin_bottom = 51.0
|
||||||
|
rect_pivot_offset = Vector2( 6, 23 )
|
||||||
custom_fonts/font = ExtResource( 1 )
|
custom_fonts/font = ExtResource( 1 )
|
||||||
text = "0"
|
text = "0"
|
||||||
|
|
||||||
|
[node name="LabelCoinNeed" type="Label" parent="HudInner/Panel"]
|
||||||
|
margin_left = 21.0
|
||||||
|
margin_top = 53.0
|
||||||
|
margin_right = 61.0
|
||||||
|
margin_bottom = 80.0
|
||||||
|
rect_pivot_offset = Vector2( 6, 23 )
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "need: 0"
|
||||||
|
|
||||||
[node name="Coin" type="Sprite" parent="HudInner/Panel"]
|
[node name="Coin" type="Sprite" parent="HudInner/Panel"]
|
||||||
position = Vector2( 31, 37 )
|
position = Vector2( 31, 37 )
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
@ -43,7 +53,7 @@ margin_right = -8.0
|
|||||||
margin_bottom = -88.0
|
margin_bottom = -88.0
|
||||||
|
|
||||||
[node name="HpBar" type="Node2D" parent="HudInner/Panel"]
|
[node name="HpBar" type="Node2D" parent="HudInner/Panel"]
|
||||||
position = Vector2( 31, 69 )
|
position = Vector2( 31, 106 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="HudInner/Panel/HpBar"]
|
[node name="Sprite" type="Sprite" parent="HudInner/Panel/HpBar"]
|
||||||
texture = ExtResource( 5 )
|
texture = ExtResource( 5 )
|
||||||
@ -58,6 +68,7 @@ texture = ExtResource( 5 )
|
|||||||
|
|
||||||
[node name="GameOverDialogue" type="Panel" parent="HudInner"]
|
[node name="GameOverDialogue" type="Panel" parent="HudInner"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
|
visible = false
|
||||||
margin_left = 544.0
|
margin_left = 544.0
|
||||||
margin_top = 360.0
|
margin_top = 360.0
|
||||||
margin_right = 1064.0
|
margin_right = 1064.0
|
||||||
|
Loading…
Reference in New Issue
Block a user