//------------------------------------------
    public IEnumerator AICallForHelp()
    {
        //Loop while chasing and attacking
        while (currentstate == LOOK_OUT_STATE.CALL_FOR_HELP)
        {
            ThisAgent.isStopped = true;
            setSpeed(0);


            // play the sound
            soundSource.Play();

            //wait for mice to hear call
            yield return(new WaitForSeconds(1f));

            //spawn 3 guard mice
            Instantiate(guardMicePrefab, miceSpawnPoint.GetComponent <Transform>().position + Vector3.forward, Quaternion.identity);
            yield return(new WaitForSeconds(3.5f));

            Instantiate(guardMicePrefab, miceSpawnPoint.GetComponent <Transform>().position, Quaternion.identity);
            yield return(new WaitForSeconds(3.5f));

            Instantiate(guardMicePrefab, miceSpawnPoint.GetComponent <Transform>().position + Vector3.back, Quaternion.identity);

            CurrentState = LOOK_OUT_STATE.WATCH;

            //Wait until next frame
            yield return(null);
        }
        yield break;
    }
    //------------------------------------------
    public IEnumerator AILook_Around()
    {
        // specifiy local variables
        ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;
        float   angle = 360.0f;     // Degree per time unit
        float   time  = 5.0f;       // Time unit in sec
        Vector3 axis  = Vector3.up; // Rotation axis, here it the yaw axis
        float   timer = 0;

        // look around
        while (timer < time)
        {
            transform.RotateAround(transform.position, axis, angle * Time.deltaTime / time);
            timer += Time.deltaTime;
            if (ThisLineSight.CanSeeTarget)
            {
                CurrentState = LOOK_OUT_STATE.CALL_FOR_HELP;
                yield break;
            }
            yield return(null);
        }

        // still could not locate player, return to idle/patrol state
        if (!useWaypoints)
        {
            CurrentState = LOOK_OUT_STATE.IDLE;
        }
        else
        {
            CurrentState = LOOK_OUT_STATE.PATROL;
        }

        yield break;
    }
    //------------------------------------------
    void Start()
    {
        //Configure starting state
        if (!useWaypoints)
        {
            CurrentState = LOOK_OUT_STATE.IDLE;
        }
        else
        {
            //set first destination
            //waypoints = GameObject.FindGameObjectsWithTag("Destination");
            currWaypoint = -1;
            setNextWaypoint();

            CurrentState = LOOK_OUT_STATE.PATROL;
        }
        soundSource = GetComponent <AudioSource>();
    }
    //------------------------------------------
    public IEnumerator AIRunAway()
    {
        //Loop while chasing
        while (currentstate == LOOK_OUT_STATE.RUN_AWAY)
        {
            //Set loose search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.LOOSE;

            RunAwayFromPlayer();

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //set speed
            this.setSpeed();

            //Have we reached destination?
            if (ThisAgent.remainingDistance <= ThisAgent.stoppingDistance)
            {
                //Stop agent
                ThisAgent.isStopped = true;

                //Reached destination but cannot see player
                if (!ThisLineSight.CanSeeTarget)
                {
                    //look around
                    CurrentState = LOOK_OUT_STATE.WATCH;
                }
                else
                {
                    //Reached destination and can see player
                    //CurrentState = LOOK_OUT_STATE.CALL_FOR_HELP;
                }

                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
    //------------------------------------------
    public IEnumerator AIIdle()
    {
        while (currentstate == LOOK_OUT_STATE.IDLE)
        {
            //Set strict search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;

            ThisAgent.isStopped = true;

            //If we can see the target then start chasing
            if (ThisLineSight.CanSeeTarget)
            {
                CurrentState = LOOK_OUT_STATE.CALL_FOR_HELP;
                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
    //------------------------------------------
    public IEnumerator AIWatch()
    {
        while (currentstate == LOOK_OUT_STATE.WATCH)
        {
            ThisAgent.isStopped = true;
            setSpeed(0);

            if (numGuardMice <= 0)
            {
                CurrentState = LOOK_OUT_STATE.LOOK_AROUND;
                yield break;
            }

            // if(!ThisLineSight.CanSeeTarget && Vector3.Distance(PlayerTransform.position, this.PlayerTransform.position) < 3) {
            //     CurrentState = LOOK_OUT_STATE.RUN_AWAY;
            // }

            //Wait until next frame
            yield return(null);
        }
    }
    //------------------------------------------
    public IEnumerator AIPatrol()
    {
        //Loop while patrolling
        while (currentstate == LOOK_OUT_STATE.PATROL)
        {
            //Set strict search
            ThisLineSight.Sensitity = LineSight.SightSensitivity.STRICT;

            //Chase to patrol position
            ThisAgent.isStopped = false;
            ThisAgent.SetDestination(PatrolDestination.position);

            //Check to see if reached destination
            if (ThisAgent.remainingDistance <= ThisAgent.stoppingDistance)
            {
                setNextWaypoint();
            }

            //Wait until path is computed
            while (ThisAgent.pathPending)
            {
                yield return(null);
            }

            //set speed
            this.setSpeed();


            //If we can see the target then start chasing
            if (ThisLineSight.CanSeeTarget)
            {
                ThisAgent.isStopped = true;
                CurrentState        = LOOK_OUT_STATE.CALL_FOR_HELP;
                yield break;
            }

            //Wait until next frame
            yield return(null);
        }
    }
 public void deathHasOccured()
 {
     CurrentState = LOOK_OUT_STATE.DEATH;
 }