feat: Coins in level selection, retry checkpoint fix, coin hud

This commit is contained in:
Jakob Feldmann 2024-02-01 14:59:56 +01:00
parent b01f4ed027
commit 5ffc359cba
9 changed files with 139 additions and 58 deletions

View File

@ -1,11 +1,5 @@
extends AudibleButton
onready var level_state := get_tree().root.get_child(4).get_node("%LevelState")
func _ready() -> void:
if !GlobalState.get_savepoint(level_state.level_name):
visible = false
func _on_button_up() -> void:
get_tree().paused = false
get_tree().reload_current_scene()

View File

@ -36,9 +36,9 @@ func _zoom_timer() -> void:
func update_interface() -> void:
var wallet = GlobalState.gsr.wallet
var wallet: int = 0
if level_state != null:
wallet += level_state.currency
wallet = level_state.check_balance()
currency.text = "Orbs: %s" % wallet
currency.text = "savings: %s" % wallet

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=1]
[ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=2]
@ -55,6 +55,13 @@ tracks/0/keys = {
"values": [ Color( 0, 0, 0, 0 ), Color( 1, 0, 0, 0.117647 ) ]
}
[sub_resource type="DynamicFontData" id=14]
font_path = "res://assets/ui/fonts/Kenney Thick.ttf"
[sub_resource type="DynamicFont" id=15]
size = 12
font_data = SubResource( 14 )
[node name="HUD" type="Control"]
pause_mode = 1
anchor_right = 1.0
@ -116,11 +123,11 @@ anims/Redlight = SubResource( 2 )
[node name="Currency" type="Label" parent="."]
unique_name_in_owner = true
visible = false
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 9.0
margin_top = -21.0
margin_right = 253.0
rect_scale = Vector2( 0.590909, 0.627907 )
custom_fonts/font = SubResource( 15 )
text = "Orbs: 100000000000000000"

View File

@ -61,7 +61,10 @@ func set_paused(value: bool) -> void:
pause_overlay.visible = value
if value == true:
$"%Continue".grab_focus()
if !GlobalState.get_savepoint(level_state.level_name):
$"%RetryCheckpoint".visible = false
else:
$"%RetryCheckpoint".visible = true
func _on_Controls_button_up() -> void:
$ControlsMenu.visible = true

View File

@ -866,11 +866,6 @@ anchor_bottom = 1.0
texture = SubResource( 14 )
expand = true
[node name="Title" type="Label" parent="PauseOverlay"]
margin_right = 170.0
margin_bottom = 45.0
text = "Blobby, The"
[node name="Panel" type="Panel" parent="PauseOverlay"]
anchor_left = 0.5
anchor_top = 0.5
@ -924,6 +919,7 @@ text = "Audio"
script = ExtResource( 23 )
[node name="RetryCheckpoint" parent="PauseOverlay/Panel/VBoxContainer" instance=ExtResource( 4 )]
unique_name_in_owner = true
margin_top = 126.0
margin_right = 222.0
margin_bottom = 165.0
@ -961,12 +957,29 @@ theme = ExtResource( 2 )
custom_fonts/font = SubResource( 9 )
text = "Paused"
[node name="SwayingGrassCheckbox" type="CheckBox" parent="PauseOverlay"]
[node name="MarginContainer2" type="MarginContainer" parent="PauseOverlay"]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -151.0
margin_top = -36.0
margin_right = 161.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="SwayingGrassCheckbox" type="CheckBox" parent="PauseOverlay/MarginContainer2"]
unique_name_in_owner = true
margin_left = 16.0
margin_top = 331.0
margin_right = 284.0
margin_bottom = 355.0
margin_right = 312.0
margin_bottom = 36.0
grow_horizontal = 2
grow_vertical = 2
focus_neighbour_left = NodePath("../../Panel/VBoxContainer/Continue")
focus_neighbour_top = NodePath("../../Panel/VBoxContainer/Continue")
focus_neighbour_right = NodePath("../../Panel/VBoxContainer/Continue")
focus_neighbour_bottom = NodePath("../../Panel/VBoxContainer/Continue")
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 2 )
custom_colors/font_color_disabled = Color( 1, 1, 1, 1 )
custom_colors/font_color_focus = Color( 1, 1, 1, 1 )
@ -976,7 +989,14 @@ custom_colors/font_color_hover = Color( 1, 1, 1, 1 )
custom_colors/font_color_pressed = Color( 1, 1, 1, 1 )
text = "fancy swaying grass
( diasabling can fix browser performance)"
flat = true
clip_text = true
align = 1
icon_align = 1
script = ExtResource( 32 )
__meta__ = {
"_edit_use_anchors_": true
}
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 24 )
@ -998,4 +1018,3 @@ volume_db = -10.0
[connection signal="button_up" from="PauseOverlay/Panel/VBoxContainer/Continue" to="PauseOverlay/Panel/VBoxContainer/Continue" method="_on_button_up"]
[connection signal="button_up" from="PauseOverlay/Panel/VBoxContainer/Controls" to="." method="_on_Controls_button_up"]
[connection signal="button_up" from="PauseOverlay/Panel/VBoxContainer/Audio" to="." method="open_audio_menu"]
[connection signal="toggled" from="PauseOverlay/SwayingGrassCheckbox" to="." method="_on_SwayingGrassCheckbox_toggled"]

