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

public class JellyfishCollider : MonoBehaviour {

    public GameObject Spawner;
    public GameObject Playah;

    public GameObject explosionPlayer;
 //   public GameObject explosionEnemy;


    void Start()
    {
        Spawner = GameObject.FindGameObjectWithTag("Spawnmanager");
        Playah = GameObject.FindGameObjectWithTag("Player");
    }
	void OnTriggerEnter2D(Collider2D other)
    {
        if(other.gameObject.CompareTag("Player"))
        {
            Instantiate(explosionPlayer, Spawner.transform);
            Debug.Log("Player Hit");
            Destroy(this.gameObject);
            other.SendMessage("TakeDamage");
            // damage player
            Spawner.GetComponent<SpawnManager>().remainingAlive--;

            //
        }

        if (other.gameObject.CompareTag("Playerbullet"))
        {
            Debug.Log("Player bullet Hit");
            
            Spawner.GetComponent<SpawnManager>().remainingAlive--;
            Playah.GetComponent<PlayerScore>().AddScore(10);
            Destroy(this.gameObject);
            Destroy(other.gameObject);
            // damage player

            //
        }
    }
}
