using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum AssassinState
{
    None = -1,
    Normal = 0, //正常状态
    FindPlayer = 1, //寻找主角位置
    Rushing = 2,   //向主角方向冲刺中
}
public class ESpirits_Assassin : MonoBehaviour
{
    [HideInInspector] 
    public float time;
    public float attackCD;
    public AssassinState state;
    public Enemy enemy;
    
    private void Update()
    {
        if (enemy.floatState == 0)
        {
            OnState();
        }
        switch (enemy.state)
        {
            case CharacterState.Die:
                this.enabled = false;
                break;
            case CharacterState.FinishRush:
                state = AssassinState.Normal;
                break;
            default:
                break;
        }
    }
    public void OnState()
    {
        switch (state)
        {
            case AssassinState.Normal:
                time += Time.deltaTime;
                if (time > attackCD)
                {
                    time = 0;
                    enemy.ChangeState(CharacterState.FindPlayer);
                    state = AssassinState.FindPlayer;
                }
                break;
            case AssassinState.FindPlayer:
                if(enemy.state  == CharacterState.Idle)
                {
                    enemy.ChangeState(CharacterState.FindPlayer);
                }
                if (enemy.isFindPlayer)
                {
                    enemy.ChangeState(CharacterState.ReadyToRush);
                    state = AssassinState.Rushing;
                }
                break;
            default:
                break;
        }
    }

}
