Compare commits

..

4 Commits

66 changed files with 816 additions and 295 deletions

View File

@@ -4,4 +4,10 @@
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>Mr.BrickAdventures</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Chickensoft.AutoInject" Version="2.8.21" />
<PackageReference Include="Chickensoft.GodotNodeInterfaces" Version="2.4.31" />
<PackageReference Include="Chickensoft.Introspection" Version="3.0.2" />
<PackageReference Include="Chickensoft.Introspection.Generator" Version="3.0.2" PrivateAssets="all" OutputItemType="analyzer" />
</ItemGroup>
</Project>

10
app/IGameScenes.cs Normal file
View File

@@ -0,0 +1,10 @@
using Godot;
namespace Mr.BrickAdventures.app;
public interface IGameScenes
{
void Load(PackedScene scene);
void Restart();
void ReturnToMain(PackedScene mainMenu);
}

1
app/IGameScenes.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://b7d1ospa5p4nx

11
app/ILevelCatalog.cs Normal file
View File

@@ -0,0 +1,11 @@
using Godot;
namespace Mr.BrickAdventures.app;
public interface ILevelCatalog
{
int Count { get; }
PackedScene? Get(int index);
PackedScene First { get; }
PackedScene MainMenu { get; }
}

1
app/ILevelCatalog.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://b2sxttgvk6nuq

70
common/AppRoot.cs Normal file
View File

@@ -0,0 +1,70 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Godot.Collections;
using Mr.BrickAdventures.app;
using Mr.BrickAdventures.data;
using Mr.BrickAdventures.game.repositories;
using Mr.BrickAdventures.game.services;
namespace Mr.BrickAdventures.common;
[Meta(typeof(IAutoNode))]
public partial class AppRoot : Node2D,
IProvide<PlayerRepository>,
IProvide<LevelRepository>,
IProvide<SaveClient>,
IProvide<SaveService>,
IProvide<LevelService>,
IProvide<IGameScenes>,
IProvide<ILevelCatalog>,
IGameScenes
{
public override void _Notification(int what) => this.Notify(what);
[Export] private Array<PackedScene> _levels = [];
[Export] private PackedScene _mainMenu = null!;
private readonly SaveClient _save = new("user://savegame.save", version: 2);
private readonly PlayerRepository _players = new();
private readonly LevelRepository _levelsRepo = new();
private SaveService _saveService = null!;
private LevelService _levelService = null!;
private ILevelCatalog _catalog = null!;
PlayerRepository IProvide<PlayerRepository>.Value() => _players;
LevelRepository IProvide<LevelRepository>.Value() => _levelsRepo;
SaveClient IProvide<SaveClient>.Value() => _save;
SaveService IProvide<SaveService>.Value() => _saveService;
LevelService IProvide<LevelService>.Value() => _levelService;
ILevelCatalog IProvide<ILevelCatalog>.Value() => _catalog;
IGameScenes IProvide<IGameScenes>.Value() => this;
public void OnReady()
{
_saveService = new SaveService(_players, _levelsRepo, _save);
_levelService = new LevelService(_levelsRepo);
_catalog = new ExportedLevelCatalog(_levels, _mainMenu);
_saveService.TryLoad();
this.Provide();
}
public void Load(PackedScene scene) => GetTree().ChangeSceneToPacked(scene);
public void Restart() => GetTree().ReloadCurrentScene();
public void ReturnToMain(PackedScene mainMenu) => GetTree().ChangeSceneToPacked(mainMenu);
private sealed class ExportedLevelCatalog : ILevelCatalog
{
private readonly Array<PackedScene> _levels;
public PackedScene MainMenu { get; }
public ExportedLevelCatalog(Array<PackedScene> levels, PackedScene mainMenu) {
_levels = levels; MainMenu = mainMenu;
}
public int Count => _levels.Count;
public PackedScene? Get(int index) => (index >= 0 && index < _levels.Count) ? _levels[index] : null;
public PackedScene First => _levels.Count > 0 ? _levels[0] : MainMenu;
}
}

1
common/AppRoot.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://dg2l7cw6da4vb

6
data/ConfigClient.cs Normal file
View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.data;
public class ConfigClient
{
}

1
data/ConfigClient.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://d3s774lnoljcu

103
data/SaveClient.cs Normal file
View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
using Godot.Collections;
using Mr.BrickAdventures.game.repositories;
namespace Mr.BrickAdventures.data;
public sealed class SaveClient
{
private readonly string _path;
private readonly int _version;
public SaveClient(string path, int version) { _path = path; _version = version; }
public bool Exists() => FileAccess.FileExists(_path);
public bool TryLoad(out PlayerState player, out LevelState level) {
player = null!; level = null!;
if (!Exists()) return false;
using var f = FileAccess.Open(_path, FileAccess.ModeFlags.Read);
var dict = (Dictionary)f.GetVar();
if ((int)dict.GetValueOrDefault("version", -1) != _version) return false;
player = ToPlayer((Dictionary)dict["player"]);
level = ToLevel((Dictionary)dict["level"]);
return true;
}
// Strict load: requires version + player_state + level_state.
// If anything is off, delete the file and act as "no save".
public bool TryLoadStrict(out PlayerState player, out LevelState level) {
player = default!;
level = default!;
if (!Exists()) return false;
try {
using var f = FileAccess.Open(_path, FileAccess.ModeFlags.Read);
if (f == null) { Delete(); return false; }
var dictionary = (Dictionary)f.GetVar();
if (!dictionary.TryGetValue("version", out var v) || (int)v != _version) { Delete(); return false; }
if (!dictionary.TryGetValue("player_state", out var pObj) || (Dictionary)pObj is not { } p) { Delete(); return false; }
if (!dictionary.TryGetValue("level_state", out var lObj) || (Dictionary)lObj is not { } l) { Delete(); return false; }
player = ToPlayer(p);
level = ToLevel(l);
return true;
}
catch (Exception e) {
GD.PushWarning($"SaveClient: load failed — deleting bad save. {e.GetType().Name}: {e.Message}");
Delete();
return false;
}
}
public void Save(PlayerState player, LevelState level) {
using var f = FileAccess.Open(_path, FileAccess.ModeFlags.Write);
var dict = new Dictionary {
{ "version", _version },
{ "player", FromPlayer(player) },
{ "level", FromLevel(level) }
};
f.StoreVar(dict);
}
public void Delete() {
if (!Exists()) return;
var abs = ProjectSettings.GlobalizePath(_path);
var ok = DirAccess.RemoveAbsolute(abs);
if (ok != Error.Ok) GD.PushWarning($"SaveClient: failed to delete {_path}: {ok}");
}
private static Dictionary FromPlayer(PlayerState s) => new() { { "coins", s.Coins }, { "lives", s.Lives } };
private static PlayerState ToPlayer(Dictionary d) => new() {
Coins = d.TryGetValue("coins", out var c) ? (int)c : 0,
Lives = d.TryGetValue("lives", out var l) ? (int)l : 3
};
private static Dictionary FromLevel(LevelState s) => new() {
{ "current", s.Current },
{ "unlocked", new Array<int>(s.Unlocked) },
{ "completed", new Array<int>(s.Completed) },
};
private static LevelState ToLevel(Dictionary d) => new() {
Current = d.TryGetValue("current", out var cur) ? (int)cur : 0,
Unlocked = d.TryGetValue("unlocked", out var ul) && (Array<int>)ul is { } a1 ? a1.ToArray() : [0],
Completed = d.TryGetValue("completed", out var cl) && (Array<int>)cl is { } a2 ? a2.ToArray() : [],
};
}
public record SaveSnapshot {
public required PlayerState PlayerState { get; init; }
public required LevelState LevelState { get; init; }
}

1
data/SaveClient.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://bsf45t7m2wa07

View File

@@ -0,0 +1,40 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Mr.BrickAdventures.app;
using Mr.BrickAdventures.game.services;
namespace Mr.BrickAdventures.features.level;
[Meta(typeof(IAutoNode))]
public partial class ExitDoorComponent : Area2D
{
public override void _Notification(int what) => this.Notify(what);
[Export] public CollisionShape2D UnlockIndicator { get; set; } = null!;
[Export] public bool Unlocked { get; set; } = false;
[Dependency] public LevelService Levels => this.DependOn<LevelService>();
[Dependency] public ILevelCatalog Catalog => this.DependOn<ILevelCatalog>();
[Dependency] public IGameScenes Scenes => this.DependOn<IGameScenes>();
public void OnReady() {
BodyEntered += OnBodyEntered;
UpdateVisuals();
}
private void OnBodyEntered(Node body) {
if (!Unlocked) return;
if (body is not CharacterBody2D) return;
var nextIdx = Levels.CompleteAndAdvance();
var next = Catalog.Get(nextIdx);
if (next != null) Scenes.Load(next); else Scenes.ReturnToMain(Catalog.MainMenu);
}
private void UpdateVisuals() {
if (UnlockIndicator != null) UnlockIndicator.Disabled = !Unlocked;
}
public void SetUnlocked(bool value) { Unlocked = value; UpdateVisuals(); }
}

