refactor #6
@@ -1,5 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.Autoloads;
|
namespace Mr.BrickAdventures.Autoloads;
|
||||||
@@ -15,7 +16,7 @@ public partial class AchievementManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
LoadAchievementsFromFolder();
|
LoadAchievementsFromFolder();
|
||||||
LoadUnlockedAchievements();
|
LoadUnlockedAchievements();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.Autoloads;
|
namespace Mr.BrickAdventures.Autoloads;
|
||||||
@@ -12,9 +13,9 @@ public partial class ConsoleManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_achievementManager = GetNode<AchievementManager>("/root/AchievementManager");
|
_achievementManager = GetNode<AchievementManager>(Constants.AchievementManagerPath);
|
||||||
_skillManager = GetNode<SkillManager>("/root/SkillManager");
|
_skillManager = GetNode<SkillManager>(Constants.SkillManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddCoinsCommand(int amount)
|
private void AddCoinsCommand(int amount)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
using Double = System.Double;
|
using Double = System.Double;
|
||||||
@@ -55,7 +56,7 @@ public partial class GameManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_speedRunManager = GetNode<SpeedRunManager>("/root/SpeedRunManager");
|
_speedRunManager = GetNode<SpeedRunManager>(Constants.SpeedRunManagerPath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ public partial class GameManager : Node
|
|||||||
ResetPlayerState();
|
ResetPlayerState();
|
||||||
ResetCurrentSessionState();
|
ResetCurrentSessionState();
|
||||||
GetTree().ChangeSceneToPacked(LevelScenes[0]);
|
GetTree().ChangeSceneToPacked(LevelScenes[0]);
|
||||||
GetNode<SaveSystem>("/root/SaveSystem").SaveGame();
|
GetNode<SaveSystem>(Constants.SaveSystemPath).SaveGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QuitGame() => GetTree().Quit();
|
public void QuitGame() => GetTree().Quit();
|
||||||
@@ -202,12 +203,12 @@ public partial class GameManager : Node
|
|||||||
_speedRunManager?.StartTimer();
|
_speedRunManager?.StartTimer();
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(LevelScenes[0]);
|
GetTree().ChangeSceneToPacked(LevelScenes[0]);
|
||||||
GetNode<SaveSystem>("/root/SaveSystem").SaveGame();
|
GetNode<SaveSystem>(Constants.SaveSystemPath).SaveGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ContinueGame()
|
public void ContinueGame()
|
||||||
{
|
{
|
||||||
var save = GetNode<SaveSystem>("/root/SaveSystem");
|
var save = GetNode<SaveSystem>(Constants.SaveSystemPath);
|
||||||
if (!save.LoadGame())
|
if (!save.LoadGame())
|
||||||
{
|
{
|
||||||
GD.PrintErr("Failed to load game. Starting a new game instead.");
|
GD.PrintErr("Failed to load game. Starting a new game instead.");
|
||||||
@@ -236,7 +237,7 @@ public partial class GameManager : Node
|
|||||||
|
|
||||||
ResetCurrentSessionState();
|
ResetCurrentSessionState();
|
||||||
TryToGoToNextLevel();
|
TryToGoToNextLevel();
|
||||||
GetNode<SaveSystem>("/root/SaveSystem").SaveGame();
|
GetNode<SaveSystem>(Constants.SaveSystemPath).SaveGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Array<SkillData> GetUnlockedSkills()
|
public Array<SkillData> GetUnlockedSkills()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.Autoloads;
|
namespace Mr.BrickAdventures.Autoloads;
|
||||||
@@ -13,7 +14,7 @@ public partial class SaveSystem : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveGame()
|
public void SaveGame()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.interfaces;
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -24,7 +25,7 @@ public partial class SkillManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.Autoloads;
|
namespace Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
@@ -11,8 +12,8 @@ public partial class StatisticsManager : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_achievementManager = GetNode<AchievementManager>("/root/AchievementManager");
|
_achievementManager = GetNode<AchievementManager>(Constants.AchievementManagerPath);
|
||||||
LoadStatistics();
|
LoadStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public static class Constants
|
|||||||
public const string FloatingTextManagerPath = "/root/FloatingTextManager";
|
public const string FloatingTextManagerPath = "/root/FloatingTextManager";
|
||||||
public const string UIManagerPath = "/root/UIManager";
|
public const string UIManagerPath = "/root/UIManager";
|
||||||
public const string ConsoleManagerPath = "/root/ConsoleManager";
|
public const string ConsoleManagerPath = "/root/ConsoleManager";
|
||||||
|
public const string ConfigFileHandlerPath = "/root/ConfigFileHandler";
|
||||||
|
|
||||||
// Group names
|
// Group names
|
||||||
public const string CoinsGroup = "coins";
|
public const string CoinsGroup = "coins";
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -16,8 +17,8 @@ public partial class AudioSettings : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_uiManager = GetNode<UIManager>("/root/UIManager");
|
_uiManager = GetNode<UIManager>(Constants.UIManagerPath);
|
||||||
_configFileHandler = GetNode<ConfigFileHandler>("/root/ConfigFileHandler");
|
_configFileHandler = GetNode<ConfigFileHandler>(Constants.ConfigFileHandlerPath);
|
||||||
Initialize();
|
Initialize();
|
||||||
MasterVolumeSlider.ValueChanged += OnMasterVolumeChanged;
|
MasterVolumeSlider.ValueChanged += OnMasterVolumeChanged;
|
||||||
MusicVolumeSlider.ValueChanged += OnMusicVolumeChanged;
|
MusicVolumeSlider.ValueChanged += OnMusicVolumeChanged;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -17,7 +18,7 @@ public partial class ChargeProgressBar : ProgressBar
|
|||||||
{
|
{
|
||||||
ProgressBar.Hide();
|
ProgressBar.Hide();
|
||||||
|
|
||||||
_skillManager = GetNodeOrNull<SkillManager>("/root/SkillManager");
|
_skillManager = GetNodeOrNull<SkillManager>(Constants.SkillManagerPath);
|
||||||
if (_skillManager == null)
|
if (_skillManager == null)
|
||||||
{
|
{
|
||||||
GD.PrintErr("ChargeProgressBar: SkillManager autoload not found.");
|
GD.PrintErr("ChargeProgressBar: SkillManager autoload not found.");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -9,7 +10,7 @@ public partial class Credits : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_uiManager = GetNode<UIManager>("/root/UIManager");
|
_uiManager = GetNode<UIManager>(Constants.UIManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event)
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ public partial class DeathScreen : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
SetLabels();
|
SetLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -14,7 +15,7 @@ public partial class GameOverScreen : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
RestartButton.Pressed += OnRestartClicked;
|
RestartButton.Pressed += OnRestartClicked;
|
||||||
MainMenuButton.Pressed += OnMainMenuClicked;
|
MainMenuButton.Pressed += OnMainMenuClicked;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ public partial class Hud : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -21,9 +22,9 @@ public partial class MainMenu : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_saveSystem = GetNode<SaveSystem>("/root/SaveSystem");
|
_saveSystem = GetNode<SaveSystem>(Constants.SaveSystemPath);
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_uiManager = GetNode<UIManager>("/root/UIManager");
|
_uiManager = GetNode<UIManager>(Constants.UIManagerPath);
|
||||||
|
|
||||||
NewGameButton.Pressed += OnNewGamePressed;
|
NewGameButton.Pressed += OnNewGamePressed;
|
||||||
ContinueButton.Pressed += OnContinuePressed;
|
ContinueButton.Pressed += OnContinuePressed;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -25,8 +26,8 @@ public partial class Marketplace : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_skillManager = GetNode<SkillManager>("/root/SkillManager");
|
_skillManager = GetNode<SkillManager>(Constants.SkillManagerPath);
|
||||||
_skillManager.SkillRemoved += OnSkillRemoved;
|
_skillManager.SkillRemoved += OnSkillRemoved;
|
||||||
|
|
||||||
Skills = _skillManager.AvailableSkills;
|
Skills = _skillManager.AvailableSkills;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -18,7 +19,7 @@ public partial class MarketplaceButton : Button
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
var player = _gameManager.Player;
|
var player = _gameManager.Player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ public partial class MarketplaceButton : Button
|
|||||||
_skillUnlockerComponent.SkillUnlocked += OnSkillStateChanged;
|
_skillUnlockerComponent.SkillUnlocked += OnSkillStateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
_skillManager = GetNode<SkillManager>("/root/SkillManager");
|
_skillManager = GetNode<SkillManager>(Constants.SkillManagerPath);
|
||||||
_skillManager.SkillRemoved += OnSkillStateChanged;
|
_skillManager.SkillRemoved += OnSkillStateChanged;
|
||||||
|
|
||||||
UpdateButtonState();
|
UpdateButtonState();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -18,8 +19,8 @@ public partial class PauseMenu : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_uiManager = GetNode<UIManager>("/root/UIManager");
|
_uiManager = GetNode<UIManager>(Constants.UIManagerPath);
|
||||||
|
|
||||||
ResumeButton.Pressed += OnResumePressed;
|
ResumeButton.Pressed += OnResumePressed;
|
||||||
MainMenuButton.Pressed += OnMainMenuPressed;
|
MainMenuButton.Pressed += OnMainMenuPressed;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -19,7 +20,7 @@ public partial class SettingsMenu : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_uiManager = GetNode<UIManager>("/root/UIManager");
|
_uiManager = GetNode<UIManager>(Constants.UIManagerPath);
|
||||||
|
|
||||||
InputSettingsButton.Pressed += OnInputSettingsPressed;
|
InputSettingsButton.Pressed += OnInputSettingsPressed;
|
||||||
AudioSettingsButton.Pressed += OnAudioSettingsPressed;
|
AudioSettingsButton.Pressed += OnAudioSettingsPressed;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.UI;
|
namespace Mr.BrickAdventures.scripts.UI;
|
||||||
@@ -12,7 +13,7 @@ public partial class SpeedRunHud : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_speedRunManager = GetNode<SpeedRunManager>("/root/SpeedRunManager");
|
_speedRunManager = GetNode<SpeedRunManager>(Constants.SpeedRunManagerPath);
|
||||||
|
|
||||||
_speedRunManager.TimeUpdated += OnTimerUpdated;
|
_speedRunManager.TimeUpdated += OnTimerUpdated;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.interfaces;
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -19,8 +20,8 @@ public partial class BrickShieldSkillComponent : Node, ISkill
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_skillManager = GetNode<SkillManager>("/root/SkillManager");
|
_skillManager = GetNode<SkillManager>(Constants.SkillManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(Node owner, SkillData data)
|
public void Initialize(Node owner, SkillData data)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.interfaces;
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
|
|
||||||
@@ -20,8 +21,8 @@ public partial class ExitDoorComponent : Area2D, IUnlockable
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
_achievementManager = GetNode<AchievementManager>("/root/AchievementManager");
|
_achievementManager = GetNode<AchievementManager>(Constants.AchievementManagerPath);
|
||||||
|
|
||||||
BodyEntered += OnExitAreaBodyEntered;
|
BodyEntered += OnExitAreaBodyEntered;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
@@ -20,7 +21,7 @@ public partial class LeverComponent : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_floatingTextManager = GetNode<FloatingTextManager>("/root/FloatingTextManager");
|
_floatingTextManager = GetNode<FloatingTextManager>(Constants.FloatingTextManagerPath);
|
||||||
|
|
||||||
if (Area == null)
|
if (Area == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
@@ -33,7 +34,7 @@ public partial class PlayerController : CharacterBody2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
var skillManager = GetNodeOrNull<SkillManager>("/root/SkillManager");
|
var skillManager = GetNodeOrNull<SkillManager>(Constants.SkillManagerPath);
|
||||||
skillManager?.RegisterPlayer(this);
|
skillManager?.RegisterPlayer(this);
|
||||||
|
|
||||||
_inputHandler = GetNode<PlayerInputHandler>("PlayerInputHandler");
|
_inputHandler = GetNode<PlayerInputHandler>("PlayerInputHandler");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
@@ -15,7 +16,7 @@ public partial class PlayerDeathComponent : Node2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
HealthComponent.Death += OnDeath;
|
HealthComponent.Death += OnDeath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
using Mr.BrickAdventures.Autoloads;
|
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
|
||||||
|
|
||||||
[GlobalClass]
|
|
||||||
public partial class ScoreComponent : Node
|
|
||||||
{
|
|
||||||
private GameManager _gameManager;
|
|
||||||
private const string CoinsGroupName = "coins";
|
|
||||||
|
|
||||||
public override async void _Ready()
|
|
||||||
{
|
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
|
||||||
|
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
|
||||||
if (_gameManager == null)
|
|
||||||
{
|
|
||||||
GD.PrintErr("GameManager not found in the scene tree.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var coins = GetTree().GetNodesInGroup(CoinsGroupName);
|
|
||||||
foreach (var coin in coins)
|
|
||||||
{
|
|
||||||
var c = coin.GetNodeOrNull<CollectableComponent>("CollectableComponent");
|
|
||||||
if (c != null)
|
|
||||||
{
|
|
||||||
c.Collected += OnCollected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCollected(float amount, CollectableType type, Node2D body)
|
|
||||||
{
|
|
||||||
if (type != CollectableType.Coin) return;
|
|
||||||
|
|
||||||
var coinAmount = (int)amount;
|
|
||||||
var currentCoins = (int)_gameManager.CurrentSessionState["coins_collected"];
|
|
||||||
_gameManager.CurrentSessionState["coins_collected"] = currentCoins + coinAmount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://ccqb8kd5m0eh7
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Mr.BrickAdventures;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.interfaces;
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
@@ -18,8 +19,8 @@ public partial class SkillUnlockerComponent : Node
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>(Constants.GameManagerPath);
|
||||||
SkillManager = GetNode<SkillManager>("/root/SkillManager");
|
SkillManager = GetNode<SkillManager>(Constants.SkillManagerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasEnoughCoins(int amount)
|
private bool HasEnoughCoins(int amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user