Compare commits
3 Commits
afca70e6c6
...
c34b9bc16f
Author | SHA1 | Date | |
---|---|---|---|
c34b9bc16f | |||
421a31917d | |||
55c3ae212b |
@@ -247,11 +247,12 @@ bus = &"sfx"
|
|||||||
stream = ExtResource("32_x2b7c")
|
stream = ExtResource("32_x2b7c")
|
||||||
bus = &"sfx"
|
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_left = -17.0
|
||||||
offset_top = -30.0
|
offset_top = -30.0
|
||||||
offset_right = 23.0
|
offset_right = 23.0
|
||||||
offset_bottom = -20.0
|
offset_bottom = -20.0
|
||||||
|
_skillManager = NodePath("../SkillManager")
|
||||||
|
|
||||||
[node name="HitParticles" parent="." instance=ExtResource("28_jh5m0")]
|
[node name="HitParticles" parent="." instance=ExtResource("28_jh5m0")]
|
||||||
process_material = SubResource("ParticleProcessMaterial_lgb3u")
|
process_material = SubResource("ParticleProcessMaterial_lgb3u")
|
||||||
|
@@ -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="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="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="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]
|
[resource]
|
||||||
script = ExtResource("3_yimbq")
|
script = ExtResource("3_yimbq")
|
||||||
Name = "BRICK_POWER"
|
Name = "BRICK_POWER"
|
||||||
Description = "BRICK_POWER_DESCRIPTION"
|
Description = "BRICK_POWER_DESCRIPTION"
|
||||||
Cost = 50
|
|
||||||
Icon = ExtResource("2_yimbq")
|
Icon = ExtResource("2_yimbq")
|
||||||
IsActive = false
|
IsActive = false
|
||||||
Level = 1
|
Level = 1
|
||||||
MaxLevel = 3
|
|
||||||
Type = 1
|
Type = 1
|
||||||
Node = ExtResource("1_5gnea")
|
Node = ExtResource("1_5gnea")
|
||||||
|
Upgrades = Array[ExtResource("3_lt17o")]([ExtResource("4_nhovl")])
|
||||||
|
@@ -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="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="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"]
|
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_wkqmb"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("5_wkqmb")
|
script = ExtResource("5_wkqmb")
|
||||||
Name = "EXPLOSIVE_BRICK"
|
Name = "EXPLOSIVE_BRICK"
|
||||||
Description = "EXPLOSIVE_BRICK_DESCRIPTION"
|
Description = "EXPLOSIVE_BRICK_DESCRIPTION"
|
||||||
Cost = 180
|
|
||||||
Icon = ExtResource("3_wkqmb")
|
Icon = ExtResource("3_wkqmb")
|
||||||
IsActive = false
|
IsActive = false
|
||||||
Level = 0
|
Level = 0
|
||||||
MaxLevel = 1
|
|
||||||
Type = 1
|
Type = 1
|
||||||
Node = ExtResource("2_gt8f6")
|
Node = ExtResource("2_gt8f6")
|
||||||
|
Upgrades = Array[ExtResource("3_txev8")]([ExtResource("4_1x338")])
|
||||||
|
@@ -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="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="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"]
|
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_us7vb"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("5_us7vb")
|
script = ExtResource("5_us7vb")
|
||||||
Name = "FIRE_BRICK"
|
Name = "FIRE_BRICK"
|
||||||
Description = "FIRE_BIRCK_DESCRIPTION"
|
Description = "FIRE_BIRCK_DESCRIPTION"
|
||||||
Cost = 150
|
|
||||||
Icon = ExtResource("3_w87qb")
|
Icon = ExtResource("3_w87qb")
|
||||||
IsActive = false
|
IsActive = false
|
||||||
Level = 0
|
Level = 0
|
||||||
MaxLevel = 3
|
|
||||||
Type = 1
|
Type = 1
|
||||||
Node = ExtResource("2_d6y6i")
|
Node = ExtResource("2_d6y6i")
|
||||||
|
Upgrades = Array[ExtResource("3_1ooyb")]([ExtResource("4_aj7vs")])
|
||||||
|
@@ -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="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="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"]
|
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="5_57pl3"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("5_57pl3")
|
script = ExtResource("5_57pl3")
|
||||||
Name = "ICE_BRICK"
|
Name = "ICE_BRICK"
|
||||||
Description = "ICE_BRICK_DESCRIPTION"
|
Description = "ICE_BRICK_DESCRIPTION"
|
||||||
Cost = 180
|
|
||||||
Icon = ExtResource("3_6btth")
|
Icon = ExtResource("3_6btth")
|
||||||
IsActive = false
|
IsActive = false
|
||||||
Level = 0
|
Level = 0
|
||||||
MaxLevel = 3
|
|
||||||
Type = 1
|
Type = 1
|
||||||
Node = ExtResource("2_gm1ka")
|
Node = ExtResource("2_gm1ka")
|
||||||
|
Upgrades = Array[ExtResource("3_e3cb0")]([ExtResource("4_3pbub")])
|
||||||
|
@@ -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="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="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="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]
|
[resource]
|
||||||
script = ExtResource("3_htb6q")
|
script = ExtResource("3_htb6q")
|
||||||
Name = "MAGNETIC"
|
Name = "MAGNETIC"
|
||||||
Description = "MAGNETIC_DESCRIPTION"
|
Description = "MAGNETIC_DESCRIPTION"
|
||||||
Config = Dictionary[String, Variant]({
|
|
||||||
"magnetic_area": NodePath("MagneticArea"),
|
|
||||||
"magnetic_move_duration": 1.25,
|
|
||||||
"root": NodePath(".")
|
|
||||||
})
|
|
||||||
Cost = 70
|
|
||||||
Icon = ExtResource("1_16qcg")
|
Icon = ExtResource("1_16qcg")
|
||||||
IsActive = false
|
IsActive = false
|
||||||
Level = 1
|
Level = 1
|
||||||
MaxLevel = 1
|
|
||||||
Type = 2
|
Type = 2
|
||||||
Node = ExtResource("1_er41s")
|
Node = ExtResource("1_er41s")
|
||||||
|
Upgrades = Array[ExtResource("3_0j4wg")]([ExtResource("4_0hjrs")])
|
||||||
|
12
resources/skills/upgrades/brick_throw/upgrade_1.tres
Normal file
12
resources/skills/upgrades/brick_throw/upgrade_1.tres
Normal 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"
|
12
resources/skills/upgrades/explosive_brick/upgrade_1.tres
Normal file
12
resources/skills/upgrades/explosive_brick/upgrade_1.tres
Normal 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"
|
12
resources/skills/upgrades/fire_brick/upgrade_1.tres
Normal file
12
resources/skills/upgrades/fire_brick/upgrade_1.tres
Normal 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"
|
12
resources/skills/upgrades/ice_brick/upgrade_1.tres
Normal file
12
resources/skills/upgrades/ice_brick/upgrade_1.tres
Normal 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"
|
12
resources/skills/upgrades/magnetic/upgrade_1.tres
Normal file
12
resources/skills/upgrades/magnetic/upgrade_1.tres
Normal 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"
|
@@ -8,11 +8,12 @@ public partial class SkillData : Resource
|
|||||||
{
|
{
|
||||||
[Export] public string Name { get; set; } = "New Skill";
|
[Export] public string Name { get; set; } = "New Skill";
|
||||||
[Export] public string Description { 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 Texture2D Icon { get; set; }
|
||||||
[Export] public bool IsActive { get; set; } = false;
|
[Export] public bool IsActive { get; set; } = false;
|
||||||
[Export] public int Level { get; set; } = 1;
|
[Export] public int Level { get; set; } = 1;
|
||||||
[Export] public int MaxLevel { get; set; } = 1;
|
|
||||||
[Export] public SkillType Type { get; set; } = SkillType.Throw;
|
[Export] public SkillType Type { get; set; } = SkillType.Throw;
|
||||||
[Export] public PackedScene Node { get; set; }
|
[Export] public PackedScene Node { get; set; }
|
||||||
|
[Export] public Array<SkillUpgrade> Upgrades { get; set; } = [];
|
||||||
|
|
||||||
|
public int MaxLevel => Upgrades.Count;
|
||||||
}
|
}
|
12
scripts/Resources/SkillUpgrade.cs
Normal file
12
scripts/Resources/SkillUpgrade.cs
Normal 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();
|
||||||
|
}
|
1
scripts/Resources/SkillUpgrade.cs.uid
Normal file
1
scripts/Resources/SkillUpgrade.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dwb0e05pewcsn
|
@@ -1,6 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -13,6 +14,9 @@ public partial class SkillManager : Node
|
|||||||
|
|
||||||
public Dictionary ActiveComponents { get; private set; } = new();
|
public Dictionary ActiveComponents { get; private set; } = new();
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void ActiveThrowSkillChangedEventHandler(BrickThrowComponent throwComponent);
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>("/root/GameManager");
|
||||||
@@ -46,7 +50,7 @@ public partial class SkillManager : Node
|
|||||||
var instance = skillData.Node.Instantiate();
|
var instance = skillData.Node.Instantiate();
|
||||||
if (instance is ISkill skill)
|
if (instance is ISkill skill)
|
||||||
{
|
{
|
||||||
skill.Initialize(Owner);
|
skill.Initialize(Owner, skillData);
|
||||||
skill.Activate();
|
skill.Activate();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -58,6 +62,11 @@ public partial class SkillManager : Node
|
|||||||
|
|
||||||
Owner.AddChild(instance);
|
Owner.AddChild(instance);
|
||||||
ActiveComponents[skillData.Name] = instance;
|
ActiveComponents[skillData.Name] = instance;
|
||||||
|
|
||||||
|
if (instance is BrickThrowComponent btc)
|
||||||
|
{
|
||||||
|
EmitSignalActiveThrowSkillChanged(btc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSkill(string skillName)
|
public void RemoveSkill(string skillName)
|
||||||
@@ -65,6 +74,11 @@ public partial class SkillManager : Node
|
|||||||
if (!ActiveComponents.TryGetValue(skillName, out var component))
|
if (!ActiveComponents.TryGetValue(skillName, out var component))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (component.AsGodotObject() is BrickThrowComponent)
|
||||||
|
{
|
||||||
|
EmitSignalActiveThrowSkillChanged(null);
|
||||||
|
}
|
||||||
|
|
||||||
var inst = (Node)component;
|
var inst = (Node)component;
|
||||||
if (inst is ISkill skill)
|
if (inst is ISkill skill)
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures.Autoloads;
|
||||||
using Mr.BrickAdventures.scripts.components;
|
using Mr.BrickAdventures.scripts.components;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
@@ -7,32 +8,57 @@ namespace Mr.BrickAdventures.scripts.UI;
|
|||||||
public partial class ChargeProgressBar : ProgressBar
|
public partial class ChargeProgressBar : ProgressBar
|
||||||
{
|
{
|
||||||
[Export] public ProgressBar ProgressBar { get; set; }
|
[Export] public ProgressBar ProgressBar { get; set; }
|
||||||
[Export] public BrickThrowComponent ThrowComponent { get; set; }
|
[Export] private SkillManager _skillManager;
|
||||||
|
|
||||||
|
private BrickThrowComponent _throwComponent;
|
||||||
private ChargeThrowInputResource _throwInput;
|
private ChargeThrowInputResource _throwInput;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Owner.ChildEnteredTree += OnNodeEntered;
|
|
||||||
ProgressBar.Hide();
|
ProgressBar.Hide();
|
||||||
SetupDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnNodeEntered(Node node)
|
if (_skillManager == null)
|
||||||
{
|
|
||||||
if (node is not BrickThrowComponent throwComponent || ThrowComponent != null) return;
|
|
||||||
ThrowComponent = throwComponent;
|
|
||||||
SetupDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupDependencies()
|
|
||||||
{
|
|
||||||
if (ThrowComponent == null || ProgressBar == null)
|
|
||||||
{
|
{
|
||||||
return;
|
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;
|
_throwInput = throwInput;
|
||||||
}
|
}
|
||||||
|
@@ -35,12 +35,12 @@ public partial class Marketplace : Control
|
|||||||
var unlockedSkills = _gameManager.GetUnlockedSkills();
|
var unlockedSkills = _gameManager.GetUnlockedSkills();
|
||||||
foreach (var skill in unlockedSkills) CreateSkillButton(skill);
|
foreach (var skill in unlockedSkills) CreateSkillButton(skill);
|
||||||
|
|
||||||
SkillUnlockerComponent.SkillUnlocked += OnSkillUnlocker;
|
SkillUnlockerComponent.SkillUnlocked += OnSkillUnlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _ExitTree()
|
public override void _ExitTree()
|
||||||
{
|
{
|
||||||
SkillUnlockerComponent.SkillUnlocked -= OnSkillUnlocker;
|
SkillUnlockerComponent.SkillUnlocked -= OnSkillUnlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
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}";
|
var buttonExists = false;
|
||||||
}
|
foreach (var existingButton in _skillButtons)
|
||||||
|
{
|
||||||
|
if (existingButton.Name == skill.Name)
|
||||||
|
{
|
||||||
|
buttonExists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSkillUnlocker(SkillData skill)
|
if (!buttonExists) CreateSkillButton(skill);
|
||||||
{
|
|
||||||
if (_skillButtons.Count == 0) CreateSkillButton(skill);
|
|
||||||
|
|
||||||
foreach (var btn in _skillButtons)
|
foreach (var btn in _skillButtons)
|
||||||
{
|
{
|
||||||
if (btn.Data.IsActive)
|
if (btn.Data.IsActive) btn.Activate();
|
||||||
btn.Activate();
|
else btn.Deactivate();
|
||||||
else
|
|
||||||
btn.Deactivate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +96,6 @@ public partial class Marketplace : Control
|
|||||||
private void CreateUpgradeButton(SkillData skill)
|
private void CreateUpgradeButton(SkillData skill)
|
||||||
{
|
{
|
||||||
var button = MarketplaceButtonScene.Instantiate<MarketplaceButton>();
|
var button = MarketplaceButtonScene.Instantiate<MarketplaceButton>();
|
||||||
button.Text = GetButtonText(skill);
|
|
||||||
button.Data = skill;
|
button.Data = skill;
|
||||||
button.Icon = skill.Icon;
|
button.Icon = skill.Icon;
|
||||||
button.Pressed += () => OnUpgradeButtonPressed(skill);
|
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)
|
private void OnSkillButtonPressed(SkillButton button)
|
||||||
{
|
{
|
||||||
SkillUnlockerComponent.SkillManager.ToggleSkillActivation(button.Data);
|
SkillUnlockerComponent.SkillManager.ToggleSkillActivation(button.Data);
|
||||||
|
|
||||||
|
foreach (var btn in _skillButtons)
|
||||||
|
{
|
||||||
|
if (btn.Data.IsActive)
|
||||||
|
btn.Activate();
|
||||||
|
else
|
||||||
|
btn.Deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -18,45 +18,73 @@ public partial class MarketplaceButton : Button
|
|||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
_gameManager = GetNode<GameManager>("/root/GameManager");
|
||||||
|
|
||||||
Setup();
|
|
||||||
var player = _gameManager.Player;
|
var player = _gameManager.Player;
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
var skillUnlockerComponent = player?.GetNodeOrNull<SkillUnlockerComponent>("SkillUnlockerComponent");
|
_skillUnlockerComponent = player.GetNodeOrNull<SkillUnlockerComponent>("SkillUnlockerComponent");
|
||||||
if (skillUnlockerComponent == null) return;
|
if (_skillUnlockerComponent != null)
|
||||||
|
{
|
||||||
|
_skillUnlockerComponent.SkillUnlocked += OnSkillStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
skillUnlockerComponent.SkillUnlocked += OnSkillUnlock;
|
UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _ExitTree()
|
public override void _ExitTree()
|
||||||
{
|
{
|
||||||
_skillUnlockerComponent.SkillUnlocked -= OnSkillUnlock;
|
if (_skillUnlockerComponent != null)
|
||||||
|
{
|
||||||
|
_skillUnlockerComponent.SkillUnlocked -= OnSkillStateChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Setup()
|
private void OnSkillStateChanged(SkillData skill)
|
||||||
{
|
{
|
||||||
if (Data == null) return;
|
if (skill.Name == Data.Name)
|
||||||
|
{
|
||||||
|
UpdateButtonState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButtonState()
|
||||||
|
{
|
||||||
|
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++)
|
for (var i = 0; i < Data.MaxLevel; i++)
|
||||||
{
|
{
|
||||||
var icon = new TextureRect()
|
var icon = new TextureRect()
|
||||||
{
|
{
|
||||||
Texture = i < Data.Level ? UnlockedSkillIcon : LockedSkillIcon,
|
Texture = (isUnlocked && i < Data.Level) ? UnlockedSkillIcon : LockedSkillIcon,
|
||||||
|
ExpandMode = TextureRect.ExpandModeEnum.FitWidthProportional
|
||||||
};
|
};
|
||||||
SkillLevelContainer.AddChild(icon);
|
SkillLevelContainer.AddChild(icon);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSkillUnlock(SkillData skill)
|
if (!isUnlocked)
|
||||||
{
|
|
||||||
if (skill.Name != Data.Name) return;
|
|
||||||
|
|
||||||
for (var i = 0; i < Data.MaxLevel; i++)
|
|
||||||
{
|
{
|
||||||
var icon = SkillLevelContainer.GetChildOrNull<TextureRect>(i);
|
Text = $"{Tr(Data.Name)} ({Data.Upgrades[0].Cost})";
|
||||||
if (icon == null) continue;
|
Disabled = false;
|
||||||
icon.Texture = i < Data.Level ? UnlockedSkillIcon : LockedSkillIcon;
|
}
|
||||||
Disabled = i >= Data.Level;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -13,6 +13,7 @@ public partial class BrickThrowComponent : Node, ISkill
|
|||||||
|
|
||||||
private bool _canThrow = true;
|
private bool _canThrow = true;
|
||||||
private Timer _timer;
|
private Timer _timer;
|
||||||
|
private SkillData _skillData;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -81,22 +82,40 @@ public partial class BrickThrowComponent : Node, ISkill
|
|||||||
_timer.Start();
|
_timer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(Node owner)
|
public void Initialize(Node owner, SkillData data)
|
||||||
{
|
{
|
||||||
PlayerController = owner as PlayerController;
|
PlayerController = owner as PlayerController;
|
||||||
|
_skillData = data;
|
||||||
|
|
||||||
|
ThrowInputBehavior = (ThrowInputResource)ThrowInputBehavior?.Duplicate();
|
||||||
|
|
||||||
if (PlayerController == null)
|
if (PlayerController == null)
|
||||||
{
|
{
|
||||||
GD.PushError("BrickThrowComponent: Owner is not a PlayerController.");
|
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()
|
public void Activate()
|
||||||
{
|
{
|
||||||
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested += ThrowBrick;
|
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested += ThrowBrick;
|
||||||
|
SetProcessInput(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public void Deactivate()
|
||||||
{
|
{
|
||||||
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested -= ThrowBrick;
|
if (ThrowInputBehavior != null) ThrowInputBehavior.ThrowRequested -= ThrowBrick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyUpgrade(SkillUpgrade upgrade)
|
||||||
|
{
|
||||||
|
foreach (var property in upgrade.Properties)
|
||||||
|
{
|
||||||
|
Set(property.Key, property.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
using Mr.BrickAdventures.scripts.interfaces;
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ public partial class MagneticSkillComponent : Node, ISkill
|
|||||||
|
|
||||||
private Array<Node2D> _collectablesToPickUp = [];
|
private Array<Node2D> _collectablesToPickUp = [];
|
||||||
private Node2D _owner;
|
private Node2D _owner;
|
||||||
|
private SkillData _skillData;
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
@@ -70,9 +72,11 @@ public partial class MagneticSkillComponent : Node, ISkill
|
|||||||
collectable.GlobalPosition += direction.Normalized() * speed;
|
collectable.GlobalPosition += direction.Normalized() * speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(Node owner)
|
public void Initialize(Node owner, SkillData data)
|
||||||
{
|
{
|
||||||
_owner = owner as Node2D;
|
_owner = owner as Node2D;
|
||||||
|
_skillData = data;
|
||||||
|
|
||||||
if (_owner == null)
|
if (_owner == null)
|
||||||
{
|
{
|
||||||
GD.PushWarning("MagneticSkillComponent: Owner is not a Node2D.");
|
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()
|
public void Activate()
|
||||||
@@ -112,4 +121,12 @@ public partial class MagneticSkillComponent : Node, ISkill
|
|||||||
MagneticArea.BodyEntered -= OnBodyEntered;
|
MagneticArea.BodyEntered -= OnBodyEntered;
|
||||||
MagneticArea.AreaEntered -= OnAreaEntered;
|
MagneticArea.AreaEntered -= OnAreaEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ApplyUpgrade(SkillUpgrade upgrade)
|
||||||
|
{
|
||||||
|
foreach (var property in upgrade.Properties)
|
||||||
|
{
|
||||||
|
Set(property.Key, property.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
using Mr.BrickAdventures.Autoloads;
|
using Mr.BrickAdventures.Autoloads;
|
||||||
|
using Mr.BrickAdventures.scripts.interfaces;
|
||||||
using Mr.BrickAdventures.scripts.Resources;
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.components;
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
@@ -28,11 +29,11 @@ public partial class SkillUnlockerComponent : Node
|
|||||||
{
|
{
|
||||||
if (_gameManager == null) return false;
|
if (_gameManager == null) return false;
|
||||||
if (_gameManager.IsSkillUnlocked(skill)) 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.Level = 1;
|
||||||
skill.IsActive = true;
|
skill.IsActive = true;
|
||||||
_gameManager.RemoveCoins(skill.Cost);
|
_gameManager.RemoveCoins(skill.Upgrades[0].Cost);
|
||||||
|
|
||||||
var skillsUnlocked = (Array<SkillData>)_gameManager.CurrentSessionState["skills_unlocked"];
|
var skillsUnlocked = (Array<SkillData>)_gameManager.CurrentSessionState["skills_unlocked"];
|
||||||
skillsUnlocked.Add(skill);
|
skillsUnlocked.Add(skill);
|
||||||
@@ -59,11 +60,19 @@ public partial class SkillUnlockerComponent : Node
|
|||||||
{
|
{
|
||||||
if (_gameManager == null) return false;
|
if (_gameManager == null) return false;
|
||||||
if (!_gameManager.IsSkillUnlocked(skill)) return false;
|
if (!_gameManager.IsSkillUnlocked(skill)) return false;
|
||||||
if (!HasEnoughCoins(skill.Cost)) return false;
|
|
||||||
if (skill.Level >= skill.MaxLevel) 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++;
|
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);
|
EmitSignalSkillUnlocked(skill);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Mr.BrickAdventures.scripts.Resources;
|
||||||
|
|
||||||
namespace Mr.BrickAdventures.scripts.interfaces;
|
namespace Mr.BrickAdventures.scripts.interfaces;
|
||||||
|
|
||||||
public interface ISkill
|
public interface ISkill
|
||||||
{
|
{
|
||||||
void Initialize(Node owner);
|
void Initialize(Node owner, SkillData data);
|
||||||
|
|
||||||
void Activate();
|
void Activate();
|
||||||
void Deactivate();
|
void Deactivate();
|
||||||
|
void ApplyUpgrade(SkillUpgrade upgrade);
|
||||||
}
|
}
|
Reference in New Issue
Block a user