View File

@ -0,0 +1,14 @@
extends Control
onready var proto_coin := get_parent().get_parent().get_parent().get_node("ProtoCoin3DSprite")
var last_draw_time := 0
var coin_3D_fps := 30
func _physics_process(delta: float) -> void:
if !visible || proto_coin == null:
return
if last_draw_time <= 0:
$CoinTexture.texture = proto_coin.texture
last_draw_time = 1/coin_3D_fps
else:
last_draw_time -= delta

View File

@ -3,11 +3,29 @@ extends VBoxContainer
func initialize_with_progress(levelFullName: String) -> void:
if !GlobalState.get_progress().has(levelFullName):
return
if !GlobalState.get_progress()[levelFullName].has("froggies"):
return
var froggies : Dictionary = GlobalState.get_progress()[levelFullName]["froggies"]
for key in froggies.keys():
register_froggy(int(key), froggies[key])
if GlobalState.get_progress()[levelFullName].has("froggies"):
var froggies : Dictionary = GlobalState.get_progress()[levelFullName]["froggies"]
for key in froggies.keys():
register_froggy(int(key), froggies[key])
var collectibles: Dictionary = GlobalState.get_savestate(levelFullName)
var coin_number: int = 0
var coin_collected_number: int = 0
for key in collectibles.keys():
if key.to_lower().find("coin") != -1:
coin_number += 1
if collectibles[key]["was_collected"] == true:
coin_collected_number += 1
if GlobalState.get_savepoint(levelFullName) != Vector2() \
&& !GlobalState.get_level_completed(levelFullName):
$CollectedCoins.visible = true
$CollectedCoins/Label.text = "Checkpoint Reached"
elif coin_number > 0:
$CollectedCoins.visible = true
$CollectedCoins/Label.text = str(coin_collected_number) + " of " + str(coin_number) + " Coins "
if coin_collected_number == coin_number:
$CollectedCoins/CoinTexture.visible = true
var level_time : float = GlobalState.get_level_time(levelFullName)
if(GlobalState.get_level_completed(levelFullName)):

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://assets/ui/froggy-freed-ui.png" type="Texture" id=1]
[ext_resource path="res://assets/ui/froggy-imprisoned-ui.png" type="Texture" id=2]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/LevelCheckBox.gd" type="Script" id=3]
[ext_resource path="res://src/UserInterface/Buttons/AudibleCheckbox.gd" type="Script" id=4]
[ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=5]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/CollectedCoins.gd" type="Script" id=6]
[sub_resource type="DynamicFontData" id=12]
font_path = "res://assets/ui/fonts/Kenney Thick.ttf"
@ -15,6 +16,14 @@ extra_spacing_top = 4
extra_spacing_bottom = 4
font_data = SubResource( 12 )
[sub_resource type="DynamicFontData" id=15]
font_path = "res://assets/ui/fonts/Kenney Thick.ttf"
[sub_resource type="DynamicFont" id=16]
size = 6
extra_spacing_top = 1
font_data = SubResource( 15 )
[sub_resource type="DynamicFont" id=13]
size = 6
extra_spacing_top = 4
@ -33,21 +42,50 @@ script = ExtResource( 3 )
[node name="CheckBox" type="CheckBox" parent="."]
margin_right = 126.0
margin_bottom = 17.0
grow_horizontal = 0
grow_vertical = 0
custom_fonts/font = SubResource( 14 )
text = "This is a level "
align = 1
icon_align = 1
expand_icon = true
script = ExtResource( 4 )
[node name="FreedFroggy1" type="TextureRect" parent="."]
[node name="CollectedCoins" type="HBoxContainer" parent="."]
unique_name_in_owner = true
visible = false
margin_top = 21.0
margin_right = 126.0
margin_bottom = 40.0
margin_bottom = 48.0
rect_min_size = Vector2( 0, 10 )
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 6 )
[node name="CoinTexture" type="TextureRect" parent="CollectedCoins"]
visible = false
margin_right = 39.0
margin_bottom = 11.0
grow_horizontal = 0
grow_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="CollectedCoins"]
margin_right = 126.0
margin_bottom = 27.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 5 )
custom_colors/font_color = Color( 0.717647, 0.717647, 0.717647, 1 )
custom_fonts/font = SubResource( 16 )
text = "3 of 3 Coins "
align = 1
valign = 1
[node name="FreedFroggy1" type="TextureRect" parent="."]
unique_name_in_owner = true
visible = false
margin_top = 35.0
margin_right = 126.0
margin_bottom = 54.0
grow_horizontal = 2
grow_vertical = 2
focus_mode = 2
@ -165,15 +203,15 @@ texture = ExtResource( 2 )
[node name="LevelTime" type="Label" parent="."]
unique_name_in_owner = true
visible = false
margin_top = 21.0
margin_top = 37.0
margin_right = 126.0
margin_bottom = 32.0
margin_bottom = 48.0
focus_mode = 2
custom_colors/font_color = Color( 0.717647, 0.717647, 0.717647, 1 )
custom_fonts/font = SubResource( 13 )
text = "Time: 10 sec"
align = 1
autowrap = true
valign = 1
[node name="HSeparator" type="HSeparator" parent="."]
margin_top = 21.0

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=20 format=2]
[ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/UserInterface/Titel.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/BenefitialObjects/ProtoCoin3DSprite.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=4]
[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=5]
@ -9,7 +9,6 @@
[ext_resource path="res://assets/environment/background/space.png" type="Texture" id=7]
[ext_resource path="res://src/UserInterface/Buttons/PlayButton.gd" type="Script" id=8]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/LevelSelectButtonGroup.tres" type="ButtonGroup" id=9]
[ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=10]
[ext_resource path="res://src/UserInterface/Screens/MainMenu/LevelList.gd" type="Script" id=11]
[ext_resource path="res://src/UserInterface/Buttons/MenuNavigationButton.gd" type="Script" id=12]
[ext_resource path="res://assets/ui/sci-fi-godot-theme/sci-fi-theme.tres" type="Theme" id=13]
@ -43,10 +42,6 @@ fill = 1
fill_from = Vector2( 0.514029, 0.849867 )
fill_to = Vector2( 1, 0.994443 )
[sub_resource type="DynamicFont" id=1]
size = 60
font_data = ExtResource( 10 )
[node name="MainScreen" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
@ -124,6 +119,10 @@ margin_right = 312.0
margin_bottom = 36.0
grow_horizontal = 2
grow_vertical = 2
focus_neighbour_left = NodePath("../../MenuContainer/Buttons/PlayButton")
focus_neighbour_top = NodePath("../../MenuContainer/Buttons/PlayButton")
focus_neighbour_right = NodePath("../../MenuContainer/Buttons/PlayButton")
focus_neighbour_bottom = NodePath("../../MenuContainer/Buttons/PlayButton")
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 13 )
@ -180,18 +179,6 @@ texture = ExtResource( 16 )
expand = true
stretch_mode = 1
[node name="Titel" parent="MarginContainer" instance=ExtResource( 2 )]
visible = false
margin_right = 260.0
margin_bottom = 85.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 13 )
custom_fonts/font = SubResource( 1 )
text = "Blobby"
[node name="MenuContainer" type="HBoxContainer" parent="."]
anchor_left = 0.45
anchor_top = 0.75
@ -281,9 +268,10 @@ follow_focus = true
scroll_horizontal_enabled = false
script = ExtResource( 11 )
[node name="ProtoCoin3DSprite" parent="MenuContainer/Panel/LevelList" instance=ExtResource( 2 )]
[node name="VBoxContainer" type="VBoxContainer" parent="MenuContainer/Panel/LevelList"]
margin_right = 123.0
margin_bottom = 102.0
margin_right = 119.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3