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

public class Acidites : MonoBehaviour
{
    [SerializeField] int healthPoints;
    [SerializeField] int damagePoints;

    [SerializeField] float moveSpeed;

    [SerializeField] bool commangle;
    [SerializeField] int bathDamage;

    void Start()
    {
    }

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

    void CheckHealth()
    {
        if (healthPoints <= 0) 
        {
            Destroy(gameObject);
        }
    }
    void Movement()
    {
        transform.position = new Vector3(transform.position.x - moveSpeed * Time.deltaTime, transform.position.y);
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Bubble")
        {
            Destroy(collision.gameObject);
            healthPoints -= collision.gameObject.GetComponent<Bubbles>().damage;
        }

        if (collision.gameObject.tag == "Bath" && commangle == false)
        {
            healthPoints -= bathDamage;
        }
        if (collision.gameObject.tag == "Machine")
        {
            Destroy(collision.gameObject);
        }
    }
}
