using System.Collections;
using System.Collections.Generic;
using Nan.Scripts;
using UnityEngine;
using UniRx;

public class Key : MonoBehaviour
{
    [SerializeField] private AudioSource _audioSource;

    public IReadOnlyReactiveProperty<bool> IsPlayerGetKey
    {
        get { return _isPlayerGetKey; }
    }

    private readonly BoolReactiveProperty _isPlayerGetKey = new BoolReactiveProperty();

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent<PlayerControl>() == null) return;
        _audioSource.transform.SetParent(null);
        Destroy(_audioSource.gameObject, 1);
        _audioSource.Play();
        Destroy(gameObject);
        ScoreManager.Instance.AddScore(3000, transform.position);
    }
}
