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

public class HealthConsuming : MonoBehaviour
{
    [SerializeField] protected float _speedMax = 8f;
    [SerializeField] protected float _speedMin = 1f;
    [SerializeField] protected float _damageIntensity = 1f;
    protected CharacterMovement _movement;
    protected HealthComponent _hc;

    private void Awake()
    {
        _movement = GetComponent<CharacterMovement>();
        _hc = GetComponent<HealthComponent>();
    }

    private void Update()
    {
        Vector3 v = _movement.velocity + Vector3.up * _movement.currentGravity;
        if (v.magnitude < _speedMin)
            return;

        _hc.TakeDamage(v.magnitude * Time.deltaTime * _damageIntensity);
    }
}
