Compare commits

...

3 Commits

20 changed files with 227 additions and 132 deletions

View File

@ -1,8 +1,8 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[sub_resource type="DynamicFontData" id=12]
[sub_resource type="DynamicFontData" id=14]
font_path = "res://assets/ui/fonts/Kenney Thick.ttf"
[resource]
size = 8
font_data = SubResource( 12 )
font_data = SubResource( 14 )

View File

@ -329,7 +329,7 @@ threads/thread_model=2
gles3/shaders/shader_compilation_mode=2
quality/depth/hdr=false
environment/default_environment="res://default_env.tres"
environment/2d/use_nvidia_rect_flicker_workaround=true
environment/2d/use_nvidia_rect_flicker_workaround=false
environment/stretch/aspect="ignore"
environment/intended_usage/framebuffer_allocation.mobile=0

View File

@ -4575,7 +4575,7 @@ unique_name_in_owner = true
position = Vector2( -12, 0 )
enabled = true
cast_to = Vector2( 0, 32 )
collision_mask = 8
collision_mask = 152
[node name="SlopeRaycastLeft" type="RayCast2D" parent="."]
visible = false
@ -4623,5 +4623,5 @@ one_shot = true
[connection signal="timeout" from="BlobbyStateMachine/JumpBufferTimer" to="BlobbyStateMachine" method="_on_JumpBufferTimer_timeout"]
[connection signal="timeout" from="BlobbyStateMachine/CrushTimer" to="." method="_on_CrushTimer_timeout"]
[connection signal="timeout" from="InvincibilityTimer" to="." method="_on_InvincibilityTimer_timeout"]
[connection signal="timeout" from="PitfallTimer" to="." method="_on_PitfallTimer_timeout"]
[connection signal="timeout" from="PitfallTimer" to="." method="die_for_real" binds= [ -1 ]]
[connection signal="timeout" from="PitfallTimer" to="." method="_on_PitfallTimer_timeout"]

View File

@ -31,7 +31,7 @@ func load_sounds() -> void:
func set_progress(value) -> void:
gsr.progress_dict = value
SaveManager.save_default()
save()
func get_progress() -> Dictionary:
@ -41,6 +41,7 @@ func get_progress() -> Dictionary:
func save() -> void:
SaveManager.save_default()
# Returns if the level was completed or not
func get_level_completed(level_name: String) -> bool:
if gsr.progress_dict.has(level_name) && gsr.progress_dict[level_name].has("levelcompleted"):
@ -53,14 +54,14 @@ func set_level_completed(level_name: String, state: bool) -> void:
if !gsr.progress_dict.has(level_name):
gsr.progress_dict[level_name] = {}
gsr.progress_dict[level_name]["levelcompleted"] = state
SaveManager.save_default()
save()
func set_leveltime(level_name: String, time: float) -> void:
func set_level_time(level_name: String, time: float) -> void:
if !gsr.progress_dict.has(level_name):
gsr.progress_dict[level_name] = {}
gsr.progress_dict[level_name]["leveltime"] = time
SaveManager.save_default()
save()
func get_level_time(level_name: String) -> float:
@ -74,7 +75,7 @@ func set_uncompleted_level_time(level_name: String, time: float) -> void:
if !gsr.progress_dict.has(level_name):
gsr.progress_dict[level_name] = {}
gsr.progress_dict[level_name]["uncompletedleveltime"] = time
SaveManager.save_default()
save()
func get_uncompleted_level_time(level_name: String) -> float:
@ -90,28 +91,29 @@ func set_savepoint(level_name: String, position: Vector2) -> void:
if !gsr.progress_dict.has(level_name):
gsr.progress_dict[level_name] = {}
gsr.progress_dict[level_name]["savepoint"] = position
SaveManager.save_default()
save()
func set_level_state(level_name: String, property_dict: Dictionary) -> void:
if !gsr.progress_dict.has(level_name):
gsr.progress_dict[level_name] = {}
gsr.progress_dict[level_name]["savestate"] = property_dict
SaveManager.save_default()
save()
func remove_savepoint(level_name: String) -> void:
if !gsr.progress_dict.has(level_name):
return
gsr.progress_dict[level_name].erase("savepoint")
gsr.progress_dict[level_name].erase("currency")
gsr.progress_dict[level_name].erase("uncompletedleveltime")
SaveManager.save_default()
save()
func remove_savestate(level_name: String) -> void:
if !gsr.progress_dict.has(level_name):
return
gsr.progress_dict[level_name].erase("savestate")
SaveManager.save_default()
save()
func get_property_value(level_name: String, propertyName: String) -> int:
@ -149,14 +151,14 @@ func touch_level(level_name: String) -> void:
# TODO This is permanent immediatly
func set_wallet(value) -> void:
gsr.wallet = value
SaveManager.save_default()
save()
func get_wallet() -> int:
return gsr.wallet
func set_swaying_grass(value: bool) -> void:
gsr.swaying_grass = value
SaveManager.save_default()
save()
func get_swaying_grass() -> bool:
return gsr.swaying_grass

