using Base.Common;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DashEffect : MonoBehaviour
{
    public bool canHit;
    public int damage;
    public Vector3 force;
    public bool changeHurt;
    public float repelValue;
    public List<Character> beHitTriggers = new List<Character>();
    public List<GameObject> enemy = new List<GameObject>();
    public float offset;
    private void Update()
    {
        if (canHit)
        {
            for (int i = 0; i < beHitTriggers.Count; i++)
            {
                beHitTriggers[i].BeHit(damage, force, changeHurt, repelValue);
            }

            transform.parent.gameObject.SetActive(false);
        }
        else
        {
            
            for (int i = 0; i< enemy.Count; i++)
            {
                
                enemy[i].transform.position = transform.position + Vector3.right * offset;
            }
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.layer == 8)
        {
            beHitTriggers.Add(other.GetComponentInParent<Character>());
            enemy.Add(other.transform.parent.parent.parent.gameObject);
        }
    }
}
