💄 Optimize vfx of item pickup
This commit is contained in:
@@ -37,9 +37,11 @@ Inventory = NodePath("../ResourceSystem")
|
|||||||
[node name="ItemPickup" parent="." instance=ExtResource("7_is6ib")]
|
[node name="ItemPickup" parent="." instance=ExtResource("7_is6ib")]
|
||||||
position = Vector2(-496, -245)
|
position = Vector2(-496, -245)
|
||||||
ItemId = "stone"
|
ItemId = "stone"
|
||||||
|
Quantity = 64
|
||||||
Infinite = true
|
Infinite = true
|
||||||
|
|
||||||
[node name="ItemPickup2" parent="." instance=ExtResource("7_is6ib")]
|
[node name="ItemPickup2" parent="." instance=ExtResource("7_is6ib")]
|
||||||
position = Vector2(-495, 5)
|
position = Vector2(-495, 5)
|
||||||
ItemId = "ore_iron"
|
ItemId = "ore_iron"
|
||||||
|
Quantity = 16
|
||||||
Infinite = true
|
Infinite = true
|
||||||
|
@@ -17,3 +17,11 @@ texture = ExtResource("1_4weev")
|
|||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
shape = SubResource("RectangleShape2D_4weev")
|
shape = SubResource("RectangleShape2D_4weev")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="."]
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 23.0
|
||||||
|
theme_override_font_sizes/font_size = 0
|
||||||
|
text = "x1"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
@@ -11,6 +11,8 @@ public partial class ItemPickup : Node2D
|
|||||||
[Export] public bool Infinite { get; set; } = false;
|
[Export] public bool Infinite { get; set; } = false;
|
||||||
|
|
||||||
private Sprite2D _sprite;
|
private Sprite2D _sprite;
|
||||||
|
private Label _quantityLabel;
|
||||||
|
private Sprite2D _shadowSprite;
|
||||||
|
|
||||||
// Called when the node enters the scene tree
|
// Called when the node enters the scene tree
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -20,6 +22,37 @@ public partial class ItemPickup : Node2D
|
|||||||
|
|
||||||
_sprite = GetNode<Sprite2D>("Sprite2D");
|
_sprite = GetNode<Sprite2D>("Sprite2D");
|
||||||
UpdateTexture();
|
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()
|
private void UpdateTexture()
|
||||||
|
Reference in New Issue
Block a user