Compare commits

..

3 Commits

22 changed files with 282 additions and 94 deletions

View File

@@ -247,11 +247,12 @@ bus = &"sfx"
stream = ExtResource("32_x2b7c")
bus = &"sfx"
[node name="ChargingBarLayer" parent="." instance=ExtResource("28_3f5nm")]
[node name="ChargingBarLayer" parent="." node_paths=PackedStringArray("_skillManager") instance=ExtResource("28_3f5nm")]
offset_left = -17.0
offset_top = -30.0
offset_right = 23.0
offset_bottom = -20.0
_skillManager = NodePath("../SkillManager")
[node name="HitParticles" parent="." instance=ExtResource("28_jh5m0")]
process_material = SubResource("ParticleProcessMaterial_lgb3u")

View File

@@ -1,17 +1,18 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://dw5ee2lpeypnb"]
[gd_resource type="Resource" load_steps=6 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="Texture2D" uid="uid://dxtdwgg3po0eg" path="res://sprites/brick_power_Skill_icon.png" id="2_yimbq"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="3_lt17o"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="3_yimbq"]
[ext_resource type="Resource" uid="uid://d0qk7kh47b4pu" path="res://resources/skills/upgrades/brick_throw/upgrade_1.tres" id="4_nhovl"]
[resource]
script = ExtResource("3_yimbq")
Name = "BRICK_POWER"
Description = "BRICK_POWER_DESCRIPTION"
Cost = 50
Icon = ExtResource("2_yimbq")
IsActive = false
Level = 1
MaxLevel = 3
Type = 1
Node = ExtResource("1_5gnea")
Upgrades = Array[ExtResource("3_lt17o")]([ExtResource("4_nhovl")])

View File

