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

public class enemykiller : MonoBehaviour
{
    // Start is called before the first frame update
    public ParticleSystem part;
    public List<ParticleCollisionEvent> collisionEvents;
    void Start()
    {
        part = GetComponent<ParticleSystem>();
        collisionEvents = new List<ParticleCollisionEvent>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    //on particle coolision
    void OnParticleCollision(GameObject otherx)
    {
        int numCollisionEvents = part.GetCollisionEvents(otherx, collisionEvents);
        int i = 0;
        while (i < numCollisionEvents)
        {
            GameObject other = collisionEvents[i].colliderComponent.gameObject;
            if (other.tag == "enemy")
            {
                Destroy(other);
                Debug.Log("enemy killed");
            }
            if (other.tag == "king")
            {
                Destroy(other);
                Debug.Log("killed king");
            }
            i++;
        }
    }
}