View File

@@ -0,0 +1 @@
uid://ddh0jm0heqtc3

34
features/ui/hud/Hud.cs Normal file
View File

@@ -0,0 +1,34 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Mr.BrickAdventures.game.repositories;
using Mr.BrickAdventures.scripts.components;
namespace Mr.BrickAdventures.features.ui.hud;
[Meta(typeof(IAutoNode))]
public partial class Hud : Node
{
public override void _Notification(int what) => this.Notify(what);
[Export] public HealthComponent Health { get; set; } = null!;
[Node] public Label CoinsLabel { get; set; } = null!;
[Node] public ProgressBar HealthBar { get; set; } = null!;
[Node] public Label LivesLabel { get; set; } = null!;
[Dependency] public PlayerRepository Player => this.DependOn<PlayerRepository>();
public void OnResolved() {
CoinsLabel.Text = $"{Tr("COINS_LABEL")}: {Player.Coins}";
LivesLabel.Text = $"{Tr("LIVES_LABEL")}: {Player.Lives}";
Player.CoinsChanged += c => CoinsLabel.Text = $"{Tr("COINS_LABEL")}: {c}";
Player.LivesChanged += l => LivesLabel.Text = $"{Tr("LIVES_LABEL")}: {l}";
if (Health != null) {
HealthBar.MaxValue = Health.MaxHealth;
HealthBar.Value = Health.Health;
Health.HealthChanged += (_, total) => { HealthBar.Value = total; };
}
}
}

View File

