using UnityEngine;

public class ExpCubeComponent : MonoBehaviour
{
    private Transform _target;
    private bool _isAttracting = false;
    private float _attractSpeed = 10f;
    
    public float ExpAmount { get; private set; } = 10f;

    public void SetExpAmount(float amount)
    {
        ExpAmount = amount;
    }

    void Update()
    {
        if (_isAttracting && _target != null)
        {
            float step = _attractSpeed * Time.deltaTime;
            transform.position = Vector3.MoveTowards(transform.position, _target.position, step);

            if (Vector3.Distance(transform.position, _target.position) < 0.1f)
            {
                // 도달했을 때 처리 (예: 경험치 획득)
                Destroy(gameObject);
            }
        }
    }

    public void Attract(Transform target)
    {
        _target = target;
        _isAttracting = true;
    }
}
