/// <summary> /// This method is used to decide which tile the robot has to reach. All the potential tiles are the one that are free and near an unknown one /// </summary> /// <returns></returns> public IEnumerator ChoosingPointToReach() { while (!targetFound) { //RemovingWrongDetection(); DetectingFrontierPoints(); //Debug.Log(posToReach.Count); if (posToReach.Count != 0) { goals = posToReach; tempGoal = rDM.PosToReach(goals); if (route != null) { route.Clear(); } route = rPl.CheckVisibility(transform.position, tempGoal); rM.tempReached = false; if (route == null && noPath) { numeric_robot_map[(int)FixingRound(tempGoal.x / squareSize), (int)FixingRound(tempGoal.z / squareSize)] = numUnknownCell; goals = posToReach; tempGoal = rDM.PosToReach(goals); if (route != null) { route.Clear(); } route = rPl.CheckVisibility(transform.position, tempGoal); rM.tempReached = false; } //Debug.Log(route); if (route == null) { rM.ApproachingPointToReach(tempGoal); } else { rM.ApproachingPointToReach(route, 0); } } else { transform.Rotate(Vector3.up * Time.deltaTime * 20f); } yield return(new WaitForSeconds(timeForDecision)); } }