﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GemPickup : MonoBehaviour {

    [Header("GameManager Reference")]
    [Space]

    [SerializeField]
    private GameManager _gameManager;

    void Awake() {
        _gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();
    }

    private void OnTriggerEnter2D(Collider2D other) {

        if(other.tag == "Player") {

            _gameManager.GemPickUp();

            PlayerInventory _playerInventory = other.GetComponent<PlayerInventory>();

            _playerInventory.ConsumeGem();

            Destroy(gameObject);
        }
    }
}