@@ -1,17 +1,18 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://cdp8sex36vdq2"]
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://cdp8sex36vdq2"]
[ext_resource type="PackedScene" uid="uid://cfses3kn3y8qw" path="res://objects/player_skills/exploding_brick_throw_skill.tscn" id="2_gt8f6"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="3_txev8"]
[ext_resource type="Texture2D" uid="uid://c0xtjfpmkfolk" path="res://sprites/explosive_brick_skill_icon.png" id="3_wkqmb"]
[ext_resource type="Resource" uid="uid://c50advf65oi8c" path="res://resources/skills/upgrades/explosive_brick/upgrade_1.tres" id="4_1x338"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_wkqmb"]
[resource]
script = ExtResource("5_wkqmb")
Name = "EXPLOSIVE_BRICK"
Description = "EXPLOSIVE_BRICK_DESCRIPTION"
Cost = 180
Icon = ExtResource("3_wkqmb")
IsActive = false
Level = 0
MaxLevel = 1
Type = 1
Node = ExtResource("2_gt8f6")
Upgrades = Array[ExtResource("3_txev8")]([ExtResource("4_1x338")])

View File

@@ -1,17 +1,18 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://cr5lo4h8wm0jc"]
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://cr5lo4h8wm0jc"]
[ext_resource type="PackedScene" uid="uid://dfm2you3v5ap4" path="res://objects/player_skills/fire_brick_throw_skill.tscn" id="2_d6y6i"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="3_1ooyb"]
[ext_resource type="Texture2D" uid="uid://cocbnr38qsikt" path="res://sprites/fire_brick_skill_icon.png" id="3_w87qb"]
[ext_resource type="Resource" uid="uid://dmfiqqjmfa7m3" path="res://resources/skills/upgrades/fire_brick/upgrade_1.tres" id="4_aj7vs"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_us7vb"]
[resource]
script = ExtResource("5_us7vb")
Name = "FIRE_BRICK"
Description = "FIRE_BIRCK_DESCRIPTION"
Cost = 150
Icon = ExtResource("3_w87qb")
IsActive = false
Level = 0
MaxLevel = 3
Type = 1
Node = ExtResource("2_d6y6i")
Upgrades = Array[ExtResource("3_1ooyb")]([ExtResource("4_aj7vs")])

View File

@@ -1,17 +1,18 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://ceakv6oqob6m7"]
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://ceakv6oqob6m7"]
[ext_resource type="PackedScene" uid="uid://dpmmacva7qf8j" path="res://objects/player_skills/ice_brick_throw_skill.tscn" id="2_gm1ka"]
[ext_resource type="Texture2D" uid="uid://c1qaxspv8aemf" path="res://sprites/ice_brick_skill_icon.png" id="3_6btth"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="3_e3cb0"]
[ext_resource type="Resource" uid="uid://myr57ylobqkn" path="res://resources/skills/upgrades/ice_brick/upgrade_1.tres" id="4_3pbub"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_57pl3"]
[resource]
script = ExtResource("5_57pl3")
Name = "ICE_BRICK"
Description = "ICE_BRICK_DESCRIPTION"
Cost = 180
Icon = ExtResource("3_6btth")
IsActive = false
Level = 0
MaxLevel = 3
Type = 1
Node = ExtResource("2_gm1ka")
Upgrades = Array[ExtResource("3_e3cb0")]([ExtResource("4_3pbub")])

View File

@@ -1,22 +1,18 @@
[gd_resource type="Resource" load_steps=4 format=3 uid="uid://d3bjre2etov1n"]
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://d3bjre2etov1n"]
[ext_resource type="Texture2D" uid="uid://cvhoq7aubxlmq" path="res://sprites/ui/magnetic_skill_icon.png" id="1_16qcg"]
[ext_resource type="PackedScene" uid="uid://cunyndudjh2he" path="res://objects/player_skills/magnetic_skill.tscn" id="1_er41s"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="3_0j4wg"]
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="3_htb6q"]
[ext_resource type="Resource" uid="uid://dte14sxesjm3y" path="res://resources/skills/upgrades/magnetic/upgrade_1.tres" id="4_0hjrs"]
[resource]
script = ExtResource("3_htb6q")
Name = "MAGNETIC"
Description = "MAGNETIC_DESCRIPTION"
Config = Dictionary[String, Variant]({
"magnetic_area": NodePath("MagneticArea"),
"magnetic_move_duration": 1.25,
"root": NodePath(".")
})
Cost = 70
Icon = ExtResource("1_16qcg")
IsActive = false
Level = 1
MaxLevel = 1
Type = 2
Node = ExtResource("1_er41s")
Upgrades = Array[ExtResource("3_0j4wg")]([ExtResource("4_0hjrs")])

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="SkillUpgrade" load_steps=2 format=3 uid="uid://d0qk7kh47b4pu"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="1_1l84l"]
[resource]
script = ExtResource("1_1l84l")
Cost = 50
Description = "Upgrade Description"
Properties = Dictionary[String, Variant]({
"FireRate": 0.6
})
metadata/_custom_type_script = "uid://dwb0e05pewcsn"

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="SkillUpgrade" load_steps=2 format=3 uid="uid://c50advf65oi8c"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="1_0hsac"]
[resource]
script = ExtResource("1_0hsac")
Cost = 240
Description = "Upgrade Description"
Properties = Dictionary[String, Variant]({
"FireRate": 0.6
})
metadata/_custom_type_script = "uid://dwb0e05pewcsn"

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="SkillUpgrade" load_steps=2 format=3 uid="uid://dmfiqqjmfa7m3"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="1_fyb20"]
[resource]
script = ExtResource("1_fyb20")
Cost = 150
Description = "Upgrade Description"
Properties = Dictionary[String, Variant]({
"FireRate": 0.6
})
metadata/_custom_type_script = "uid://dwb0e05pewcsn"

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="SkillUpgrade" load_steps=2 format=3 uid="uid://myr57ylobqkn"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="1_bfa1e"]
[resource]
script = ExtResource("1_bfa1e")
Cost = 140
Description = "Upgrade Description"
Properties = Dictionary[String, Variant]({
"FireRate": 0.6
})
metadata/_custom_type_script = "uid://dwb0e05pewcsn"

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="SkillUpgrade" load_steps=2 format=3 uid="uid://dte14sxesjm3y"]
[ext_resource type="Script" uid="uid://dwb0e05pewcsn" path="res://scripts/Resources/SkillUpgrade.cs" id="1_dkk4n"]
[resource]
script = ExtResource("1_dkk4n")
Cost = 70
Description = "Upgrade Description"
Properties = Dictionary[String, Variant]({
"FireRate": 0.6
})
metadata/_custom_type_script = "uid://dwb0e05pewcsn"

View File

@@ -8,11 +8,12 @@ public partial class SkillData : Resource
{
[Export] public string Name { get; set; } = "New Skill";
[Export] public string Description { get; set; } = "New Skill";
[Export] public int Cost { get; set; } = 0;
[Export] public Texture2D Icon { get; set; }
[Export] public bool IsActive { get; set; } = false;
[Export] public int Level { get; set; } = 1;
[Export] public int MaxLevel { get; set; } = 1;
[Export] public SkillType Type { get; set; } = SkillType.Throw;
[Export] public PackedScene Node { get; set; }
[Export] public Array<SkillUpgrade> Upgrades { get; set; } = [];
public int MaxLevel => Upgrades.Count;
}

View File

@@ -0,0 +1,12 @@
using Godot;
using Godot.Collections;
namespace Mr.BrickAdventures.scripts.Resources;
[GlobalClass]
public partial class SkillUpgrade : Resource
{
[Export] public int Cost { get; set; } = 50;
[Export(PropertyHint.MultilineText)] public string Description { get; set; } = "Upgrade Description";
[Export] public Dictionary<string, Variant> Properties { get; set; } = new();
}

View File

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

View File

@@ -1,6 +1,7 @@
using Godot;
using Godot.Collections;
using Mr.BrickAdventures.Autoloads;
using Mr.BrickAdventures.scripts.components;
using Mr.BrickAdventures.scripts.interfaces;
using Mr.BrickAdventures.scripts.Resources;
@@ -10,9 +11,12 @@ public partial class SkillManager : Node
{
private GameManager _gameManager;
[Export] public Array<SkillData> AvailableSkills { get; set; } = [];
public Dictionary ActiveComponents { get; private set; } = new();
[Signal]
public delegate void ActiveThrowSkillChangedEventHandler(BrickThrowComponent throwComponent);
public override void _Ready()
{
_gameManager = GetNode<GameManager>("/root/GameManager");
@@ -46,7 +50,7 @@ public partial class SkillManager : Node
var instance = skillData.Node.Instantiate();
if (instance is ISkill skill)
{
skill.Initialize(Owner);
skill.Initialize(Owner, skillData);
skill.Activate();
}
else
@@ -58,12 +62,22 @@ public partial class SkillManager : Node
Owner.AddChild(instance);
ActiveComponents[skillData.Name] = instance;
if (instance is BrickThrowComponent btc)
{
EmitSignalActiveThrowSkillChanged(btc);
}
}
public void RemoveSkill(string skillName)
{
if (!ActiveComponents.TryGetValue(skillName, out var component))
return;
if (component.AsGodotObject() is BrickThrowComponent)
{
EmitSignalActiveThrowSkillChanged(null);
}
var inst = (Node)component;
if (inst is ISkill skill)

View File

@@ -1,4 +1,5 @@
using Godot;
using Mr.BrickAdventures.Autoloads;
using Mr.BrickAdventures.scripts.components;
using Mr.BrickAdventures.scripts.Resources;
@@ -7,32 +8,57 @@ namespace Mr.BrickAdventures.scripts.UI;
public partial class ChargeProgressBar : ProgressBar
{
[Export] public ProgressBar ProgressBar { get; set; }
[Export] public BrickThrowComponent ThrowComponent { get; set; }
[Export] private SkillManager _skillManager;
private BrickThrowComponent _throwComponent;
private ChargeThrowInputResource _throwInput;
public override void _Ready()
{
Owner.ChildEnteredTree += OnNodeEntered;
ProgressBar.Hide();
SetupDependencies();
}
private void OnNodeEntered(Node node)
{
if (node is not BrickThrowComponent throwComponent || ThrowComponent != null) return;
ThrowComponent = throwComponent;
SetupDependencies();
}
private void SetupDependencies()
{
if (ThrowComponent == null || ProgressBar == null)
if (_skillManager == null)
{
return;
}
if (ThrowComponent.ThrowInputBehavior is ChargeThrowInputResource throwInput)
_skillManager.ActiveThrowSkillChanged += OnActiveThrowSkillChanged;
SetupDependencies();
}
private void OnActiveThrowSkillChanged(BrickThrowComponent throwComponent)
{
OnOwnerExiting();
if (throwComponent == null) return;
_throwComponent = throwComponent;
_throwComponent.TreeExiting += OnOwnerExiting;
SetupDependencies();
}
private void OnOwnerExiting()
{
if (_throwInput != null)
{
_throwInput.ChargeStarted -= OnChargeStarted;
_throwInput.ChargeStopped -= OnChargeStopped;
_throwInput.ChargeUpdated -= OnChargeUpdated;
_throwInput = null;
}
_throwComponent = null;
}
private void SetupDependencies()
{
if (_throwComponent == null || ProgressBar == null)
{
return;
}
if (_throwComponent.ThrowInputBehavior is ChargeThrowInputResource throwInput)
{
_throwInput = throwInput;
}

View File

@@ -35,12 +35,12 @@ public partial class Marketplace : Control
var unlockedSkills = _gameManager.GetUnlockedSkills();
foreach (var skill in unlockedSkills) CreateSkillButton(skill);
SkillUnlockerComponent.SkillUnlocked += OnSkillUnlocker;
SkillUnlockerComponent.SkillUnlocked += OnSkillUnlocked;
}
public override void _ExitTree()
{
SkillUnlockerComponent.SkillUnlocked -= OnSkillUnlocker;
SkillUnlockerComponent.SkillUnlocked -= OnSkillUnlocked;
}
public override void _Input(InputEvent @event)
@@ -59,21 +59,24 @@ public partial class Marketplace : Control
}
}
private string GetButtonText(SkillData skill)
private void OnSkillUnlocked(SkillData skill)
{
return $"{Tr(skill.Name)} {skill.Cost}";
}
private void OnSkillUnlocker(SkillData skill)
{
if (_skillButtons.Count == 0) CreateSkillButton(skill);
var buttonExists = false;
foreach (var existingButton in _skillButtons)
{
if (existingButton.Name == skill.Name)
{
buttonExists = true;
break;
}
}
if (!buttonExists) CreateSkillButton(skill);
foreach (var btn in _skillButtons)
{
if (btn.Data.IsActive)
btn.Activate();
else
btn.Deactivate();
if (btn.Data.IsActive) btn.Activate();
else btn.Deactivate();
}
}
@@ -93,7 +96,6 @@ public partial class Marketplace : Control
private void CreateUpgradeButton(SkillData skill)
{
var button = MarketplaceButtonScene.Instantiate<MarketplaceButton>();
button.Text = GetButtonText(skill);
button.Data = skill;
button.Icon = skill.Icon;
button.Pressed += () => OnUpgradeButtonPressed(skill);
@@ -123,20 +125,16 @@ public partial class Marketplace : Control
}
}
private void RemoveButton(SkillData skill)
{
foreach (var node in ToUnlockGrid.GetChildren())
{
var child = (Button)node;
if (child.Text != GetButtonText(skill)) continue;
child.QueueFree();
break;
}
}
private void OnSkillButtonPressed(SkillButton button)
{
SkillUnlockerComponent.SkillManager.ToggleSkillActivation(button.Data);
foreach (var btn in _skillButtons)
{
if (btn.Data.IsActive)
btn.Activate();
else
btn.Deactivate();
}
}
}

