using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;

public class Chest : MonoBehaviour
{
    private GameManager _gameManager;
    private void Awake()
    {
        _gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
        Assert.IsNotNull(_gameManager);
    }
    
    private void OnTriggerStay(Collider other)
    {
        Debug.Log("Triggered");
        if (!Input.GetKeyDown(KeyCode.Space))
        {
            return;
        }
        if (!other.name.Equals("Player"))
        {
            return;
        }
        
        _gameManager.OpenChest();
        Destroy(gameObject);
    }
}
