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

public class AttackState : MonoBehaviour
{
    public ExaustedState ExaustedState;
    public CharacterController Controller;
    public Vector3 Direction;
    public float Speed;
    public float Duration;
    public float Damage;
    private float timer;

    public Transform ModelForEater;
    public float RotationSpeed;
    public ParticleSystem AttackTrail;

    // Start is called before the first frame update
    void OnEnable()
    {
        Controller.transform.LookAt(Direction + Controller.transform.position);
        AttackTrail.Play(true);
        timer = 0;
    }

    void OnDisable()
    {
        AttackTrail.Stop(true);
    }

    // Update is called once per frame
    void Update()
    {

        Controller.Move(Direction * Speed * Time.deltaTime);
        ModelForEater.Rotate(ModelForEater.right, RotationSpeed * Time.deltaTime, Space.World);

        timer += Time.deltaTime;
        if(timer > Duration)
        {
            enabled = false;
            ExaustedState.Duration = 2;
            ExaustedState.enabled = true;
        }
    }
}
