Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Picking a card needs to do something to the player #2

@valkyrienyanko

Description

@valkyrienyanko

Currently picking a card does nothing.

Lets say picking any card should set the player speed to 100 (players default speed is 50)

How do we do this?

Here are my thoughts.

Add a event to UICard.cs called OnPicked

// UICard.cs
public partial class UICard : MarginContainer
{
    public event Action OnPicked;

Invoke this action when the card is picked.

// UICard.cs
GuiInput += (inputEvent) =>
{
    if (inputEvent is InputEventMouseButton mouse)
    {
        if (mouse.IsLeftClickPressed())
        {
            GetTree().Paused = false;
            Level.CardManager.RemoveCards();
            OnPicked?.Invoke();
        }
    }
};

Listen to this action in UICard _Ready()

// UICard.cs
public override void _Ready()
{
    OnPicked += () =>
    {
         // How to access player??
         // Player.Speed = 100;
    }
}

I want to do a static approach Player.(...) but this feels wrong and messy. Isn't there a better way to approach this? I don't want to start making static properties and functions in Player.cs just so UICard can interact with Player.

Player Script: https://github.com/Valks-Games/AvoidTheEnemies/blob/main/Scripts/Player.cs
UICard Script: https://github.com/Valks-Games/AvoidTheEnemies/blob/main/Scripts/UI/UICard.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions