Valks-Games / AvoidTheEnemies

Lets make a game like Vampire Survivors and Halls of Torment!
MIT License
5 stars 1 forks source link

XP Orb Pickup Radius Tied to XP Orb #8

Open valkyrienyanko opened 1 year ago

valkyrienyanko commented 1 year ago

The players pickup radius should be a upgrade of its own. But currently the pickup radius is directly tied to the xp orb. How can we change this so the players pickup radius factors into this?

Untitled

// XPOrb.cs
public partial class XPOrb : AnimatedSprite2D
{
    public event Action<Player> OnPickup;

    public int Value { get; set; }

    public override void _Ready()
    {
        GetNode<Area2D>("Area2D").BodyEntered += body =>
        {
            if (body is Player player)
            {
                OnPickup?.Invoke(player);

                // Destroy this xp orb
                QueueFree();
            }
        };
    }
}