View File

@ -9,20 +9,17 @@ export var currencyValue := 1
export var coin_3D_fps := 30
var last_draw_time := 0
var scene_saved_id := 0
func _ready() -> void:
scene_saved_id = level_state.register_saveable_object(self)
var collected_saved = level_state.get_saved_object_property(scene_saved_id, "was_collected")
level_state.register_saveable_node(self)
var collected_saved = level_state.get_saved_node_property(self, "was_collected")
if collected_saved != null:
was_collected = collected_saved
if was_collected:
visible = false
level_state.set_currency(level_state.get_currency() + currencyValue)
return
func _physics_process(delta: float) -> void:
if !visible || proto_coin == null:

View File

@ -15,10 +15,10 @@ var scene_saved_id := 0
var activatable = true
func _ready() -> void:
scene_saved_id = level_state.register_saveable_object(self)
var activated_saved = level_state.get_saved_object_property(scene_saved_id, "activated")
level_state.register_saveable_node(self)
var activated_saved = level_state.get_saved_node_property(self, "activated")
if activated_saved != null:
if level_state.savepoint_loaded && activated_saved != null:
activated = activated_saved
$Digit.frame = frog_number
if activated:

View File

@ -8,14 +8,13 @@ onready var unactivatable_timer := $Timer
export onready var activated := false
var scene_saved_id := 0
var activatable := true
func _ready() -> void:
scene_saved_id = level_state.register_saveable_object(self)
var activated_saved = level_state.get_saved_object_property(scene_saved_id, "activated")
level_state.register_saveable_node(self)
var activated_saved = level_state.get_saved_node_property(self, "activated")
if activated_saved != null:
if level_state.savepoint_loaded && activated_saved != null:
activated = activated_saved
signal_manager.connect("unlocked", self, "receive_unlock")

View File

@ -9,14 +9,13 @@ onready var unactivatable_timer := $Timer
export onready var activated := false
export var cost := 3
var scene_saved_id := 0
var activatable = false
func _ready():
scene_saved_id = level_state.register_saveable_object(self)
var activated_saved = level_state.get_saved_object_property(scene_saved_id, "activated")
level_state.register_saveable_node(self)
var activated_saved = level_state.get_saved_node_property(self, "activated")
if activated_saved != null:
if level_state.savepoint_loaded && activated_saved != null:
activated = activated_saved
$Sprite.frame = 0

View File

@ -104,7 +104,7 @@ func grass_wave_update(delta: float) -> void:
$Timer.stop()
is_idle_swinging = true
var start = displacement_coeff.x if begin_idle else 0.0
displacement_coeff.x = start * exp(-0.2 * (time-start_swing_time)) + 0.3 * -sin(2.0*(time - start_swing_time))
displacement_coeff.x = start * exp(-0.2 * (time-start_swing_time)) + 0.5 * -sin(2.0*(time - start_swing_time))
begin_idle = false
# if(displacement_coeff.x > saved_coeff):
# print(displacement_coeff.x)

View File

@ -7,14 +7,13 @@ export onready var is_armed = false
var trigger_zone_entered: bool = false
var scene_saved_id := 0
var activatable = false
func _ready():
scene_saved_id = level_state.register_saveable_object(self)
var is_armed_saved = level_state.get_saved_object_property(scene_saved_id, "is_armed")
level_state.register_saveable_node(self)
var is_armed_saved = level_state.get_saved_node_property(self, "is_armed")
if is_armed_saved != null:
if level_state.savepoint_loaded && is_armed_saved != null:
is_armed = is_armed_saved
if(!is_armed):

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

View File

