public FightStateMachineWill(int id, StateWill state)
     : base(id)
 {
     states = new List<StateWill>();
     transitions = new List<TransitionWill>();
     currentState = state;
 }
 public FightStateMachineWill(int id, List<StateWill> listState, int indexFirstState =0)
     : base(id)
 {
     transitions = new List<TransitionWill>();
     states = listState;
     currentState = states[indexFirstState];
 }
    public override StateWill check(StateWill current = null)
    {
        if (current!=null)
        {
            SW_Dodge dodge = (SW_Dodge)current;
            if (firstTime)
            {
                firstTime = false;
            }

            return nextState;
        }

        return null;
    }
    public override StateWill check(StateWill current = null)
    {
        float dist = Vector3.Distance(TeamManagerWill.instance.members[0].gameObject.transform.position, TeamManagerWill.instance.mainTarget.transform.position);
        if (isTargetFurther)
        {
            if (dist > range)
                return nextState;
        }
        else
        {
            if (dist < range)
            {
                return nextState;
            }

        }

        return null;
    }
    public override StateWill check(StateWill current = null)
    {
        Vector3 posPlayer = TeamManagerWill.instance.members[idAgent].transform.position;
        GameObject target = TeamManagerWill.instance.mainTarget;

        Vector3 dir = target.transform.position - posPlayer;
        RaycastHit hit;
        Debug.DrawRay(posPlayer, dir);
        if (Physics.Raycast(posPlayer, dir, out hit))
        {
            //Debug.Log("tag hit: " + hit.collider.tag + " /name: " + hit.collider.name);
            if (hit.collider.tag == target.tag && isTrue)
            {
                return nextState;
            }
            else if (hit.collider.tag != target.tag && !isTrue&& hit.collider.tag != "Bullet")
            {
                return nextState;
            }
        }

        return null;
    }
 public TW_VisionOnTarget(int id,StateWill pState, bool pIsTrue)
     : base(id, pState)
 {
     isTrue = pIsTrue;
 }
 public TW_DistanceTarget(int id,StateWill pState, bool pIsTargetFurther, float pRange)
     : base(id, pState)
 {
     range = pRange;
     isTargetFurther = pIsTargetFurther;
 }
 public TW_TimeOut(int id, StateWill pState, bool pIsTrue)
     : base(id, pState)
 {
     isTrue = pIsTrue;
 }
 public abstract StateWill check(StateWill current =null);
 public TransitionWill(int id, StateWill pState)
 {
     idAgent = id;
     nextState = pState;
 }
 public void changeState(StateWill newState)
 {
     if(newState!=null)
     currentState = newState;
 }