✨ Item pickup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AceFieldNewHorizon.Scripts.System;
|
||||
using Godot;
|
||||
|
||||
namespace AceFieldNewHorizon.Scripts.Entities;
|
||||
@@ -18,6 +19,8 @@ public partial class Player : CharacterBody2D
|
||||
[Export] public float ZoomAcceleration = 0.05f;
|
||||
[Export] public float ZoomDecay = 0.9f;
|
||||
[Export] public float ZoomSmoothing = 10.0f;
|
||||
|
||||
[Export] public ResourceManager Inventory;
|
||||
|
||||
private Camera2D _camera;
|
||||
private Vector2 _cameraTargetZoom = Vector2.One;
|
||||
@@ -29,6 +32,8 @@ public partial class Player : CharacterBody2D
|
||||
{
|
||||
_camera = GetNode<Camera2D>("Camera2D");
|
||||
_cameraTargetZoom = _camera.Zoom;
|
||||
|
||||
AddToGroup(ItemPickup.PickupGroupName);
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
@@ -135,4 +140,10 @@ public partial class Player : CharacterBody2D
|
||||
// Apply the movement
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
public void AddItem(string itemId, int quantity)
|
||||
{
|
||||
Inventory.AddResource(itemId, quantity);
|
||||
GD.Print($"[Player] Picked up {quantity} x {itemId}. Total: {Inventory.GetResourceAmount(itemId)}");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user