Add winning condition

main
Olivier 'reivilibre' 2023-01-09 18:10:15 +00:00
parent c14b9cf8d2
commit cc5cb04f0f
3 changed files with 21 additions and 2 deletions

View File

@ -120,3 +120,4 @@ navpoly = SubResource( 4 )
navpoly = SubResource( 3 )
[node name="Hud" parent="." instance=ExtResource( 8 )]
needed_coins = 20

View File

@ -8,9 +8,14 @@ export var num_days = 5
export var next_level = ""
export var needed_coins = 50
func add_coin(amount: int):
coin += amount
$HudInner/Panel/LabelCoin.text = str(coin)
if coin >= needed_coins:
self._win()
var hp: int = 3
@ -46,9 +51,11 @@ func _ready():
sch.postie_times = postie_times
sch.days_on_this_level = num_days
$HudInner/Panel/LabelCoinNeed.text = "need: " + str(needed_coins)
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)
# random place to put it, but needed to get our navigation working:
func _on_TryAgainButton_pressed() -> void:

View File

@ -29,9 +29,19 @@ margin_left = 50.0
margin_top = 24.0
margin_right = 90.0
margin_bottom = 51.0
rect_pivot_offset = Vector2( 6, 23 )
custom_fonts/font = ExtResource( 1 )
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"]
position = Vector2( 31, 37 )
texture = ExtResource( 2 )
@ -43,7 +53,7 @@ margin_right = -8.0
margin_bottom = -88.0
[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"]
texture = ExtResource( 5 )
@ -58,6 +68,7 @@ texture = ExtResource( 5 )
[node name="GameOverDialogue" type="Panel" parent="HudInner"]
pause_mode = 2
visible = false
margin_left = 544.0
margin_top = 360.0
margin_right = 1064.0