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

public class BoosssColls : 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

            //
        }

        if (other.gameObject.CompareTag("Playerbullet"))
        {
            Debug.Log("Player bullet Hit");

           
            Playah.GetComponent<PlayerScore>().AddScore(10);
            this.GetComponent<BossFSM>().currentlife--;

            if(this.GetComponent<BossFSM>().currentlife <= 0)
            {
                Spawner.GetComponent<SpawnManager>().remainingAlive--;
                Destroy(this.gameObject);
            }
            Destroy(other.gameObject);
            // damage player

            //
        }
    }
}