@ -10,6 +10,7 @@ var freed_frogs := []
# TODO Rename probs
var is_dead := false setget set_dead
var savepoint_loaded := false
var level_time := 0.0
var saved_property_dictionary := {}
@ -19,8 +20,9 @@ var object_in_scene_id: int = 0
func _ready() -> void:
GlobalState.touch_level(level_name)
saved_property_dictionary = GlobalState.get_savestate(level_name)
GlobalState.gsr.last_played_level = level_name
SaveManager.save_default()
GlobalState.save()
signal_manager.connect("level_completed", self, "_on_level_completed")
signal_manager.connect("player_died", self, "player_dying")
@ -42,52 +44,61 @@ func set_currency(value: int) -> void:
currency = value
signal_manager.emit_signal("currency_updated")
func get_currency() -> int:
return currency
func set_deaths(value: int) -> void:
deaths = value
func set_dead(value: bool) -> void:
is_dead = value
func get_own_scene_id(obj: Object) -> int:
if "scene_id" in obj && saved_object_dictionary.has(obj.scene_id):
return obj.scene_id
func register_saveable_node(node: Node) -> void:
if saved_object_dictionary.has(node.name):
return
else:
return register_saveable_object(obj)
saved_object_dictionary[node.name] = node
if !saved_property_dictionary.has(node.name):
save_node_properties()
func register_saveable_object(obj: Object) -> int:
var id = object_in_scene_id
saved_object_dictionary[id] = obj
object_in_scene_id += 1
return id
func save_object_properties() -> void:
for id in saved_object_dictionary.keys():
var object = saved_object_dictionary[id]
# Saves the state of triggers, collected collectibles and such
func save_node_properties() -> void:
for name in saved_object_dictionary.keys():
var object = saved_object_dictionary[name]
var property_list = object.get_property_list()
var saved_properties = {}
for property in property_list:
# Only script Variables and only "primitive" types
if property["usage"] == PROPERTY_USAGE_SCRIPT_VARIABLE && property["type"] <= 16:
saved_properties[property["name"]] = object.get(property["name"])
saved_property_dictionary[id] = saved_properties
saved_property_dictionary[name] = saved_properties
GlobalState.set_level_state(level_name, saved_property_dictionary)
func get_saved_object_property(id: int, property: String):
if saved_property_dictionary.has(id) && saved_property_dictionary[id].has(property):
return saved_property_dictionary[id][property]
func get_saved_node_property(node: Node, property: String):
if (
saved_property_dictionary.has(node.name)
&& saved_property_dictionary[node.name].has(property)
):
return saved_property_dictionary[node.name][property]
else:
return null
func set_savepoint(pos: Vector2) -> void:
GlobalState.set_savepoint(level_name, pos)
save_object_properties()
GlobalState.set_uncompleted_level_time(level_name, level_time)
GlobalState.set_level_state(level_name, saved_property_dictionary)
save_node_properties()
GlobalState.get_progress()[level_name]["currency"] = (
GlobalState.get_property_value(level_name, "currency")
+ currency)
currency = 0
update_global_state()
func load_savepoint() -> bool:
@ -95,6 +106,9 @@ func load_savepoint() -> bool:
return false
saved_property_dictionary = GlobalState.get_savestate(level_name)
level_time = GlobalState.get_uncompleted_level_time(level_name)
# Just update the hud
set_currency(currency)
savepoint_loaded = true
return true
@ -134,48 +148,48 @@ func absolved_tutorial(lesson: String) -> void:
# and returns true if so. Else it does not spend and return false.
func spend_currency(cost: int) -> bool:
# TODO member that
if OS.is_debug_build():
return true
#if OS.is_debug_build():
# return true
if check_balance() < cost:
return false
# Can get negative if the cost is greater than what was collected in the same level
currency = currency - cost
return true
func check_balance() -> int:
var balance = currency + GlobalState.get_wallet()
var balance = currency + GlobalState.get_wallet() + GlobalState.get_property_value(level_name, "currency")
return balance
func _on_level_completed():
#if(OS.is_debug_build()):
# return
# TODO Extra screen for new best time
save_node_properties()
savepoint_loaded = false
GlobalState.set_level_completed(level_name, true)
if(GlobalState.get_level_time(level_name) > level_time ):
GlobalState.set_leveltime(level_name, level_time)
if GlobalState.get_level_time(level_name) > level_time:
GlobalState.set_level_time(level_name, level_time)
GlobalState.set_uncompleted_level_time(level_name, INF)
GlobalState.remove_savepoint(level_name)
GlobalState.remove_savestate(level_name)
update_global_state()
GlobalState.remove_savepoint(level_name)
reset()
# TODO This is now inconsistent as the level_completed property could be used to
# TODO This is now inconsistent as the level_completed property could be used to
# determine what was achieved for good and what progress was lost due to death/reloading
func update_global_state() -> void:
var progress_dict: Dictionary = GlobalState.get_progress()
var levelProgress: Dictionary = {}
levelProgress["currency"] = currency
levelProgress["deaths"] = deaths
# TODO Doesnt account for multiple plays of same level
if !progress_dict.has(level_name):
progress_dict[level_name] = levelProgress
else:
progress_dict[level_name]["currency"] = (
GlobalState.get_property_value(level_name, "currency")
+ currency
)
progress_dict[level_name]["deaths"] = (
GlobalState.get_property_value(level_name, "deaths")
+ deaths
@ -186,11 +200,15 @@ func update_global_state() -> void:
for frog_number in freed_frogs:
if progress_dict[level_name]["froggies"].has(frog_number):
progress_dict[level_name]["froggies"][frog_number] = true
# TODO Wallet is independant from progress_dict because???
GlobalState.set_wallet(GlobalState.gsr.wallet + currency)
if GlobalState.get_level_completed(level_name):
currency += GlobalState.get_property_value(level_name, "currency")
GlobalState.set_wallet(GlobalState.gsr.wallet + currency)
progress_dict[level_name]["currency"] = 0
currency = 0
# Adds currency to level progress temporarily
GlobalState.set_progress(progress_dict)
func player_dying(animation_number: int = 0) -> void:
currency = 0
is_dead = true