Add new skills: Double Jump, Ground Pound, Brick Armor, and Brick Shield; implement skill removal signal in SkillManager (#11)
This commit is contained in:
48
scripts/components/BrickArmorSkillComponent.cs
Normal file
48
scripts/components/BrickArmorSkillComponent.cs
Normal 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);
|
||||
}
|
||||
}
|
1
scripts/components/BrickArmorSkillComponent.cs.uid
Normal file
1
scripts/components/BrickArmorSkillComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://5fyepa666cc8
|
72
scripts/components/BrickShieldSkillComponent.cs
Normal file
72
scripts/components/BrickShieldSkillComponent.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Godot;
|
||||
using Mr.BrickAdventures.Autoloads;
|
||||
using Mr.BrickAdventures.scripts.interfaces;
|
||||
using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class BrickShieldSkillComponent : Node, ISkill
|
||||
{
|
||||
[Export] public PackedScene ShieldScene { get; set; }
|
||||
|
||||
private PlayerController _player;
|
||||
private Node2D _shieldInstance;
|
||||
private SkillData _skillData;
|
||||
private GameManager _gameManager;
|
||||
private SkillManager _skillManager;
|
||||
private HealthComponent _shieldHealth;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_gameManager = GetNode<GameManager>("/root/GameManager");
|
||||
_skillManager = GetNode<SkillManager>("/root/SkillManager");
|
||||
}
|
||||
|
||||
public void Initialize(Node owner, SkillData data)
|
||||
{
|
||||
_player = owner as PlayerController;
|
||||
_skillData = data;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (_player == null || ShieldScene == null || _shieldInstance != null) return;
|
||||
|
||||
_shieldInstance = ShieldScene.Instantiate<Node2D>();
|
||||
_player.AddChild(_shieldInstance);
|
||||
_shieldInstance.Position = Vector2.Zero;
|
||||
_shieldInstance.TreeExiting += OnShieldDestroyed;
|
||||
_shieldHealth = _shieldInstance.GetNode<HealthComponent>("HealthComponent");
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
if (_shieldInstance != null && IsInstanceValid(_shieldInstance))
|
||||
{
|
||||
_shieldInstance.TreeExiting -= OnShieldDestroyed;
|
||||
_shieldInstance.QueueFree();
|
||||
}
|
||||
_shieldInstance = null;
|
||||
}
|
||||
|
||||
public void ApplyUpgrade(SkillUpgrade upgrade)
|
||||
{
|
||||
upgrade.Properties.TryGetValue("shield_health", out var newHealth);
|
||||
if (_shieldHealth != null)
|
||||
{
|
||||
_shieldHealth.Health = (float)newHealth;
|
||||
_shieldHealth.MaxHealth = (float)newHealth;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShieldDestroyed()
|
||||
{
|
||||
if (_gameManager != null && _skillData != null && _skillManager != null)
|
||||
{
|
||||
_gameManager.RemoveSkill(_skillData.Name);
|
||||
_skillManager.RemoveSkill(_skillData.Name);
|
||||
}
|
||||
_shieldInstance = null;
|
||||
}
|
||||
}
|
1
scripts/components/BrickShieldSkillComponent.cs.uid
Normal file
1
scripts/components/BrickShieldSkillComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dbiu2qrr8sprx
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class BrickThrowComponent : Node, ISkill
|
||||
{
|
||||
[Export] public PackedScene BrickScene { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class BulletComponent : Node
|
||||
{
|
||||
[Export] public Area2D Area { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CageComponent : Node
|
||||
{
|
||||
[Export] public LeverComponent Lever { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CanBeLaunchedComponent : Node
|
||||
{
|
||||
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CanPickUpComponent : Node
|
||||
{
|
||||
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CannotStompComponent : Node
|
||||
{
|
||||
|
||||
|
@@ -3,6 +3,7 @@ using PhantomCamera;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ChaseLevelComponent : Node
|
||||
{
|
||||
[Export] public float ChaseSpeed { get; set; } = 200.0f;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CleanupComponent : Node
|
||||
{
|
||||
public void CleanUp()
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CollapsableComponent : Node
|
||||
{
|
||||
[Export] public Timer ToCollapseTimer { get; set; }
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CollectableComponent : Node
|
||||
{
|
||||
private bool _hasFadeAway = false;
|
||||
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DamageComponent : Node
|
||||
{
|
||||
[Export] public float Damage { get; set; } = 0.25f;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DestroyableComponent : Node2D
|
||||
{
|
||||
[Export] public HealthComponent Health { get; set; }
|
||||
|
45
scripts/components/DoubleJumpSkillComponent.cs
Normal file
45
scripts/components/DoubleJumpSkillComponent.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using Mr.BrickAdventures.scripts.interfaces;
|
||||
using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DoubleJumpSkillComponent : Node, ISkill
|
||||
{
|
||||
[Export] private PackedScene _doubleJumpAbilityScene;
|
||||
private PlayerController _playerController;
|
||||
|
||||
public void Initialize(Node owner, SkillData data)
|
||||
{
|
||||
_playerController = owner as PlayerController;
|
||||
if (_playerController == null)
|
||||
{
|
||||
GD.PrintErr("DoubleJumpSkillComponent must be a child of a PlayerController.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (_playerController == null) return;
|
||||
|
||||
var hasAbility = _playerController.GetActiveAbilities().Any(ability => ability is DoubleJumpAbility);
|
||||
|
||||
if (!hasAbility)
|
||||
{
|
||||
var abilityInstance = _doubleJumpAbilityScene.Instantiate<DoubleJumpAbility>();
|
||||
_playerController.AddAbility(abilityInstance);
|
||||
}
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
_playerController?.RemoveAbility<DoubleJumpAbility>();
|
||||
}
|
||||
|
||||
public void ApplyUpgrade(SkillUpgrade upgrade)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
1
scripts/components/DoubleJumpSkillComponent.cs.uid
Normal file
1
scripts/components/DoubleJumpSkillComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c61jxwtgiuqsy
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class EffectInflictorComponent : Node
|
||||
{
|
||||
[Export] public DamageComponent Damage { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class EnemyDeathComponent : Node
|
||||
{
|
||||
[Export] public float TweenDuration { get; set; } = 0.5f;
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.interfaces;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ExitDoorComponent : Area2D, IUnlockable
|
||||
{
|
||||
[Export] public bool Locked { get; set; } = true;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ExplosiveComponent : Node2D
|
||||
{
|
||||
[Export] public DamageComponent Damage { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FadeAwayComponent : Node
|
||||
{
|
||||
[Export] public Sprite2D Sprite { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FireEffectComponent : Node
|
||||
{
|
||||
[Export] public HealthComponent Health { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FlashingComponent : Node
|
||||
{
|
||||
[Export] public Node2D Sprite { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FlipComponent : Node2D
|
||||
{
|
||||
[Export] public Sprite2D LeftEye { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class GravityMotionComponent : Node2D
|
||||
{
|
||||
[Export] public CharacterBody2D Body { get; set; }
|
||||
|
66
scripts/components/GroundPoundSkillComponent.cs
Normal file
66
scripts/components/GroundPoundSkillComponent.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Godot;
|
||||
using Mr.BrickAdventures.scripts.interfaces;
|
||||
using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class GroundPoundSkillComponent : Node, ISkill
|
||||
{
|
||||
[Export] public float PoundForce { get; set; } = 1200f;
|
||||
[Export] public PackedScene ShockwaveScene { get; set; }
|
||||
|
||||
private PlayerController _player;
|
||||
private PlayerInputHandler _input;
|
||||
private bool _isPounding = false;
|
||||
|
||||
public void Initialize(Node owner, SkillData data)
|
||||
{
|
||||
_player = owner as PlayerController;
|
||||
if (_player != null)
|
||||
{
|
||||
_input = _player.GetNode<PlayerInputHandler>("PlayerInputHandler");
|
||||
}
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (_player == null || _input == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we just landed from a ground pound to create the shockwave.
|
||||
if (_isPounding && _player.IsOnFloor())
|
||||
{
|
||||
_isPounding = false;
|
||||
if (ShockwaveScene != null)
|
||||
{
|
||||
var shockwave = ShockwaveScene.Instantiate<Node2D>();
|
||||
_player.GetParent()?.AddChild(shockwave);
|
||||
shockwave.GlobalPosition = _player.GlobalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to initiate a ground pound. The player must be in the air.
|
||||
if (_input.DownHeld && !_player.IsOnFloor() && !_isPounding)
|
||||
{
|
||||
// Apply a strong downward force, zeroing out horizontal movement.
|
||||
_player.Velocity = new Vector2(0, PoundForce);
|
||||
_isPounding = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
SetPhysicsProcess(true);
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
SetPhysicsProcess(false);
|
||||
_isPounding = false;
|
||||
}
|
||||
|
||||
public void ApplyUpgrade(SkillUpgrade upgrade) { }
|
||||
}
|
1
scripts/components/GroundPoundSkillComponent.cs.uid
Normal file
1
scripts/components/GroundPoundSkillComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://3sclg5kdjg13
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class HealComponent : Node
|
||||
{
|
||||
[Export] public GpuParticles2D HealFx { get; set; }
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.Autoloads;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class HealthComponent : Node2D
|
||||
{
|
||||
[Export] public float Health { get; set; } = 1.0f;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class HitComponent : Node
|
||||
{
|
||||
[Export] public Sprite2D Sprite { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class HomingMissileMotionComponent : Node
|
||||
{
|
||||
[Export] public LaunchComponent Launch { get; set; }
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class IceEffectComponent : Node
|
||||
{
|
||||
[Export] public Array<Node> ComponentsToDisable { get; set; } = [];
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class InvulnerabilityComponent : Node
|
||||
{
|
||||
[Export] public float Duration { get; set; } = 1f;
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class JumpPadComponent : Node
|
||||
{
|
||||
[Export] public float JumpForce { get; set; } = 10f;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class KillPlayerOutOfScreenComponent : Node
|
||||
{
|
||||
[Export] public VisibleOnScreenNotifier2D ScreenNotifier { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class KnockbackComponent : Node
|
||||
{
|
||||
[Export] public CharacterBody2D Body { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class LaunchComponent : Node2D
|
||||
{
|
||||
[Export] public Vector2 InitialDirection { get; set; } = Vector2.Right;
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class LeverComponent : Node
|
||||
{
|
||||
[Export] public Area2D Area { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class LifetimeComponent : Node
|
||||
{
|
||||
[Export] public float LifeTime { get; set; } = 5.0f;
|
||||
|
@@ -6,6 +6,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class MagneticSkillComponent : Node, ISkill
|
||||
{
|
||||
[Export] public Area2D MagneticArea { get; set; }
|
||||
|
46
scripts/components/Movement/DoubleJumpAbility.cs
Normal file
46
scripts/components/Movement/DoubleJumpAbility.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DoubleJumpAbility : MovementAbility
|
||||
{
|
||||
private bool _hasDoubleJumped = false;
|
||||
private float _jumpVelocity;
|
||||
|
||||
public override void Initialize(PlayerController controller)
|
||||
{
|
||||
base.Initialize(controller);
|
||||
|
||||
foreach (var ability in _controller.GetActiveAbilities())
|
||||
{
|
||||
if (ability is VariableJumpAbility jumpAbility)
|
||||
{
|
||||
_jumpVelocity = (2.0f * jumpAbility.JumpHeight) / jumpAbility.JumpTimeToPeak * -1.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_jumpVelocity == 0)
|
||||
{
|
||||
_jumpVelocity = -400.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 ProcessMovement(Vector2 velocity, double delta)
|
||||
{
|
||||
if (_body.IsOnFloor())
|
||||
{
|
||||
_hasDoubleJumped = false;
|
||||
}
|
||||
|
||||
if (_input.JumpPressed && !_body.IsOnFloor() && !_hasDoubleJumped)
|
||||
{
|
||||
velocity.Y = _jumpVelocity;
|
||||
_controller.EmitSignal(PlayerController.SignalName.JumpInitiated);
|
||||
_hasDoubleJumped = true;
|
||||
}
|
||||
|
||||
return velocity;
|
||||
}
|
||||
}
|
1
scripts/components/Movement/DoubleJumpAbility.cs.uid
Normal file
1
scripts/components/Movement/DoubleJumpAbility.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xc0j26e88np7
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class OutOfScreenComponent : Node
|
||||
{
|
||||
[Export] public VisibleOnScreenNotifier2D VisibilityNotifier { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PeriodicShootingComponent : Node
|
||||
{
|
||||
[Export] public PackedScene BulletScene { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.Autoloads;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PlayerDeathComponent : Node2D
|
||||
{
|
||||
[Export] public AudioStreamPlayer2D DeathSfx { get; set; }
|
||||
|
@@ -10,6 +10,7 @@ public class ProjectileInitParams
|
||||
public float PowerMultiplier { get; set; } = 1f;
|
||||
}
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ProjectileInitComponent : Node
|
||||
{
|
||||
[Export] public LaunchComponent LaunchComponent { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RequirementComponent : Node
|
||||
{
|
||||
[Export] public CollectableType RequirementType { get; set; }
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ScoreComponent : Node
|
||||
{
|
||||
private GameManager _gameManager;
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ShipShooterComponent : Node
|
||||
{
|
||||
[Export] public PackedScene BulletScene { get; set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SideToSideMovementComponent : Node
|
||||
{
|
||||
[Export] public Sprite2D Sprite { get; set; }
|
||||
|
@@ -6,6 +6,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SkillUnlockerComponent : Node
|
||||
{
|
||||
public SkillManager SkillManager { get; private set; }
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SpaceshipEnterComponent : Area2D
|
||||
{
|
||||
[Signal] public delegate void SpaceshipEnteredEventHandler();
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SpaceshipExitComponent : Area2D
|
||||
{
|
||||
[Signal] public delegate void SpaceshipExitEventHandler();
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SpinComponent : Node
|
||||
{
|
||||
[Export] public float SpinSpeed { get; set; } = 8f;
|
||||
|
@@ -11,6 +11,7 @@ public partial class StatusEffect : GodotObject
|
||||
public Timer Timer { get; set; }
|
||||
}
|
||||
|
||||
[GlobalClass]
|
||||
public partial class StatusEffectComponent : Node
|
||||
{
|
||||
private List<StatusEffect> _activeEffects = [];
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class StompDamageComponent : Node
|
||||
{
|
||||
[Export] public float Damage { get; set; } = 0.25f;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class StraightMotionComponent : Node
|
||||
{
|
||||
[Export] public LaunchComponent LaunchComponent { get; set; }
|
||||
|
@@ -5,6 +5,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TerrainHitFx : Node
|
||||
{
|
||||
private List<GpuParticles2D> _gpuParticles = [];
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TooltipComponent : Area2D
|
||||
{
|
||||
[Export] public Control UiRoot { get; set; }
|
||||
|
@@ -3,6 +3,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TrailComponent : Line2D
|
||||
{
|
||||
[Export] public int MaxPoints { get; set; } = 100;
|
||||
|
@@ -2,6 +2,7 @@ using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TriggerLeverComponent : Node
|
||||
{
|
||||
|
||||
|
@@ -4,6 +4,7 @@ using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class UnlockOnRequirementComponent : Node
|
||||
{
|
||||
[Export] public RequirementComponent RequirementComponent { get; set; }
|
||||
|
51
scripts/components/XRayVisionSkillComponent.cs
Normal file
51
scripts/components/XRayVisionSkillComponent.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Godot;
|
||||
using Mr.BrickAdventures.scripts.interfaces;
|
||||
using Mr.BrickAdventures.scripts.Resources;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class XRayVisionSkillComponent : Node, ISkill
|
||||
{
|
||||
[Export(PropertyHint.Layers2DRender)] public uint SecretLayer { get; set; }
|
||||
[Export] public float Duration { get; set; } = 5.0f;
|
||||
|
||||
private Camera2D _camera;
|
||||
private Viewport _viewport;
|
||||
private uint _originalVisibilityLayer;
|
||||
private Timer _timer;
|
||||
|
||||
public void Initialize(Node owner, SkillData data)
|
||||
{
|
||||
_viewport = GetViewport();
|
||||
_camera = GetViewport().GetCamera2D();
|
||||
_timer = new Timer { OneShot = true };
|
||||
AddChild(_timer);
|
||||
_timer.Timeout += Deactivate;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (_camera == null) return;
|
||||
|
||||
_originalVisibilityLayer = _camera.VisibilityLayer;
|
||||
_camera.VisibilityLayer |= SecretLayer;
|
||||
_timer.Start(Duration);
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
if (_camera != null)
|
||||
{
|
||||
_camera.VisibilityLayer = _originalVisibilityLayer;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyUpgrade(SkillUpgrade upgrade)
|
||||
{
|
||||
if (upgrade.Properties.TryGetValue("duration", out var newDuration))
|
||||
{
|
||||
Duration = (float)newDuration;
|
||||
}
|
||||
}
|
||||
}
|
1
scripts/components/XRayVisionSkillComponent.cs.uid
Normal file
1
scripts/components/XRayVisionSkillComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dl7vthhurirwc
|
Reference in New Issue
Block a user