using System.Collections;
using System.Collections.Generic;
using Tobii.EyeTracking;
using UnityEngine;


public class BaseEnemy : MonoBehaviour {

    private AbilityType type;

    protected float health = 5;

    [SerializeField]
    float damage;

    private BoxCollider2D boxCollider;
    private Rigidbody2D rigibody;


    private Animator animator;

    protected SpriteRenderer sr;

    public float Health {
        get {
            return health;
        }
        set {
            health = value;
        }
    }

    public AbilityType Type {
        get {
            return type;
        }

        set {
            type = value;
        }
    }


    public virtual void Start ()
    {
        //animator = GetComponent<Animator>();
        boxCollider = GetComponent<BoxCollider2D>();
        sr = GetComponent<SpriteRenderer>();
        rigibody = GetComponent<Rigidbody2D>();

    }

    public virtual void Update()
    {

        //  Debug.Log("_gazeAware is" + _gazeAware == null ? " Null" : " not");


        if (health <= 0)
        {
            //animator.SetTrigger("Dead");
            Destroy(boxCollider);
            Destroy(rigibody);
        }
        
    }

    public void OnCollisionEnter2D(Collision2D col) {
        Bullet b = col.gameObject.GetComponent<Bullet>();

        if(b != null) {
            if(b.Type.Equals(type)) {
                health -= col.gameObject.GetComponent<Bullet>().damage * 3;
                Destroy(col.gameObject);
            }

        }


    }



}
