//Bound to range, not needed as handled clearned elsewhere public Vector2 FindSafestInRange(BlobScript myPos, List <BlobScript> otherPosition, int range) { var loc = myPos.GetGridLocation(); MarkDownGridSpiral(myPos, otherPosition); var leftBound = (int)(loc.x - range > 0 ? loc.x - range : 0); var RightBound = (int)(loc.x + range < Grid.Length ? loc.x + range : 0); var topBound = (int)(loc.y - range > 0 ? loc.y - range : 0); var bottomBound = (int)(loc.y + range < Grid.Length ? loc.y + range : 0); int min = 100; Vector2 safest = new Vector2(); for (int i = leftBound; i < RightBound; i++) { for (int j = topBound; j < bottomBound; j++) { if (Grid[i, j] < min) { min = Grid[i, j]; safest.x = i; safest.y = j; } } } return(safest); }
//Not Bound to range, not needed as handled clearned elsewhere public Vector2 FindSafestInRange(BlobScript myPos, List <BlobScript> otherPosition) { var loc = myPos.GetGridLocation(); MarkDownGridSpiral(myPos, otherPosition); var min = 100; var safest = new Vector2(); for (int i = 0; i < Grid.GetLength(0); i++) { for (int j = 0; j < Grid.GetLength(1); j++) { if (Grid[i, j] < min) { min = Grid[i, j]; safest.x = i; safest.y = j; } } } return(safest); }