@@ -0,0 +1 @@
uid://c1uwe5e1cfdxl

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://byxf45ukq82pe"]
[ext_resource type="LabelSettings" uid="uid://rvn5ivivfvv6" path="res://resources/ui/hud_label_settings.tres" id="1_4dsh5"]
[ext_resource type="Script" uid="uid://c3pde84b3kdco" path="res://scripts/ui/hud.gd" id="1_ueofj"]
[ext_resource type="Script" uid="uid://c1uwe5e1cfdxl" path="res://features/ui/hud/Hud.cs" id="1_m4pq7"]
[ext_resource type="FontFile" uid="uid://xm0vbusjr7b7" path="res://fonts/PressStart2P-Regular.ttf" id="1_ygmwt"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mmcdi"]
@@ -16,7 +16,7 @@ bg_color = Color(0.47451, 0.47451, 0.47451, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_22dp1"]
bg_color = Color(0.858824, 0.254902, 0.380392, 1)
[node name="HUD" type="Control" node_paths=PackedStringArray("coins_label", "health_progressbar", "lives_label")]
[node name="HUD" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -25,10 +25,7 @@ grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
script = ExtResource("1_ueofj")
coins_label = NodePath("PanelContainer/MarginContainer/HBoxContainer/Coins label")
health_progressbar = NodePath("PanelContainer/MarginContainer/HBoxContainer/ProgressBar")
lives_label = NodePath("PanelContainer/MarginContainer/HBoxContainer/Lives")
script = ExtResource("1_m4pq7")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
@@ -57,7 +54,8 @@ text = "HEALTH_LABEL"
label_settings = ExtResource("1_4dsh5")
uppercase = true
[node name="ProgressBar" type="ProgressBar" parent="PanelContainer/MarginContainer/HBoxContainer"]
[node name="HealthBar" type="ProgressBar" parent="PanelContainer/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_horizontal = 3
@@ -69,7 +67,8 @@ step = 0.1
value = 60.0
show_percentage = false
[node name="Lives" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer"]
[node name="LivesLabel" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "LIVES_LABEL"
@@ -77,7 +76,8 @@ label_settings = ExtResource("1_4dsh5")
horizontal_alignment = 1
uppercase = true
[node name="Coins label" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer"]
[node name="CoinsLabel" type="Label" parent="PanelContainer/MarginContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
text = "COINS_LABEL"

View File

@@ -0,0 +1,26 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Mr.BrickAdventures.app;
namespace Mr.BrickAdventures.features.ui.menus;
[Meta(typeof(IAutoNode))]
public partial class GameOverScreen : Control
{
public override void _Notification(int what) => this.Notify(what);
[Export] public Button RestartButton { get; set; } = null!;
[Export] public Button MainMenuButton { get; set; } = null!;
[Export] public PackedScene MainMenuScene { get; set; } = null!;
[Dependency] public IGameScenes Scenes => this.DependOn<IGameScenes>();
public void OnReady() {
Visible = false;
RestartButton.Pressed += () => Scenes.Restart();
MainMenuButton.Pressed += () => Scenes.ReturnToMain(MainMenuScene);
}
public void ShowGameOver() => Show();
}

View File

@@ -0,0 +1 @@
uid://b36jv878751ta

View File

@@ -0,0 +1,57 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Mr.BrickAdventures.app;
using Mr.BrickAdventures.game.repositories;
using Mr.BrickAdventures.game.services;
namespace Mr.BrickAdventures.features.ui.menus;
[Meta(typeof(IAutoNode))]
public partial class MainMenu : Control
{
public override void _Notification(int what) => this.Notify(what);
[Node] public Button NewGameButton { get; set; } = null!;
[Node] public Button ContinueButton { get; set; } = null!;
[Node] public Button SettingsButton { get; set; } = null!;
[Node] public Button CreditsButton { get; set; } = null!;
[Node] public Button ExitButton { get; set; } = null!;
[Node] public Label VersionLabel { get; set; } = null!;
[Export] public Control SettingsControl { get; set; } = null!;
[Export] public Control CreditsControl { get; set; } = null!;
[Dependency] public SaveService Save => this.DependOn<SaveService>();
[Dependency] public LevelRepository Levels => this.DependOn<LevelRepository>();
[Dependency] public IGameScenes Scenes => this.DependOn<IGameScenes>();
[Dependency] public ILevelCatalog Catalog => this.DependOn<ILevelCatalog>();
public void OnReady() {
VersionLabel.Text = $"v. {ProjectSettings.GetSetting("application/config/version")}";
NewGameButton.Pressed += OnNewGamePressed;
ContinueButton.Pressed += OnContinuePressed;
SettingsButton.Pressed += () => SettingsControl.Show();
CreditsButton.Pressed += () => CreditsControl.Show();
ExitButton.Pressed += () => GetTree().Quit();
}
public void OnResolved()
{
ContinueButton.Disabled = !Save.Exists();
(ContinueButton.Disabled ? NewGameButton : ContinueButton).GrabFocus();
}
private void OnNewGamePressed() {
Save.NewGame();
Levels.SetCurrent(0);
var first = Catalog.First;
Scenes.Load(first);
}
private void OnContinuePressed() {
if (!Save.TryLoad()) { OnNewGamePressed(); return; }
var scene = Catalog.Get(Levels.Current) ?? Catalog.First;
Scenes.Load(scene);
}
}

View File

@@ -0,0 +1 @@
uid://fcsg0e8s36in

View File

@@ -0,0 +1,33 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using Mr.BrickAdventures.app;
using Mr.BrickAdventures.game.services;
namespace Mr.BrickAdventures.features.ui.menus;
[Meta(typeof(IAutoNode))]
public partial class PauseMenu : Control
{
public override void _Notification(int what) => this.Notify(what);
[Export] public Button ResumeButton { get; set; } = null!;
[Export] public Button RestartButton { get; set; } = null!;
[Export] public Button MainMenuButton { get; set; } = null!;
[Dependency] public IGameScenes Scenes => this.DependOn<IGameScenes>();
[Dependency] public ILevelCatalog Catalog => this.DependOn<ILevelCatalog>();
[Dependency] public LevelService Levels => this.DependOn<LevelService>();
public void OnReady() {
Visible = false;
ResumeButton.Pressed += () => { GetTree().Paused = false; Hide(); };
RestartButton.Pressed += () => { GetTree().Paused = false; Scenes.Restart(); };
MainMenuButton.Pressed += () => { GetTree().Paused = false; Scenes.ReturnToMain(Catalog.MainMenu); };
}
public void Toggle() {
if (Visible) { GetTree().Paused = false; Hide(); }
else { Show(); GetTree().Paused = true; }
}
}

View File

@@ -0,0 +1 @@
uid://bwgs02wcfnm8u

View File

@@ -1,25 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://8b6ol5sssbgo"]
[ext_resource type="Script" uid="uid://hyfvthdbgjbc" path="res://scripts/ui/main_menu.gd" id="1_epxpl"]
[ext_resource type="Script" uid="uid://fcsg0e8s36in" path="res://features/ui/menus/MainMenu.cs" id="1_q8hru"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qv2q0"]
bg_color = Color(0, 0, 0, 1)
[node name="MainMenu" type="Control" node_paths=PackedStringArray("main_menu_control", "new_game_button", "continue_button", "settings_button", "credits_button", "exit_button", "version_label")]
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_epxpl")
main_menu_control = NodePath(".")
new_game_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/NewGameButton")
continue_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/ContinueButton")
settings_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/SettingsButton")
credits_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/CreditsButton")
exit_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/QuitButton")
version_label = NodePath("PanelContainer/MarginContainer/VBoxContainer/version")
script = ExtResource("1_q8hru")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1
@@ -53,31 +46,37 @@ layout_mode = 2
size_flags_vertical = 3
[node name="ContinueButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "CONTINUE_BUTTON"
flat = true
[node name="NewGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "NEW_GAME_BUTTON"
flat = true
[node name="SettingsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "SETTINGS_BUTTON"
flat = true
[node name="CreditsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "CREDITS_BUTTON"
flat = true
[node name="QuitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
[node name="ExitButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "QUIT_BUTTON"
flat = true
[node name="version" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
[node name="VersionLabel" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 8

View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.features.ui.settings;
public class AudioSettings
{
}

View File

@@ -0,0 +1 @@
uid://bnj36dhskiem

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Mr.BrickAdventures.game.repositories;
public sealed class LevelRepository
{
public int Current { get; private set; } = 0;
public HashSet<int> Unlocked { get; } = new() { 0 };
public HashSet<int> Completed { get; } = new();
public event Action<int>? CurrentChanged;
public void SetCurrent(int idx) { Current = idx; CurrentChanged?.Invoke(Current); }
public void Unlock(int idx) => Unlocked.Add(idx);
public void Complete(int idx) { Completed.Add(idx); Unlock(idx + 1); }
public LevelState Export() => new() {
Current = Current, Unlocked = [..Unlocked], Completed = [..Completed]
};
public void Load(LevelState s) {
Current = s.Current;
Unlocked.Clear(); foreach (var i in s.Unlocked) Unlocked.Add(i);
Completed.Clear(); foreach (var i in s.Completed) Completed.Add(i);
CurrentChanged?.Invoke(Current);
}
}
public record LevelState {
public int Current;
public int[] Unlocked = [];
public int[] Completed = [];
}

View File

@@ -0,0 +1 @@
uid://d0604lmwpadt5

View File

@@ -0,0 +1,25 @@
using System;
namespace Mr.BrickAdventures.game.repositories;
public sealed class PlayerRepository
{
public int Coins { get; private set; } = 0;
public int Lives { get; private set; } = 3;
public event Action<int>? CoinsChanged;
public event Action<int>? LivesChanged;
public void SetCoins(int value) { Coins = Math.Max(0, value); CoinsChanged?.Invoke(Coins); }
public void AddCoins(int amount) { SetCoins(Coins + amount); }
public void RemoveCoins(int amount){ SetCoins(Coins - amount); }
public void SetLives(int value) { Lives = value; LivesChanged?.Invoke(Lives); }
public void AddLives(int amount) { SetLives(Lives + amount); }
public void RemoveLives(int amount){ SetLives(Lives - amount); }
public PlayerState Export() => new() { Coins = Coins, Lives = Lives };
public void Load(PlayerState s) { SetCoins(s.Coins); SetLives(s.Lives); }
}
public record PlayerState { public int Coins; public int Lives; }

View File

@@ -0,0 +1 @@
uid://d1dijkt574x4b

View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.game.repositories;
public sealed class SessionRepository
{
}

View File

@@ -0,0 +1 @@
uid://b550hcqugygv0

View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.game.repositories;
public class SettingsRepository
{
}

View File

@@ -0,0 +1 @@
uid://bk11iduo7bg2h

View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.game.repositories;
public class SkillsRepository
{
}

View File

@@ -0,0 +1 @@
uid://cymx7mtmdblun

View File

@@ -0,0 +1,21 @@
using Mr.BrickAdventures.game.repositories;
namespace Mr.BrickAdventures.game.services;
public sealed class LevelService
{
private readonly LevelRepository _levels;
public LevelService(LevelRepository levels) => _levels = levels;
public int CompleteAndAdvance() {
var cur = _levels.Current;
_levels.Complete(cur);
var next = cur + 1;
_levels.SetCurrent(next);
return next;
}
public void StartNew() {
_levels.Load(new LevelState { Current = 0, Unlocked = new [] { 0 }, Completed = [] });
}
}

View File

@@ -0,0 +1 @@
uid://b2tsi3cjnh5xq

View File

@@ -0,0 +1,32 @@
using Mr.BrickAdventures.data;
using Mr.BrickAdventures.game.repositories;
namespace Mr.BrickAdventures.game.services;
public sealed class SaveService
{
private readonly PlayerRepository _players;
private readonly LevelRepository _levels;
private readonly SaveClient _save;
public SaveService(PlayerRepository players, LevelRepository levels, SaveClient save) {
_players = players; _levels = levels; _save = save;
}
public bool TryLoad() {
if (!_save.TryLoad(out var p, out var l)) return false;
_players.Load(p);
_levels.Load(l);
return true;
}
public void Save() => _save.Save(_players.Export(), _levels.Export());
public bool Exists() => _save.Exists();
public void NewGame() {
_players.Load(new PlayerState { Coins = 0, Lives = 3 });
_levels.Load(new LevelState { Current = 0, Unlocked = [0], Completed = [] });
Save();
}
}

View File

@@ -0,0 +1 @@
uid://dxqkxlkkivxog

View File

@@ -0,0 +1,6 @@
namespace Mr.BrickAdventures.game.services;
public sealed class SkillService
{
}

View File

@@ -0,0 +1 @@
uid://dim21hs12wdi5

View File

@@ -1,9 +1,9 @@
[gd_scene load_steps=7 format=3 uid="uid://bargnp4twtmxg"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_aya2w"]
[ext_resource type="Script" uid="uid://r4jybneigfcn" path="res://scripts/components/CollectableComponent.cs" id="2_htmrw"]
[ext_resource type="Script" uid="uid://pa1bwc4no08q" path="res://scripts/components/collectable.gd" id="2_7cph7"]
[ext_resource type="Resource" uid="uid://bsnr5v2b2mfsl" path="res://resources/collectables/big_coin.tres" id="3_lk3av"]
[ext_resource type="Script" uid="uid://bjln6jb1sigx2" path="res://scripts/components/FadeAwayComponent.cs" id="4_62p7g"]
[ext_resource type="Script" uid="uid://bg75hnr3q6grk" path="res://scripts/components/fade_away.gd" id="4_wkrj0"]
[ext_resource type="AudioStream" uid="uid://bceic1csr8rq3" path="res://sfx/pickup_coin_2.wav" id="5_dbffd"]
[sub_resource type="CircleShape2D" id="CircleShape2D_3ask2"]
@@ -23,17 +23,19 @@ hframes = 12
vframes = 12
frame = 51
[node name="CollectableComponent" type="Node" parent="." node_paths=PackedStringArray("Area2D", "CollisionShape", "Sfx") groups=["coins"]]
script = ExtResource("2_htmrw")
Area2D = NodePath("..")
CollisionShape = NodePath("../CollisionShape2D")
Data = ExtResource("3_lk3av")
Sfx = NodePath("../sfx")
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
script = ExtResource("2_7cph7")
area2d = NodePath("..")
collision_shape = NodePath("../CollisionShape2D")
collectable_data = ExtResource("3_lk3av")
sfx = NodePath("../sfx")
[node name="FadeAwayComponent" type="Node" parent="." node_paths=PackedStringArray("Sprite", "Area")]
script = ExtResource("4_62p7g")
Sprite = NodePath("../Sprite2D")
Area = NodePath("..")
[node name="FadeAwayComponent" type="Node" parent="." node_paths=PackedStringArray("sprite2d", "root", "area2d")]
script = ExtResource("4_wkrj0")
sprite2d = NodePath("../Sprite2D")
fade_duration = 0.4
root = NodePath("..")
area2d = NodePath("..")
[node name="sfx" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("5_dbffd")

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=7 format=3 uid="uid://d08dfqmirnd66"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_1co1x"]
[ext_resource type="Script" uid="uid://r4jybneigfcn" path="res://scripts/components/CollectableComponent.cs" id="2_lthbn"]
[ext_resource type="Script" uid="uid://pa1bwc4no08q" path="res://scripts/components/collectable.gd" id="2_cujcq"]
[ext_resource type="Resource" uid="uid://b6xqotmke54x" path="res://resources/collectables/big_treasure.tres" id="3_k64cr"]
[ext_resource type="Script" uid="uid://bg75hnr3q6grk" path="res://scripts/components/fade_away.gd" id="4_nw7tw"]
[ext_resource type="AudioStream" uid="uid://wr7n5ivv06ux" path="res://sfx/pickup_coin_4.wav" id="5_fxf8v"]
@@ -22,12 +22,12 @@ hframes = 12
vframes = 12
frame = 64
[node name="CollectableComponent" type="Node" parent="." node_paths=PackedStringArray("Area2D", "CollisionShape", "Sfx") groups=["coins"]]
script = ExtResource("2_lthbn")
Area2D = NodePath("..")
CollisionShape = NodePath("../CollisionShape2D")
Data = ExtResource("3_k64cr")
Sfx = NodePath("../sfx")
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
script = ExtResource("2_cujcq")
area2d = NodePath("..")
collision_shape = NodePath("../CollisionShape2D")
collectable_data = ExtResource("3_k64cr")
sfx = NodePath("../sfx")
[node name="FadeAwayComponent" type="Node" parent="." node_paths=PackedStringArray("sprite2d", "root", "area2d")]
script = ExtResource("4_nw7tw")

View File

@@ -1,14 +1,13 @@
[gd_scene load_steps=11 format=3 uid="uid://bymro4t7angv5"]
[gd_scene load_steps=10 format=3 uid="uid://bymro4t7angv5"]
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_1c3jb"]
[ext_resource type="Script" uid="uid://cfw8nbrarex0i" path="res://scripts/components/BulletComponent.cs" id="2_r41xl"]
[ext_resource type="Script" uid="uid://2i7p7v135u7c" path="res://scripts/components/DamageComponent.cs" id="3_h7wgh"]
[ext_resource type="Script" uid="uid://cs6u3sh68f43j" path="res://scripts/components/OutOfScreenComponent.cs" id="4_ihgvw"]
[ext_resource type="Script" uid="uid://c7n6ecsobohjn" path="res://scripts/components/ProjectileInitComponent.cs" id="5_aiue8"]
[ext_resource type="Script" uid="uid://cbexrnnj47f87" path="res://scripts/components/LaunchComponent.cs" id="6_t4c40"]
[ext_resource type="Script" uid="uid://c7p06t0eax8am" path="res://scripts/components/StraightMotionComponent.cs" id="7_y10b5"]
[ext_resource type="Script" uid="uid://cdnwrn8v05qhi" path="res://scripts/components/bullet_component.gd" id="2_i6t5k"]
[ext_resource type="Script" uid="uid://dkmxhjtmu5xlb" path="res://scripts/components/damage_component.gd" id="3_8xipx"]
[ext_resource type="Script" uid="uid://1tnr46o1ib4u" path="res://scripts/components/out_of_screen_component.gd" id="4_rdtjq"]
[ext_resource type="Script" uid="uid://bgty7040ams6s" path="res://scripts/components/projectile_init_component.gd" id="5_2vqt8"]
[ext_resource type="Script" uid="uid://873un8agkyja" path="res://scripts/components/launch_component.gd" id="6_d0tcd"]
[ext_resource type="Script" uid="uid://cvcnfrr1udco5" path="res://scripts/components/straight_motion_component.gd" id="7_r41xl"]
[ext_resource type="PackedScene" uid="uid://c1iorglk708g0" path="res://objects/fxs/terrain_hit_fx.tscn" id="8_d0tcd"]
[ext_resource type="Script" uid="uid://cypxrqoeiihbf" path="res://scripts/components/TerrainHitFx.cs" id="9_y1xkr"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ar0xf"]
size = Vector2(16, 10)
@@ -26,11 +25,12 @@ hframes = 12
vframes = 12
frame = 80
[node name="BulletComponent" type="Node" parent="." node_paths=PackedStringArray("Area", "TerrainHitFx", "BulletSprite")]
script = ExtResource("2_r41xl")
Area = NodePath("..")
TerrainHitFx = NodePath("../TerrainHitFX")
BulletSprite = NodePath("../Sprite2D")
[node name="BulletComponent" type="Node" parent="." node_paths=PackedStringArray("root", "area2d", "hit_terrain_fx", "bullet_sprite")]
script = ExtResource("2_i6t5k")
root = NodePath("..")
area2d = NodePath("..")
hit_terrain_fx = NodePath("../TerrainHitFX")
bullet_sprite = NodePath("../Sprite2D")
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
position = Vector2(0, 2.38419e-07)
@@ -38,28 +38,30 @@ scale = Vector2(0.8, 0.5)
[node name="Timer" type="Timer" parent="."]
[node name="DamageComponent" type="Node" parent="." node_paths=PackedStringArray("Area", "DamageTimer")]
script = ExtResource("3_h7wgh")
Area = NodePath("..")
DamageTimer = NodePath("../Timer")
[node name="DamageComponent" type="Node" parent="." node_paths=PackedStringArray("area2d")]
script = ExtResource("3_8xipx")
area2d = NodePath("..")
[node name="OutOfScreenComponent" type="Node" parent="." node_paths=PackedStringArray("VisibilityNotifier")]
script = ExtResource("4_ihgvw")
VisibilityNotifier = NodePath("../VisibleOnScreenNotifier2D")
[node name="OutOfScreenComponent" type="Node" parent="." node_paths=PackedStringArray("visibility_notifier", "root")]
script = ExtResource("4_rdtjq")
visibility_notifier = NodePath("../VisibleOnScreenNotifier2D")
root = NodePath("..")
[node name="ProjectileInitComponent" type="Node" parent="." node_paths=PackedStringArray("LaunchComponent")]
script = ExtResource("5_aiue8")
LaunchComponent = NodePath("../LaunchComponent")
[node name="ProjectileInitComponent" type="Node" parent="." node_paths=PackedStringArray("launch_component")]
script = ExtResource("5_2vqt8")
launch_component = NodePath("../LaunchComponent")
metadata/_custom_type_script = "uid://bgty7040ams6s"
[node name="LaunchComponent" type="Node2D" parent="."]
script = ExtResource("6_t4c40")
[node name="LaunchComponent" type="Node2D" parent="." node_paths=PackedStringArray("root")]
script = ExtResource("6_d0tcd")
root = NodePath(".")
speed = 180.0
metadata/_custom_type_script = "uid://873un8agkyja"
[node name="StraightMotionComponent" type="Node" parent="." node_paths=PackedStringArray("LaunchComponent")]
script = ExtResource("7_y10b5")
LaunchComponent = NodePath("../LaunchComponent")
[node name="StraightMotionComponent" type="Node" parent="." node_paths=PackedStringArray("root", "launch_component")]
script = ExtResource("7_r41xl")
root = NodePath("..")
launch_component = NodePath("../LaunchComponent")
metadata/_custom_type_script = "uid://cvcnfrr1udco5"
[node name="TerrainHitFX" parent="." instance=ExtResource("8_d0tcd")]
script = ExtResource("9_y1xkr")

View File

@@ -1,24 +1,25 @@
[gd_scene load_steps=49 format=3 uid="uid://bqi5s710xb1ju"]
[gd_scene load_steps=48 format=3 uid="uid://bqi5s710xb1ju"]
[ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"]
[ext_resource type="Script" uid="uid://ccuddyoakg04u" path="res://scripts/player.gd" id="1_8j4h4"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
[ext_resource type="Script" uid="uid://btlm1f3l70il" path="res://scripts/components/PlatformMovementComponent.cs" id="2_o1ihh"]
[ext_resource type="Texture2D" uid="uid://jl1gwqchhpdc" path="res://sprites/left_eye.png" id="3_2srrh"]
[ext_resource type="Script" uid="uid://cty54itmnudfm" path="res://scripts/components/ShipMovementComponent.cs" id="3_ur2y5"]
[ext_resource type="Script" uid="uid://b3mrdvre1y567" path="res://scripts/components/ship_movement.gd" id="3_p4n66"]
[ext_resource type="Texture2D" uid="uid://iiawtnwmeny3" path="res://sprites/right_eye.png" id="4_ccn81"]
[ext_resource type="Script" uid="uid://oxeqvxkgj87j" path="res://scripts/components/flip_player.gd" id="5_geu10"]
[ext_resource type="Texture2D" uid="uid://0l454rfplmqg" path="res://sprites/MrBrick_base-sheet.png" id="5_yysbb"]
[ext_resource type="Script" uid="uid://qeu80jy4vmuf" path="res://scripts/components/score.gd" id="6_fowa2"]
[ext_resource type="Script" uid="uid://btfsq0bvtrx3t" path="res://scripts/components/health.gd" id="7_tqjk8"]
[ext_resource type="Script" uid="uid://dkpu3121y88oo" path="res://scripts/components/player_death.gd" id="8_1v23d"]
[ext_resource type="Texture2D" uid="uid://dhkwyv6ayb5qb" path="res://sprites/flying_ship.png" id="8_6lsog"]
[ext_resource type="Script" uid="uid://dy78ak8eykw6e" path="res://scripts/components/FlipComponent.cs" id="9_yysbb"]
[ext_resource type="Script" uid="uid://mnjg3p0aw1ow" path="res://scripts/components/CanPickUpComponent.cs" id="10_yysbb"]
[ext_resource type="Script" uid="uid://ccqb8kd5m0eh7" path="res://scripts/components/ScoreComponent.cs" id="11_o1ihh"]
[ext_resource type="Script" uid="uid://dgb8bqcri7nsj" path="res://scripts/components/HealthComponent.cs" id="12_ur2y5"]
[ext_resource type="Script" uid="uid://byw1legrv1ep2" path="res://scripts/components/PlayerDeathComponent.cs" id="13_7til7"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="14_e5pae"]
[ext_resource type="Script" uid="uid://cecelixl41t3j" path="res://scripts/components/InvulnerabilityComponent.cs" id="15_xuhvf"]
[ext_resource type="PackedScene" uid="uid://dyp4i4ru2j2jh" path="res://objects/fxs/explosion_fx.tscn" id="9_hwg11"]
[ext_resource type="Script" uid="uid://nogmyshjrv57" path="res://scripts/components/knockback.gd" id="9_rjyu4"]
[ext_resource type="Script" uid="uid://ulhswh4jjlc6" path="res://scripts/components/stomp_damage_component.gd" id="12_payr4"]
[ext_resource type="Script" uid="uid://dqmbvuutd5c3c" path="res://scripts/components/flashing_component.gd" id="13_hrtyn"]
[ext_resource type="Script" uid="uid://ijrli0x8ij8v" path="res://scripts/components/invulnerability_component.gd" id="14_jopig"]
[ext_resource type="Script" uid="uid://6ffxsx3gknhr" path="res://scripts/components/can_be_launched_component.gd" id="16_kemlv"]
[ext_resource type="Resource" uid="uid://dw5ee2lpeypnb" path="res://resources/skills/brick_throw.tres" id="16_smbir"]
[ext_resource type="Script" uid="uid://dvyd26ricriql" path="res://scripts/components/FlashingComponent.cs" id="16_uno3u"]
[ext_resource type="Resource" uid="uid://2glvryih82t1" path="res://resources/skills/fire_brick.tres" id="17_6y5qu"]
[ext_resource type="Script" uid="uid://dtg6115je7b5s" path="res://scripts/components/StompDamageComponent.cs" id="17_bl1gx"]
[ext_resource type="Script" uid="uid://bpy6xtfm8l3hy" path="res://scripts/components/trigger_lever_component.gd" id="17_hglfj"]
[ext_resource type="AudioStream" uid="uid://duj2q0rqytaxg" path="res://sfx/jump.wav" id="18_pysae"]
[ext_resource type="Resource" uid="uid://cx5fsbexblp60" path="res://resources/skills/ice_brick.tres" id="18_umfbf"]
[ext_resource type="Resource" uid="uid://cdp8sex36vdq2" path="res://resources/skills/explosive_brick.tres" id="19_5wjb7"]
@@ -28,17 +29,15 @@
[ext_resource type="Script" uid="uid://bya240e627ti6" path="res://scripts/resources/skill_data.gd" id="21_d0oiv"]
[ext_resource type="Resource" uid="uid://d3bjre2etov1n" path="res://resources/skills/magnetic.tres" id="22_vnsgd"]
[ext_resource type="Script" uid="uid://bjsyeo1n7bsri" path="res://scripts/components/skill_unlocker_component.gd" id="23_qsv2c"]
[ext_resource type="Script" uid="uid://bo506l4x0808e" path="res://scripts/components/HitComponent.cs" id="26_6n1ss"]
[ext_resource type="Script" uid="uid://cjcc7fia15wu3" path="res://scripts/components/CanBeLaunchedComponent.cs" id="27_oefns"]
[ext_resource type="PackedScene" uid="uid://bg76mtpcmfm2j" path="res://objects/ui/charging_bar_layer.tscn" id="28_3f5nm"]
[ext_resource type="Script" uid="uid://cqau0810tjk4d" path="res://scripts/components/TriggerLeverComponent.cs" id="28_bnap0"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="28_jh5m0"]
[ext_resource type="Script" uid="uid://ceq8n7yw7qxpi" path="res://scripts/components/hit_component.gd" id="29_jh5m0"]
[ext_resource type="Script" uid="uid://cflncpa377l8l" path="res://scripts/components/platform_movement.gd" id="31_xoue7"]
[ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="32_x2b7c"]
[ext_resource type="Script" uid="uid://d1ctdx52gskv1" path="res://scripts/components/ship_shooter.gd" id="34_gwc8i"]
[ext_resource type="Script" uid="uid://dev2q1228otm2" path="res://scripts/UI/ChargeProgressBar.cs" id="34_o1ihh"]
[ext_resource type="PackedScene" uid="uid://dtem8jgcyoqar" path="res://objects/entities/green_laser.tscn" id="36_oxudy"]
[ext_resource type="Script" uid="uid://diw6opv6yutgi" path="res://scripts/components/KillPlayerOutOfScreenComponent.cs" id="37_qec3q"]
[ext_resource type="Script" uid="uid://3qy7rm28q66a" path="res://scripts/components/ProgressiveDamageComponent.cs" id="38_dhjci"]
[ext_resource type="Script" uid="uid://cfeoalic0mu2j" path="res://scripts/components/kill_player_out_of_screen.gd" id="37_oxudy"]
[ext_resource type="Script" uid="uid://d32kd83lf86iy" path="res://scripts/components/progressive_damage_component.gd" id="38_o1ihh"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xoue7"]
shader = ExtResource("2_lgb3u")
@@ -84,29 +83,33 @@ scale_curve = SubResource("CurveTexture_xoue7")
color = Color(0.764706, 0.443137, 0, 1)
color_ramp = SubResource("GradientTexture1D_lgb3u")
[node name="Brick Player" type="CharacterBody2D" node_paths=PackedStringArray("ShipSprite") groups=["player"]]
[node name="Brick Player" type="CharacterBody2D" node_paths=PackedStringArray("ship_sprite") groups=["player"]]
collision_layer = 4
collision_mask = 43
script = ExtResource("1_yysbb")
MovementTypes = Dictionary[String, NodePath]({
"platform": NodePath("Movements/PlatformMovement")
})
ShipSprite = NodePath("Graphics/Ship")
script = ExtResource("1_8j4h4")
movement_types = {
"platform": NodePath("Movements/PlatformMovement"),
"ship": NodePath("Movements/ShipMovement")
}
ship_sprite = NodePath("Graphics/Ship")
[node name="Movements" type="Node" parent="."]
[node name="PlatformMovement" type="Node2D" parent="Movements" node_paths=PackedStringArray("JumpSfx", "RotationTarget", "Body")]
script = ExtResource("2_o1ihh")
JumpSfx = NodePath("../../sfx_jump")
RotationTarget = NodePath("../../Graphics/Root/Base")
Body = NodePath("../..")
[node name="PlatformMovement" type="Node" parent="Movements" node_paths=PackedStringArray("jump_sfx", "rotation_target", "body")]
script = ExtResource("31_xoue7")
jump_sfx = NodePath("../../sfx_jump")
rotation_target = NodePath("../../Graphics/Root/Base")
body = NodePath("../..")
type = "platform"
[node name="ShipMovement" type="Node2D" parent="Movements" node_paths=PackedStringArray("Body")]
script = ExtResource("3_ur2y5")
MaxSpeed = 360.0
Acceleration = 1200.0
Friction = 800.0
Body = NodePath("../..")
[node name="ShipMovement" type="Node" parent="Movements" node_paths=PackedStringArray("body")]
script = ExtResource("3_p4n66")
max_speed = 360.0
acceleration = 1200.0
friction = 800.0
body = NodePath("../..")
type = "ship"
metadata/_custom_type_script = "uid://b3mrdvre1y567"
[node name="Graphics" type="Node2D" parent="."]
@@ -137,11 +140,11 @@ visible = false
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_hdsg1")
[node name="FlipPlayerComponent" type="Node2D" parent="." node_paths=PackedStringArray("LeftEye", "RightEye", "PlatformMovement")]
script = ExtResource("9_yysbb")
LeftEye = NodePath("../Graphics/Root/Left Eye")
RightEye = NodePath("../Graphics/Root/Right Eye")
PlatformMovement = NodePath("../Movements/PlatformMovement")
[node name="FlipPlayerComponent" type="Node2D" parent="." node_paths=PackedStringArray("eye_left", "eye_right", "platform_movement")]
script = ExtResource("5_geu10")
eye_left = NodePath("../Graphics/Root/Left Eye")
eye_right = NodePath("../Graphics/Root/Right Eye")
platform_movement = NodePath("../Movements/PlatformMovement")
[node name="StompDamageArea" type="Area2D" parent="."]
collision_layer = 0
@@ -153,57 +156,54 @@ position = Vector2(0, 1)
shape = SubResource("RectangleShape2D_vad0t")
[node name="CanPickUpComponent" type="Node" parent="."]
script = ExtResource("10_yysbb")
[node name="ScoreComponent" type="Node" parent="."]
script = ExtResource("11_o1ihh")
script = ExtResource("6_fowa2")
[node name="HealthComponent" type="Node2D" parent="." node_paths=PackedStringArray("HurtSfx", "HealSfx")]
script = ExtResource("12_ur2y5")
HurtSfx = NodePath("../sfx_hurt")
HealSfx = NodePath("../sfx_heal")
[node name="HealthComponent" type="Node" parent="." node_paths=PackedStringArray("hurt_fx", "heal_fx")]
script = ExtResource("7_tqjk8")
hurt_fx = NodePath("../sfx_hurt")
heal_fx = NodePath("../sfx_heal")
[node name="PlayerDeathComponent" type="Node2D" parent="." node_paths=PackedStringArray("DeathSfx", "HealthComponent")]
[node name="PlayerDeathComponent" type="Node2D" parent="."]
process_mode = 3
script = ExtResource("13_7til7")
DeathSfx = NodePath("../sfx_hurt")
HealthComponent = NodePath("../HealthComponent")
script = ExtResource("8_1v23d")
death_effect = ExtResource("9_hwg11")
[node name="KnockbackComponent" type="Node" parent="." node_paths=PackedStringArray("Body", "HealthComponent")]
script = ExtResource("14_e5pae")
Body = NodePath("..")
KnockbackForce = 1250.0
HealthComponent = NodePath("../HealthComponent")
[node name="KnockbackComponent" type="Node" parent="." node_paths=PackedStringArray("character_body")]
script = ExtResource("9_rjyu4")
character_body = NodePath("..")
knockback_force = 1500.0
[node name="ThrowTimer" type="Timer" parent="."]
[node name="InvulnerabilityComponent" type="Node" parent="." node_paths=PackedStringArray("FlashingComponent")]
script = ExtResource("15_xuhvf")
FlashingComponent = NodePath("../FlashingComponent Base")
[node name="InvulnerabilityComponent" type="Node" parent="." node_paths=PackedStringArray("flashing_component")]
script = ExtResource("14_jopig")
flashing_component = NodePath("../FlashingComponent Base")
[node name="FlashingComponent Base" type="Node" parent="." node_paths=PackedStringArray("Sprite", "HealthComponent")]
script = ExtResource("16_uno3u")
Sprite = NodePath("../Graphics/Root/Base")
FlashDuration = 1.0
HealthComponent = NodePath("../HealthComponent")
[node name="FlashingComponent Base" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component")]
script = ExtResource("13_hrtyn")
sprite = NodePath("../Graphics/Root/Base")
flash_duration = 1.0
health_component = NodePath("../HealthComponent")
[node name="FlashingComponent LEye" type="Node" parent="." node_paths=PackedStringArray("Sprite", "HealthComponent")]
script = ExtResource("16_uno3u")
Sprite = NodePath("../Graphics/Root/Left Eye")
FlashDuration = 1.0
HealthComponent = NodePath("../HealthComponent")
[node name="FlashingComponent LEye" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component")]
script = ExtResource("13_hrtyn")
sprite = NodePath("../Graphics/Root/Left Eye")
flash_duration = 1.0
health_component = NodePath("../HealthComponent")
[node name="FlashingComponent REye" type="Node" parent="." node_paths=PackedStringArray("Sprite", "HealthComponent")]
script = ExtResource("16_uno3u")
Sprite = NodePath("../Graphics/Root/Right Eye")
FlashDuration = 1.0
HealthComponent = NodePath("../HealthComponent")
[node name="FlashingComponent REye" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component")]
script = ExtResource("13_hrtyn")
sprite = NodePath("../Graphics/Root/Right Eye")
flash_duration = 1.0
health_component = NodePath("../HealthComponent")
[node name="StompDamageComponent" type="Node" parent="." node_paths=PackedStringArray("Area", "Root")]
script = ExtResource("17_bl1gx")
Damage = 4.0
Area = NodePath("../StompDamageArea")
Root = NodePath("..")
[node name="StompDamageComponent" type="Node" parent="." node_paths=PackedStringArray("area2d", "root")]
script = ExtResource("12_payr4")
damage = 4.0
area2d = NodePath("../StompDamageArea")
root = NodePath("..")
[node name="SkillManager" type="Node" parent="."]
script = ExtResource("20_ppfy7")
@@ -213,11 +213,11 @@ available_skills = Array[ExtResource("21_d0oiv")]([ExtResource("22_vnsgd"), ExtR
script = ExtResource("23_qsv2c")
skill_manager = NodePath("../SkillManager")
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("Sprite", "Health", "HitFx")]
script = ExtResource("26_6n1ss")
Sprite = NodePath("../Graphics/Root/Base")
Health = NodePath("../HealthComponent")
HitFx = NodePath("../HitParticles")
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component", "hit_fx")]
script = ExtResource("29_jh5m0")
sprite = NodePath("../Graphics/Root/Base")
health_component = NodePath("../HealthComponent")
hit_fx = NodePath("../HitParticles")
metadata/_custom_type_script = "uid://ceq8n7yw7qxpi"
[node name="MagneticArea" type="Area2D" parent="."]
@@ -229,10 +229,10 @@ visible = false
shape = SubResource("CircleShape2D_ps31c")
[node name="CanBeLaunchedComponent" type="Node" parent="."]
script = ExtResource("27_oefns")
script = ExtResource("16_kemlv")
[node name="TriggerLeverComponent" type="Node" parent="."]
script = ExtResource("28_bnap0")
script = ExtResource("17_hglfj")
[node name="sfx_jump" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("18_pysae")
@@ -250,13 +250,11 @@ bus = &"sfx"
stream = ExtResource("32_x2b7c")
bus = &"sfx"
[node name="ChargingBarLayer" parent="." node_paths=PackedStringArray("ProgressBar") instance=ExtResource("28_3f5nm")]
[node name="ChargingBarLayer" parent="." instance=ExtResource("28_3f5nm")]
offset_left = -17.0
offset_top = -30.0
offset_right = 23.0
offset_bottom = -20.0
script = ExtResource("34_o1ihh")
ProgressBar = NodePath(".")
[node name="HitParticles" parent="." instance=ExtResource("28_jh5m0")]
process_material = SubResource("ParticleProcessMaterial_lgb3u")
@@ -276,13 +274,18 @@ gizmo_extents = 1.0
position = Vector2(0, 3)
scale = Vector2(0.8, 1.9)
[node name="KillPlayerOutOfScreen" type="Node" parent="." node_paths=PackedStringArray("ScreenNotifier", "HealthComponent")]
script = ExtResource("37_qec3q")
ScreenNotifier = NodePath("../VisibleOnScreenNotifier2D")
HealthComponent = NodePath("../HealthComponent")
[node name="KillPlayerOutOfScreen" type="Node" parent="." node_paths=PackedStringArray("screen_notifier", "health_component")]
script = ExtResource("37_oxudy")
screen_notifier = NodePath("../VisibleOnScreenNotifier2D")
health_component = NodePath("../HealthComponent")
[node name="ProgressiveDamageComponent" type="Node" parent="." node_paths=PackedStringArray("HealthComponent", "Sprite", "PlatformMovement")]
script = ExtResource("38_dhjci")
HealthComponent = NodePath("../HealthComponent")
Sprite = NodePath("../Graphics/Root/Base")
PlatformMovement = NodePath("../Movements/PlatformMovement")
[node name="ProgressiveDamageComponent" type="Node" parent="." node_paths=PackedStringArray("health_component", "sprite", "platform_movement")]
script = ExtResource("38_o1ihh")
health_component = NodePath("../HealthComponent")
sprite = NodePath("../Graphics/Root/Base")
platform_movement = NodePath("../Movements/PlatformMovement")
min_jump_height = 100.0
jump_reduction_percentage = 0.15
[connection signal="on_death" from="HealthComponent" to="PlayerDeathComponent" method="_on_health_component_on_death"]
[connection signal="on_health_change" from="HealthComponent" to="KnockbackComponent" method="_on_health_component_on_health_change"]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://c1iorglk708g0"]
[ext_resource type="Script" uid="uid://cypxrqoeiihbf" path="res://scripts/components/TerrainHitFx.cs" id="1_22p6x"]
[ext_resource type="Script" uid="uid://djfejwp6e402k" path="res://scripts/components/terrain_hit_fx.gd" id="1_22p6x"]
[sub_resource type="GradientTexture1D" id="GradientTexture1D_6dbny"]

View File

@@ -62,9 +62,6 @@ process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="UI Layer" parent="." instance=ExtResource("2_lbnsn")]
[node name="HUD" parent="UI Layer" index="0" node_paths=PackedStringArray("player_health")]
player_health = NodePath("../../Brick Player/HealthComponent")
[node name="DeathScreen" parent="UI Layer" index="1" node_paths=PackedStringArray("nodes_to_disable")]
current_level = ExtResource("4_c2yv5")
nodes_to_disable = [NodePath("../../Brick Player")]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=11 format=3 uid="uid://6foggu31cu14"]
[ext_resource type="PackedScene" uid="uid://byxf45ukq82pe" path="res://objects/ui/hud.tscn" id="1_tgtfe"]
[ext_resource type="PackedScene" uid="uid://byxf45ukq82pe" path="res://features/ui/hud/hud.tscn" id="1_tgtfe"]
[ext_resource type="PackedScene" uid="uid://dulkm3ah4tm0u" path="res://objects/ui/death_screen.tscn" id="2_ln68j"]
[ext_resource type="Script" uid="uid://cp68km8bykymb" path="res://scripts/resources/level_resource.gd" id="3_5kt5k"]
[ext_resource type="PackedScene" uid="uid://wmw6gaisyrvx" path="res://objects/ui/game_over_screen.tscn" id="4_11xmk"]
@@ -34,9 +34,8 @@ visible = false
offset_top = 32.0
components_to_disable = [null]
[node name="Pause menu" parent="." node_paths=PackedStringArray("settings_menu") instance=ExtResource("6_1q4vn")]
[node name="Pause menu" parent="." instance=ExtResource("6_1q4vn")]
visible = false
settings_menu = NodePath("../Settings menu")
[node name="Settings menu" parent="." node_paths=PackedStringArray("input_settings", "audio_settings") instance=ExtResource("7_hkjav")]
visible = false

View File

@@ -1,12 +1,11 @@
[gd_scene load_steps=4 format=3 uid="uid://i6mnjbjcoqe5"]
[gd_scene load_steps=3 format=3 uid="uid://i6mnjbjcoqe5"]
[ext_resource type="Script" uid="uid://cugifchx6jhuk" path="res://scripts/ui/pause_menu.gd" id="1_aktha"]
[ext_resource type="PackedScene" uid="uid://cl00e2ocomk3m" path="res://scenes/main_menu.tscn" id="2_h4pd5"]
[ext_resource type="Script" uid="uid://bwgs02wcfnm8u" path="res://features/ui/menus/PauseMenu.cs" id="1_ljtns"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g4ivv"]
bg_color = Color(0, 0, 0, 1)
[node name="Pause menu" type="Control" node_paths=PackedStringArray("pause_menu_control", "resume_button", "quit_button", "settings_button", "exit_to_menu_button")]
[node name="Pause menu" type="Control" node_paths=PackedStringArray("ResumeButton", "RestartButton", "MainMenuButton")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -15,13 +14,10 @@ grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 6
size_flags_vertical = 6
script = ExtResource("1_aktha")
pause_menu_control = NodePath(".")
resume_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Resume Button")
quit_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Quit game Button")
settings_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Settings Button")
exit_to_menu_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Exit to menu Button")
exit_to_menu_scene = ExtResource("2_h4pd5")
script = ExtResource("1_ljtns")
ResumeButton = NodePath("PanelContainer/MarginContainer/VBoxContainer/Resume Button")
RestartButton = NodePath("PanelContainer/MarginContainer/VBoxContainer/Settings Button")
MainMenuButton = NodePath("PanelContainer/MarginContainer/VBoxContainer/Exit to menu Button")
[node name="PanelContainer" type="PanelContainer" parent="."]
layout_mode = 1

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bsnr5v2b2mfsl"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://bsnr5v2b2mfsl"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_wfbgp"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_fudbo"]
[resource]
script = ExtResource("1_wfbgp")
Amount = 5.0
Type = 0
script = ExtResource("1_fudbo")
amount = 5.0
type = 0

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://b6xqotmke54x"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://b6xqotmke54x"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_5mosu"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_037vi"]
[resource]
script = ExtResource("1_5mosu")
Amount = 50.0
Type = 0
script = ExtResource("1_037vi")
amount = 100.0
type = 0

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://b6apusc0jmi3x"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://b6apusc0jmi3x"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_d8txc"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_2d5tb"]
[resource]
script = ExtResource("1_d8txc")
Amount = 1.0
Type = 1
script = ExtResource("1_2d5tb")
amount = 1.0
type = 1

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://vql535ckoeqm"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://vql535ckoeqm"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_7pquc"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_veemo"]
[resource]
script = ExtResource("1_7pquc")
Amount = 1.0
Type = 0
script = ExtResource("1_veemo")
amount = 1.0
type = 0

View File

@@ -1,9 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://2tl3yoh202no"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://2tl3yoh202no"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_brkhb"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_brkhb"]
[resource]
script = ExtResource("1_brkhb")
Amount = 0.25
Type = 2
amount = 0.25
type = 2
metadata/_custom_type_script = "uid://cb5f0mx0hrt3b"

View File

@@ -1,8 +1,8 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bws2xldndlre1"]
[gd_resource type="Resource" script_class="CollectableResource" load_steps=2 format=3 uid="uid://bws2xldndlre1"]
[ext_resource type="Script" uid="uid://gptsgaw3agkf" path="res://scripts/Resources/CollectableResource.cs" id="1_clntw"]
[ext_resource type="Script" uid="uid://cb5f0mx0hrt3b" path="res://scripts/resources/collectable_resource.gd" id="1_w50p5"]
[resource]
script = ExtResource("1_clntw")
Amount = 50.0
Type = 0
script = ExtResource("1_w50p5")
amount = 50.0
type = 0

View File

@@ -1,23 +1,24 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://dw5ee2lpeypnb"]
[gd_resource type="Resource" script_class="SkillData" load_steps=5 format=3 uid="uid://dw5ee2lpeypnb"]
[ext_resource type="PackedScene" uid="uid://coayig4dxelo2" path="res://objects/player_skills/brick_throw_skill.tscn" id="1_5gnea"]
[ext_resource type="Script" uid="uid://bya240e627ti6" path="res://scripts/resources/skill_data.gd" id="1_etxe2"]
[ext_resource type="Resource" uid="uid://br84dsfa3ti04" path="res://resources/throw_behaviors/tap_throw_input.tres" id="1_xwijh"]
[ext_resource type="Texture2D" uid="uid://dxtdwgg3po0eg" path="res://sprites/brick_power_Skill_icon.png" id="2_yimbq"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="3_yimbq"]
[resource]
script = ExtResource("3_yimbq")
Name = "BRICK_POWER"
Description = "BRICK_POWER_DESCRIPTION"
Config = Dictionary[String, Variant]({
script = ExtResource("1_etxe2")
name = "BRICK_POWER"
description = "BRICK_POWER_DESCRIPTION"
node = ExtResource("1_5gnea")
config = {
"fire_rate": 0.6,
"player_controller": NodePath("."),
"throw_input_behavior": null,
"throw_input_behavior": ExtResource("1_xwijh"),
"timer": NodePath("ThrowTimer")
})
Cost = 50
Icon = ExtResource("2_yimbq")
IsActive = false
Level = 1
MaxLevel = 3
Type = 0
Node = ExtResource("1_5gnea")
}
cost = 50
icon = ExtResource("2_yimbq")
type = 1
is_active = false
level = 0
max_level = 3

View File

@@ -66,9 +66,6 @@ process_material = SubResource("ParticleProcessMaterial_lgb3u")
[node name="UI Layer" parent="." instance=ExtResource("3_4fsls")]
[node name="HUD" parent="UI Layer" index="0" node_paths=PackedStringArray("player_health")]
player_health = NodePath("../../Brick Player/HealthComponent")
[node name="DeathScreen" parent="UI Layer" index="1" node_paths=PackedStringArray("nodes_to_disable")]
current_level = ExtResource("4_onnch")
nodes_to_disable = [NodePath("../../Brick Player")]

View File

@@ -1,27 +1,38 @@
[gd_scene load_steps=6 format=3 uid="uid://cl00e2ocomk3m"]
[gd_scene load_steps=12 format=3 uid="uid://cl00e2ocomk3m"]
[ext_resource type="PackedScene" path="res://objects/ui/main_menu.tscn" id="1_ekxnf"]
[ext_resource type="PackedScene" uid="uid://8b6ol5sssbgo" path="res://features/ui/menus/main_menu.tscn" id="1_ekxnf"]
[ext_resource type="Script" uid="uid://dg2l7cw6da4vb" path="res://common/AppRoot.cs" id="1_rtw2f"]
[ext_resource type="PackedScene" uid="uid://y0ae6e7t70fj" path="res://objects/ui/settings_menu.tscn" id="2_bqqt6"]
[ext_resource type="PackedScene" uid="uid://bwgmrcyj4mvu" path="res://objects/ui/credits.tscn" id="3_bqqt6"]
[ext_resource type="PackedScene" uid="uid://chqb11pfoqmeb" path="res://scenes/level_village_2.tscn" id="3_lgwnu"]
[ext_resource type="PackedScene" uid="uid://bol7g83v2accs" path="res://scenes/level_village_1.tscn" id="3_oa1go"]
[ext_resource type="PackedScene" uid="uid://b5fx1vdfky307" path="res://objects/ui/audio_settings.tscn" id="4_8ln24"]
[ext_resource type="PackedScene" uid="uid://h60obxmju6mo" path="res://scenes/level_village_3.tscn" id="4_flqon"]
[ext_resource type="PackedScene" uid="uid://bhad760x3vvco" path="res://scenes/level_village_4.tscn" id="5_rcqid"]
[ext_resource type="PackedScene" uid="uid://cvfsbiy5ggrpg" path="res://objects/ui/input_settings.tscn" id="5_rtw2f"]
[ext_resource type="PackedScene" uid="uid://dagpmlgvr262d" path="res://scenes/level_forest_5.tscn" id="6_1ajci"]
[node name="Main menu" type="CanvasLayer"]
[node name="AppRoot" type="Node2D"]
script = ExtResource("1_rtw2f")
_levels = Array[PackedScene]([ExtResource("3_oa1go"), ExtResource("3_lgwnu"), ExtResource("4_flqon"), ExtResource("5_rcqid"), ExtResource("6_1ajci")])
_mainMenu = null
[node name="MainMenu" parent="." node_paths=PackedStringArray("settings_control", "credits_control") instance=ExtResource("1_ekxnf")]
settings_control = NodePath("../Settings menu")
credits_control = NodePath("../Credits")
[node name="Main menu" type="CanvasLayer" parent="."]
[node name="Settings menu" parent="." node_paths=PackedStringArray("input_settings", "audio_settings") instance=ExtResource("2_bqqt6")]
[node name="MainMenu" parent="Main menu" node_paths=PackedStringArray("SettingsControl", "CreditsControl") instance=ExtResource("1_ekxnf")]
SettingsControl = NodePath("../Settings menu")
CreditsControl = NodePath("../Credits")
[node name="Settings menu" parent="Main menu" node_paths=PackedStringArray("input_settings", "audio_settings") instance=ExtResource("2_bqqt6")]
visible = false
input_settings = NodePath("../Input Settings")
audio_settings = NodePath("../Audio settings")
[node name="Credits" parent="." instance=ExtResource("3_bqqt6")]
[node name="Credits" parent="Main menu" instance=ExtResource("3_bqqt6")]
visible = false
[node name="Audio settings" parent="." instance=ExtResource("4_8ln24")]
[node name="Audio settings" parent="Main menu" instance=ExtResource("4_8ln24")]
visible = false
[node name="Input Settings" parent="." instance=ExtResource("5_rtw2f")]
[node name="Input Settings" parent="Main menu" instance=ExtResource("5_rtw2f")]
visible = false

View File

@@ -4,6 +4,6 @@ namespace Mr.BrickAdventures.scripts.Resources;
public partial class CollectableResource : Resource
{
[Export] public float Amount { get; set; } = 0.0f;
[Export] public Variant Amount { get; set; } = 0.0;
[Export] public CollectableType Type { get; set; }
}

View File

@@ -1,43 +0,0 @@
using Godot;
using Mr.BrickAdventures.Autoloads;
using Mr.BrickAdventures.scripts.components;
namespace Mr.BrickAdventures.scripts.UI;
public partial class Hud : Node
{
[Export] public HealthComponent Health { get; set; }
[Export] public Label CoinsLabel { get; set; }
[Export] public ProgressBar HealthBar { get; set; }
[Export] public Label LivesLabel { get; set; }
private GameManager _gameManager;
public override void _Ready()
{
_gameManager = GetNode<GameManager>("/root/GameManager");
}
public override void _Process(double delta)
{
SetHealthBar();
SetLivesLabel();
SetCoinsLabel();
}
private void SetCoinsLabel()
{
CoinsLabel.Text = Tr("COINS_LABEL") + ": " + _gameManager.GetCoins();
}
private void SetLivesLabel()
{
LivesLabel.Text = Tr("LIVES_LABEL") + ": " + _gameManager.GetLives();
}
private void SetHealthBar()
{
HealthBar.Value = Health.Health;
HealthBar.MaxValue = Health.MaxHealth;
}
}

View File

@@ -1 +0,0 @@
uid://wfj674u4486f

View File

@@ -13,7 +13,7 @@ public partial class CollectableComponent : Node
[Export] public CollectableResource Data { get; set; }
[Export] public AudioStreamPlayer2D Sfx {get; set; }
[Signal] public delegate void CollectedEventHandler(float amount, CollectableType type, Node2D body);
[Signal] public delegate void CollectedEventHandler(Variant amount, CollectableType type, Node2D body);
public override void _Ready()
{

View File

@@ -19,7 +19,7 @@ public partial class HealComponent : Node
Collectable.Collected += OnCollected;
}
private void OnCollected(float amount, CollectableType type, Node2D body)
private void OnCollected(Variant amount, CollectableType type, Node2D body)
{
if (type != CollectableType.Health) return;
@@ -28,7 +28,8 @@ public partial class HealComponent : Node
var healthComponent = body.GetNodeOrNull<HealthComponent>("HealthComponent");
if (healthComponent == null) return;
healthComponent.IncreaseHealth(amount);
var value = amount.AsSingle();
healthComponent.IncreaseHealth(value);
if (HealFx != null)
{
PlayHealFx();

View File

@@ -28,9 +28,9 @@ public partial class RequirementComponent : Node
}
}
private void OnCollected(float amount, CollectableType type, Node2D body)
private void OnCollected(Variant amount, CollectableType type, Node2D body)
{
AddProgress((int)amount);
AddProgress(amount.As<int>());
}
private void AddProgress(int amount = 1)

View File

@@ -31,11 +31,11 @@ public partial class ScoreComponent : Node
}
}
private void OnCollected(float amount, CollectableType type, Node2D body)
private void OnCollected(Variant amount, CollectableType type, Node2D body)
{
if (type != CollectableType.Coin) return;
var coinAmount = (int)amount;
var coinAmount = amount.As<int>();
var currentCoins = (int)_gameManager.CurrentSessionState["coins_collected"];
_gameManager.CurrentSessionState["coins_collected"] = currentCoins + coinAmount;
}