private static StarDistance[][] CalculateStarsDistances() { StarDistance[][] result = new StarDistance[settings.STARS_AMMOUNT][]; for (int i = 0; i < settings.STARS_AMMOUNT; i++) { List <StarDistance> subList = new List <StarDistance>(); for (int u = 0; u < settings.STARS_AMMOUNT; u++) { subList.Add(new StarDistance { index = u, distance = Vector3.Distance(Galaxy.StarSystemsArr[i].position, Galaxy.StarSystemsArr[u].position), direction = (Galaxy.StarSystemsArr[u].position - Galaxy.StarSystemsArr[i].position).normalized }); } result[i] = subList.ToArray(); } return(result); }
private static StarDistance[][] SortDistanceArr() { var list = new List <StarDistance[]>(); for (int i = 0; i < Galaxy.Distances.Length; i++) { var subList = new StarDistance[Galaxy.Distances[i].Length]; for (int j = 0; j < subList.Length; j++) { subList[j] = Galaxy.Distances[i][j]; } Array.Sort(subList, (x, y) => { return(x.distance >= y.distance ? 1 : -1); }); list.Add(subList); } return(list.ToArray()); }