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

public class Trans_Float : MonoBehaviour
{
    public PlayerController controller;

    private bool isFirst = true;           //第一次攻击
    private int times;              //攻击次数
    public int minTime, maxTime;   //保底范围

    public bool toFloat = false;           //攻击触发漂浮
    private Demonic dem;

    private void Start()
    {
        controller = GetComponentInParent<PlayerController>();
        dem = GetComponent<Demonic>();
    }

    private void Update()
    {
        if (controller.isinputJ)
        {
            controller.isinputJ = false;
            if (isFirst)
            {
                if (!dem.attackToFloat)
                {
                    isFirst = false;
                    dem.attackToFloat = true;
                }
            }
            else
            {
                if (!dem.attackToFloat)
                {
                    times += 1;
                    if (times >= minTime || times == maxTime)
                    {
                        times = 0;
                        dem.attackToFloat = true;
                    }
                }
            }
            GetComponent<Demonic>().Attack2();
        }
        if (controller.isinputK)
        {
            controller.isinputK = false;
            print(2);
        }
        if (controller.isinputL)
        {
            controller.isinputL = false;
            print(3);
        }
    }
}
