﻿using UnityEngine;

public class SuccubusScript : MonoBehaviour
{
    public GameObject PlayerObj;
    public float CurrentHP = 100;

    private Rigidbody2D succubusRigidbody;
    private const float Speed = 10f;
    private float prevHP = 100;
    private float maxHP = 100;

    // Start is called before the first frame update
    void Start()
    {
        succubusRigidbody = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        var vector = new Vector2(PlayerObj.transform.position.x, PlayerObj.transform.position.y) - succubusRigidbody.position;
        succubusRigidbody.position += vector.normalized * Time.deltaTime * Speed;
    }

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Sword")
        {
            Destroy(gameObject);
            // Visszább kéne lökni, vagy csak megállítani egy kicsit, és sebződni.
        }
    }
}
