using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Destructible : MonoBehaviour
{
//Set up serialized visual effect for the destruction of items in
//the game
[SerializeField] private GameObject destroyVFX;
///
/// This method triggers item drop in the case of destruction
/// of the destructible objects.
///
///
private void OnTriggerEnter2D(Collider2D other){
//drops pickup items if destructible object is destroyed by the player
if(other.gameObject.GetComponent() || other.gameObject.GetComponent()){
GetComponent().DropItems();
Instantiate(destroyVFX, transform.position, Quaternion.identity);
Destroy(gameObject);
//Notify GameManager that a destructible has been destroyed
GameManager.Instance.destructiblesDestroyed++;
GameManager.Instance.CheckWinCondition();
}
}
}