View File

@@ -18,45 +18,73 @@ public partial class MarketplaceButton : Button
public override void _Ready()
{
_gameManager = GetNode<GameManager>("/root/GameManager");
Setup();
var player = _gameManager.Player;
var skillUnlockerComponent = player?.GetNodeOrNull<SkillUnlockerComponent>("SkillUnlockerComponent");
if (skillUnlockerComponent == null) return;
if (player == null) return;
skillUnlockerComponent.SkillUnlocked += OnSkillUnlock;
_skillUnlockerComponent = player.GetNodeOrNull<SkillUnlockerComponent>("SkillUnlockerComponent");
if (_skillUnlockerComponent != null)
{
_skillUnlockerComponent.SkillUnlocked += OnSkillStateChanged;
}
UpdateButtonState();
}
public override void _ExitTree()
{
_skillUnlockerComponent.SkillUnlocked -= OnSkillUnlock;
if (_skillUnlockerComponent != null)
{
_skillUnlockerComponent.SkillUnlocked -= OnSkillStateChanged;
}
}
private void OnSkillStateChanged(SkillData skill)
{
if (skill.Name == Data.Name)
{
UpdateButtonState();
}
}
private void Setup()
private void UpdateButtonState()
{
if (Data == null) return;
if (Data == null || Data.Upgrades.Count == 0)
{
Visible = false;
return;
}
var isUnlocked = _gameManager.IsSkillUnlocked(Data);
for (var i = 0; i < SkillLevelContainer.GetChildCount(); i++)
{
SkillLevelContainer.GetChild(i).QueueFree();
}
for (var i = 0; i < Data.MaxLevel; i++)
{
var icon = new TextureRect()
{
Texture = i < Data.Level ? UnlockedSkillIcon : LockedSkillIcon,
Texture = (isUnlocked && i < Data.Level) ? UnlockedSkillIcon : LockedSkillIcon,
ExpandMode = TextureRect.ExpandModeEnum.FitWidthProportional
};
SkillLevelContainer.AddChild(icon);
}
}
private void OnSkillUnlock(SkillData skill)
{
if (skill.Name != Data.Name) return;
for (var i = 0; i < Data.MaxLevel; i++)
if (!isUnlocked)
{
var icon = SkillLevelContainer.GetChildOrNull<TextureRect>(i);
if (icon == null) continue;
icon.Texture = i < Data.Level ? UnlockedSkillIcon : LockedSkillIcon;
Disabled = i >= Data.Level;
Text = $"{Tr(Data.Name)} ({Data.Upgrades[0].Cost})";
Disabled = false;
}
else if (Data.Level < Data.MaxLevel)
{
Text = $"{Tr(Data.Name)} ({Data.Upgrades[Data.Level].Cost})";
Disabled = false;
}
else
{
Text = $"{Tr(Data.Name)} (MAX)";
Disabled = true;
}
}
}

