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

public class WinSewPoints : MonoBehaviour
{
    public event SewPointCollected SewPointHandler;
    public GameObject m_PS;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    /// <summary>
    /// OnTriggerEnter is called when the Collider other enters the trigger.
    /// </summary>
    /// <param name="other">The other Collider involved in this collision.</param>

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player"){
            if (SewPointHandler != null){
                GameObject psObj = Instantiate(m_PS);
                ParticleSystem ps = psObj.GetComponent<ParticleSystem>();
                Debug.Log("spawn");
                ps.Emit(1);
                SewPointHandler(gameObject);
                psObj.transform.position = transform.position;
                Destroy(psObj, 0.5f);
            }
        }
    }
}
