using UnityEngine;
using System.Collections;

public class DrillEffect : MonoBehaviour
{
    public bool enableEffect;
    public ParticleSystem ps;

    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.GetComponent<EnvironmentMovement>())
        {
            if (col.GetComponent<EnvironmentMovement>().name == "Drill")
            {
                enableEffect = true;
                oneShot = true;
            }
        }
    }

    void OnTriggerExit2D(Collider2D col)
    {
        if (col.GetComponent<EnvironmentMovement>())
        {
            if (col.GetComponent<EnvironmentMovement>().name == "Drill")
            {
                enableEffect = false;
            }
        }
    }

    bool oneShot = true;
    void Update()
    {
        //particleSystem.gameObject.SetActive(enableEffect);

        if(enableEffect && oneShot)
        {
            ps.Play();
            oneShot = false;
        }
        else if(!enableEffect)
            ps.Stop();
    }
}
