Add new skills: Double Jump, Ground Pound, Brick Armor, and Brick Shield; implement skill removal signal in SkillManager (#11)

This commit is contained in:
2025-08-31 15:17:11 +02:00
committed by GitHub
parent bd40c797d4
commit ead52f6d51
89 changed files with 682 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
using Godot;
using Mr.BrickAdventures.scripts.interfaces;
using Mr.BrickAdventures.scripts.Resources;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class BrickArmorSkillComponent : Node, ISkill
{
private HealthComponent _healthComponent;
private SkillData _skillData;
private float _armorBonus = 0;
public void Initialize(Node owner, SkillData data)
{
if (owner is not PlayerController player) return;
_healthComponent = player.GetNode<HealthComponent>("HealthComponent");
_skillData = data;
}
public void Activate()
{
if (_healthComponent == null || _skillData == null) return;
ApplyUpgrade(_skillData.Upgrades[_skillData.Level - 1]);
}
public void Deactivate()
{
if (_healthComponent == null) return;
_healthComponent.MaxHealth -= _armorBonus;
if (_healthComponent.Health > _healthComponent.MaxHealth)
{
_healthComponent.SetHealth(_healthComponent.MaxHealth);
}
_armorBonus = 0;
}
public void ApplyUpgrade(SkillUpgrade upgrade)
{
if (_healthComponent == null || upgrade == null) return;
_healthComponent.MaxHealth -= _armorBonus;
_armorBonus = (float)upgrade.Properties["health_bonus"];
_healthComponent.MaxHealth += _armorBonus;
_healthComponent.IncreaseHealth(_armorBonus);
}
}