💄 Optimize vfx of item pickup
This commit is contained in:
@@ -11,6 +11,8 @@ public partial class ItemPickup : Node2D
|
||||
[Export] public bool Infinite { get; set; } = false;
|
||||
|
||||
private Sprite2D _sprite;
|
||||
private Label _quantityLabel;
|
||||
private Sprite2D _shadowSprite;
|
||||
|
||||
// Called when the node enters the scene tree
|
||||
public override void _Ready()
|
||||
@@ -20,6 +22,37 @@ public partial class ItemPickup : Node2D
|
||||
|
||||
_sprite = GetNode<Sprite2D>("Sprite2D");
|
||||
UpdateTexture();
|
||||
|
||||
// Get the Label node for quantity
|
||||
if (HasNode("Label"))
|
||||
{
|
||||
_quantityLabel = GetNode<Label>("Label");
|
||||
if (Quantity > 1)
|
||||
_quantityLabel.Text = Quantity.ToString();
|
||||
else
|
||||
_quantityLabel.Text = string.Empty;
|
||||
}
|
||||
|
||||
// Add or update shadow sprite
|
||||
if (HasNode("ShadowSprite"))
|
||||
{
|
||||
_shadowSprite = GetNode<Sprite2D>("ShadowSprite");
|
||||
_shadowSprite.Texture = _sprite.Texture;
|
||||
_shadowSprite.Modulate = new Color(0, 0, 0, 0.5f);
|
||||
_shadowSprite.Position = _sprite.Position + new Vector2(0, 6);
|
||||
_shadowSprite.ZIndex = _sprite.ZIndex - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_shadowSprite = new Sprite2D();
|
||||
_shadowSprite.Scale = _sprite.Scale;
|
||||
_shadowSprite.Name = "ShadowSprite";
|
||||
_shadowSprite.Texture = _sprite.Texture;
|
||||
_shadowSprite.Modulate = new Color(0, 0, 0, 0.5f);
|
||||
_shadowSprite.Position = _sprite.Position + new Vector2(0, 6);
|
||||
_shadowSprite.ZIndex = _sprite.ZIndex - 1;
|
||||
AddChild(_shadowSprite);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTexture()
|
||||
|
Reference in New Issue
Block a user