Global Achievement State

This commit is contained in:
Jakob Feldmann 2023-03-14 14:51:59 +01:00
parent e0fa4e24d4
commit ccb013d93c
22 changed files with 111 additions and 47 deletions

View File

@ -42,6 +42,10 @@ config/name="Blobby"
run/main_scene="res://src/UserInterface/Screens/MainScreen.tscn" run/main_scene="res://src/UserInterface/Screens/MainScreen.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload]
GlobalState="*res://src/Autoload/GlobalState.tscn"
[debug] [debug]
settings/fps/force_fps=144 settings/fps/force_fps=144

View File

@ -1,8 +1,8 @@
extends KinematicBody2D extends KinematicBody2D
class_name Actor class_name Actor
onready var levelState := get_tree().root.get_child(0).get_node("%LevelState") onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(0).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager")
const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd") const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")

View File

@ -9,7 +9,7 @@ var RopeAnchor = preload("res://src/Contraptions/Rope/RopeAnchor.tscn")
var rope var rope
var is_first_signal = true var is_first_signal = true
func _on_LevelTemplate_ready() -> void: func _on_Level_ready() -> void:
rope = Rope.instance() rope = Rope.instance()
# For some reason the rope only can be instanced in the parent scene # For some reason the rope only can be instanced in the parent scene
# The scene also has to be ready beforehand # The scene also has to be ready beforehand

View File

@ -194,7 +194,7 @@ extents = Vector2( 18.2143, 14.3338 )
[node name="Flyer" type="KinematicBody2D" groups=["frogfood", "harmful"]] [node name="Flyer" type="KinematicBody2D" groups=["frogfood", "harmful"]]
collision_layer = 258 collision_layer = 258
collision_mask = 9 collision_mask = 25
script = ExtResource( 1 ) script = ExtResource( 1 )
vision_distance = 8.0 vision_distance = 8.0
blindspot_angle = 30 blindspot_angle = 30

View File

@ -0,0 +1,6 @@
extends Node
var progress_dict := {} setget set_progress
func set_progress(value) -> void:
progress_dict = value

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/Autoload/GlobalState.gd" type="Script" id=1]
[node name="GlobalState" type="Node"]
script = ExtResource( 1 )

View File

@ -2,6 +2,8 @@ tool
extends Area2D extends Area2D
onready var anim_player: AnimationPlayer = $AnimationPlayer onready var anim_player: AnimationPlayer = $AnimationPlayer
onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
onready var levelName := get_tree().get_current_scene().get_name()
export var next_scene: PackedScene export var next_scene: PackedScene
@ -9,6 +11,26 @@ export var next_scene: PackedScene
func _get_configuration_warning() -> String: func _get_configuration_warning() -> String:
return "The next scene property can't be empty" if not next_scene else "" return "The next scene property can't be empty" if not next_scene else ""
func update_level_achievements() -> void:
var progress_dict : Dictionary = GlobalState.progress_dict
var levelProgress : Dictionary = {}
levelProgress["currency"] = levelState.currency
levelProgress["kills"] = levelState.kills
levelProgress["deaths"] = levelState.deaths
levelProgress["frees"] = levelState.frees
progress_dict[levelName] = levelProgress
# if !progress_dict.has(levelName):
# progress_dict[levelName] = levelProgress
# else:
# progress_dict[levelName]["currency"] = progress_dict[levelName]["currency"] + levelState.currency
# progress_dict[levelName]["kills"] = progress_dict[levelName]["kills"] + levelState.kills
# progress_dict[levelName]["deaths"] = progress_dict[levelName]["deaths"] + levelState.deaths
# progress_dict[levelName]["frees"] = progress_dict[levelName]["frees"] + levelState.frees
GlobalState.set_progress(progress_dict)
func teleport() -> void: func teleport() -> void:
anim_player.play("fade_in") anim_player.play("fade_in")
@ -17,4 +39,5 @@ func teleport() -> void:
func _on_body_entered(_body: Node) -> void: func _on_body_entered(_body: Node) -> void:
update_level_achievements()
teleport() teleport()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2] [gd_scene load_steps=13 format=2]
[ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1] [ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1]
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=2] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=2]
@ -9,13 +9,12 @@
[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=7] [ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=8] [ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/Utilities/LevelState.tscn" type="PackedScene" id=9] [ext_resource path="res://src/Utilities/LevelState.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/ObstacleObjects/Mine.tscn" type="PackedScene" id=10]
[ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=12] [ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=12]
[ext_resource path="res://src/Environment/ShaderGrass.tscn" type="PackedScene" id=13] [ext_resource path="res://src/Environment/ShaderGrass.tscn" type="PackedScene" id=13]
[sub_resource type="AnimationNodeStateMachinePlayback" id=4] [sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="LevelTemplate" type="Node2D"] [node name="01 Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]
@ -35,10 +34,10 @@ wait_time = 20.0
drag_margin_bottom = 0.3 drag_margin_bottom = 0.3
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"] [node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 3 frame = 10
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"] [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 7 frame = 0
[node name="Blobby" parent="." instance=ExtResource( 2 )] [node name="Blobby" parent="." instance=ExtResource( 2 )]
unique_name_in_owner = true unique_name_in_owner = true
@ -142,12 +141,6 @@ rotation = 1.57079
position = Vector2( 1488, -120 ) position = Vector2( 1488, -120 )
next_scene = ExtResource( 4 ) next_scene = ExtResource( 4 )
[node name="Mine2" parent="." instance=ExtResource( 10 )]
position = Vector2( 20, -9 )
[node name="Mine" parent="." instance=ExtResource( 10 )]
position = Vector2( 21, -27 )
[connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"] [connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"]
[editable path="UserInterface"] [editable path="UserInterface"]

View File

@ -68,7 +68,7 @@ tracks/0/keys = {
"values": [ Vector2( 0, 0 ), Vector2( -96, 0 ) ] "values": [ Vector2( 0, 0 ), Vector2( -96, 0 ) ]
} }
[node name="LevelTemplate" type="Node2D"] [node name="02 Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]
@ -87,10 +87,10 @@ wait_time = 20.0
[node name="BlobbyCam" parent="." instance=ExtResource( 12 )] [node name="BlobbyCam" parent="." instance=ExtResource( 12 )]
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"] [node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 0 frame = 8
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"] [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 5 frame = 13
[node name="Blobby" parent="." instance=ExtResource( 2 )] [node name="Blobby" parent="." instance=ExtResource( 2 )]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -67,7 +67,7 @@ animations = [ {
[sub_resource type="AnimationNodeStateMachinePlayback" id=6] [sub_resource type="AnimationNodeStateMachinePlayback" id=6]
[node name="LevelTemplate" type="Node2D"] [node name="03 Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]
@ -139,7 +139,7 @@ shape = SubResource( 3 )
position = Vector2( 0, 1.5 ) position = Vector2( 0, 1.5 )
z_index = -1 z_index = -1
frames = SubResource( 5 ) frames = SubResource( 5 )
frame = 20 frame = 7
playing = true playing = true
[node name="Portal" parent="." instance=ExtResource( 42 )] [node name="Portal" parent="." instance=ExtResource( 42 )]
@ -161,7 +161,7 @@ tile_data = PoolIntArray( -1, 1610612751, 0, -65536, 1610612746, 0, -65535, 1610
tile_data = PoolIntArray( 851970, 1, 0, 851971, 0, 0, 851973, 0, 0, 851975, 2, 0 ) tile_data = PoolIntArray( 851970, 1, 0, 851971, 0, 0, 851973, 0, 0, 851975, 2, 0 )
[node name="Flyer" parent="." instance=ExtResource( 41 )] [node name="Flyer" parent="." instance=ExtResource( 41 )]
position = Vector2( 600, 120 ) position = Vector2( 698, 294 )
max_speed = 120 max_speed = 120
[node name="StateLabel" parent="Flyer" index="1"] [node name="StateLabel" parent="Flyer" index="1"]
@ -177,7 +177,7 @@ movement_radius = 4
[node name="FlyingPlatformClean" parent="." instance=ExtResource( 43 )] [node name="FlyingPlatformClean" parent="." instance=ExtResource( 43 )]
position = Vector2( 496, 220 ) position = Vector2( 496, 220 )
[connection signal="ready" from="." to="BoundFrog" method="_on_LevelTemplate_ready"] [connection signal="ready" from="." to="BoundFrog" method="_on_Level_ready"]
[connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"] [connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"]
[connection signal="area_exited" from="Spring/SpringPlatform/SpringSkin" to="Spring/SpringPlatform" method="_on_SpringSkin_area_exited"] [connection signal="area_exited" from="Spring/SpringPlatform/SpringSkin" to="Spring/SpringPlatform" method="_on_SpringSkin_area_exited"]
[connection signal="area_entered" from="Spring/SpringPlatform/EnteringVelocityDetector" to="Spring/SpringPlatform" method="_on_EnteringVelocityDetector_area_entered"] [connection signal="area_entered" from="Spring/SpringPlatform/EnteringVelocityDetector" to="Spring/SpringPlatform" method="_on_EnteringVelocityDetector_area_entered"]

View File

@ -38,7 +38,7 @@ points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 )
} ] } ]
1/z_index = 0 1/z_index = 0
[node name="LevelTemplate" type="Node2D"] [node name="Enemy Test Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]

View File

@ -16,7 +16,7 @@
[sub_resource type="AnimationNodeStateMachinePlayback" id=4] [sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="LevelTemplate" type="Node2D"] [node name="Flyer Test Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]

View File

@ -21,7 +21,7 @@
[sub_resource type="AnimationNodeStateMachinePlayback" id=5] [sub_resource type="AnimationNodeStateMachinePlayback" id=5]
[node name="LevelTemplate" type="Node2D"] [node name="Froggy Test Level" type="Node2D"]
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]
@ -160,7 +160,7 @@ rotation = -4.71238
[node name="BoundFrog" parent="." instance=ExtResource( 9 )] [node name="BoundFrog" parent="." instance=ExtResource( 9 )]
position = Vector2( 324, 224 ) position = Vector2( 324, 224 )
[connection signal="ready" from="." to="BoundFrog" method="_on_LevelTemplate_ready"] [connection signal="ready" from="." to="BoundFrog" method="_on_Level_ready"]
[editable path="UserInterface"] [editable path="UserInterface"]
[editable path="UserInterface/HUD"] [editable path="UserInterface/HUD"]

View File

@ -10,7 +10,7 @@
[sub_resource type="AnimationNodeStateMachinePlayback" id=4] [sub_resource type="AnimationNodeStateMachinePlayback" id=4]
[node name="LevelTemplate" type="Node2D"] [node name="Grass Test Level" type="Node2D"]
position = Vector2( 16, -10 ) position = Vector2( 16, -10 )
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
@ -219,10 +219,10 @@ position = Vector2( 210, -15 )
[node name="BlobbyCam" parent="." instance=ExtResource( 11 )] [node name="BlobbyCam" parent="." instance=ExtResource( 11 )]
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"] [node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 7 frame = 4
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"] [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 12 frame = 9
[node name="Blobby" parent="." instance=ExtResource( 10 )] [node name="Blobby" parent="." instance=ExtResource( 10 )]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -9,8 +9,8 @@ var states = {}
onready var parent = get_parent() onready var parent = get_parent()
# Scene Singletons # Scene Singletons
onready var levelState := get_tree().root.get_child(0).get_node("%LevelState") onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(0).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager")
# Basic process flow for every SM # Basic process flow for every SM

View File

@ -1,6 +1,21 @@
extends Label extends Label
onready var levelState = $"%LevelState" onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
func _ready(): func _ready():
self.text = self.text % [levelState.currency, levelState.kills, levelState.frees] var wallet = 0
var deaths = 0
var kills = 0
var frees = 0
var prog = GlobalState.progress_dict
for key in GlobalState.progress_dict:
if prog[key].has("currency"):
wallet += prog[key]["currency"]
if prog[key].has("deaths"):
deaths += prog[key]["deaths"]
if prog[key].has("deaths"):
kills += prog[key]["kills"]
if prog[key].has("frees"):
frees += prog[key]["frees"]
self.text = self.text % [wallet, deaths, kills, frees]

View File

@ -3,7 +3,7 @@
[ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=1] [ext_resource path="res://assets/meta/montserrat_extrabold.otf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 24 size = 20
use_mipmaps = true use_mipmaps = true
use_filter = true use_filter = true
font_data = ExtResource( 1 ) font_data = ExtResource( 1 )

View File

@ -7,8 +7,8 @@ onready var timer: Label = $HUDOverlay/GetBackTimer
onready var currency: Label = $HUDOverlay/Currency onready var currency: Label = $HUDOverlay/Currency
onready var kills: Label = $HUDOverlay/Kills onready var kills: Label = $HUDOverlay/Kills
onready var frees: Label = $HUDOverlay/Frees onready var frees: Label = $HUDOverlay/Frees
onready var levelState := get_tree().root.get_child(0).get_node("%LevelState") onready var levelState := get_tree().root.get_child(1).get_node("%LevelState")
onready var signalManager := get_tree().root.get_child(0).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager")
func _ready(): func _ready():
@ -36,7 +36,16 @@ func _zoom_timer() -> void:
func update_interface() -> void: func update_interface() -> void:
currency.text = "Wallet: %s Orbicles" % levelState.currency
var wallet = 0
var prog := GlobalState.progress_dict
for key in prog:
if prog[key].has("currency"):
wallet += prog[key]["currency"]
wallet += levelState.currency
currency.text = "Wallet: %s Orbicles" % wallet
kills.text = "Kills: %s" % levelState.kills kills.text = "Kills: %s" % levelState.kills
frees.text = "Freed: %s" % levelState.frees frees.text = "Freed: %s" % levelState.frees

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=1] [ext_resource path="res://assets/environment/background/space.png" type="Texture" id=1]
[ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=2] [ext_resource path="res://assets/meta/new_dynamicfont.tres" type="DynamicFont" id=2]
[ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=3] [ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=4] [ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=4]
@ -36,14 +36,14 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 0.0 size_flags_stretch_ratio = 0.0
custom_fonts/font = ExtResource( 2 ) custom_fonts/font = ExtResource( 2 )
text = "Thanks You For Playing!" text = "Thanks Mom!"
autowrap = true autowrap = true
[node name="StatsLabel" parent="." instance=ExtResource( 6 )] [node name="StatsLabel" parent="." instance=ExtResource( 6 )]
margin_left = -146.5 margin_left = -343.0
margin_top = -33.5 margin_top = -59.0
margin_right = 146.5 margin_right = 352.0
margin_bottom = 33.5 margin_bottom = 11.0
size_flags_vertical = 1 size_flags_vertical = 1
align = 1 align = 1
script = ExtResource( 8 ) script = ExtResource( 8 )

View File

@ -1,12 +1,13 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=1] [ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=2] [ext_resource path="res://src/UserInterface/Buttons/Titel.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=3] [ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/environment/background/background.png" type="Texture" id=4] [ext_resource path="res://assets/environment/background/space.png" type="Texture" id=4]
[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=5] [ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=5]
[ext_resource path="res://src/UserInterface/Screens/LevelList.gd" type="Script" id=6] [ext_resource path="res://src/UserInterface/Screens/LevelList.gd" type="Script" id=6]
[ext_resource path="res://src/UserInterface/Screens/LevelSelectButtonGroup.tres" type="ButtonGroup" id=7] [ext_resource path="res://src/UserInterface/Screens/LevelSelectButtonGroup.tres" type="ButtonGroup" id=7]
[ext_resource path="res://assets/environment/background/Spaceship-Wall.png" type="Texture" id=8]
[node name="MainScreen" type="Control"] [node name="MainScreen" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -23,6 +24,13 @@ texture = ExtResource( 4 )
expand = true expand = true
stretch_mode = 1 stretch_mode = 1
[node name="background2" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 8 )
expand = true
stretch_mode = 1
[node name="Titel" parent="." instance=ExtResource( 2 )] [node name="Titel" parent="." instance=ExtResource( 2 )]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5

View File

@ -1,6 +1,6 @@
extends Node extends Node
onready var signalManager := get_tree().root.get_child(0).get_node("%SignalManager") onready var signalManager := get_tree().root.get_child(1).get_node("%SignalManager")
#TODO Easteregg pls #TODO Easteregg pls
var currency: = 0 setget set_currency var currency: = 0 setget set_currency