View File

@@ -13,6 +13,7 @@ public partial class BrickThrowComponent : Node, ISkill
private bool _canThrow = true;
private Timer _timer;
private SkillData _skillData;
public override void _Ready()
{
@@ -81,22 +82,40 @@ public partial class BrickThrowComponent : Node, ISkill
_timer.Start();
}
public void Initialize(Node owner)
public void Initialize(Node owner, SkillData data)
{
PlayerController = owner as PlayerController;
_skillData = data;
ThrowInputBehavior = (ThrowInputResource)ThrowInputBehavior?.Duplicate();
if (PlayerController == null)
{
GD.PushError("BrickThrowComponent: Owner is not a PlayerController.");
}
if (_skillData.Level > 0 && _skillData.Upgrades.Count >= _skillData.Level)
{
ApplyUpgrade(_skillData.Upgrades[_skillData.Level - 1]);
}
}
public void Activate()
{
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested += ThrowBrick;
SetProcessInput(true);
}
public void Deactivate()
{
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested -= ThrowBrick;
}
public void ApplyUpgrade(SkillUpgrade upgrade)
{
foreach (var property in upgrade.Properties)
{
Set(property.Key, property.Value);
}
}
}

View File

@@ -2,6 +2,7 @@ using System;
using Godot;
using Godot.Collections;
using Mr.BrickAdventures.scripts.interfaces;
using Mr.BrickAdventures.scripts.Resources;
namespace Mr.BrickAdventures.scripts.components;
@@ -12,6 +13,7 @@ public partial class MagneticSkillComponent : Node, ISkill
private Array<Node2D> _collectablesToPickUp = [];
private Node2D _owner;
private SkillData _skillData;
public override void _Process(double delta)
{
@@ -70,9 +72,11 @@ public partial class MagneticSkillComponent : Node, ISkill
collectable.GlobalPosition += direction.Normalized() * speed;
}
public void Initialize(Node owner)
public void Initialize(Node owner, SkillData data)
{
_owner = owner as Node2D;
_skillData = data;
if (_owner == null)
{
GD.PushWarning("MagneticSkillComponent: Owner is not a Node2D.");
@@ -91,6 +95,11 @@ public partial class MagneticSkillComponent : Node, ISkill
}
}
}
if (_skillData.Level > 0 && _skillData.Upgrades.Count >= _skillData.Level)
{
ApplyUpgrade(_skillData.Upgrades[_skillData.Level - 1]);
}
}
public void Activate()
@@ -112,4 +121,12 @@ public partial class MagneticSkillComponent : Node, ISkill
MagneticArea.BodyEntered -= OnBodyEntered;
MagneticArea.AreaEntered -= OnAreaEntered;
}
public void ApplyUpgrade(SkillUpgrade upgrade)
{
foreach (var property in upgrade.Properties)
{
Set(property.Key, property.Value);
}
}
}

View File

@@ -1,6 +1,7 @@
using Godot;
using Godot.Collections;
using Mr.BrickAdventures.Autoloads;
using Mr.BrickAdventures.scripts.interfaces;
using Mr.BrickAdventures.scripts.Resources;
namespace Mr.BrickAdventures.scripts.components;
@@ -28,11 +29,11 @@ public partial class SkillUnlockerComponent : Node
{
if (_gameManager == null) return false;
if (_gameManager.IsSkillUnlocked(skill)) return false;
if (!HasEnoughCoins(skill.Cost)) return false;
if (!HasEnoughCoins(skill.Upgrades[0].Cost)) return false;
skill.Level = 1;
skill.IsActive = true;
_gameManager.RemoveCoins(skill.Cost);
_gameManager.RemoveCoins(skill.Upgrades[0].Cost);
var skillsUnlocked = (Array<SkillData>)_gameManager.CurrentSessionState["skills_unlocked"];
skillsUnlocked.Add(skill);
@@ -59,11 +60,19 @@ public partial class SkillUnlockerComponent : Node
{
if (_gameManager == null) return false;
if (!_gameManager.IsSkillUnlocked(skill)) return false;
if (!HasEnoughCoins(skill.Cost)) return false;
if (skill.Level >= skill.MaxLevel) return false;
if (!HasEnoughCoins(skill.Upgrades[skill.Level].Cost)) return false;
_gameManager.RemoveCoins(skill.Cost);
_gameManager.RemoveCoins(skill.Upgrades[skill.Level].Cost);
skill.Level++;
if (SkillManager.ActiveComponents.TryGetValue(skill.Name, out Variant componentVariant))
{
var component = componentVariant.AsGodotObject();
if (component is ISkill skillInstance)
{
skillInstance.ApplyUpgrade(skill.Upgrades[skill.Level - 1]);
}
}
EmitSignalSkillUnlocked(skill);
return true;
}

View File

@@ -1,11 +1,13 @@
using Godot;
using Mr.BrickAdventures.scripts.Resources;
namespace Mr.BrickAdventures.scripts.interfaces;
public interface ISkill
{
void Initialize(Node owner);
void Initialize(Node owner, SkillData data);
void Activate();
void Deactivate();
void ApplyUpgrade(SkillUpgrade upgrade);
}