private Coords NearestAcessibleHex(Coords goal, MoveRangeCalculator range) { Coords here = range.Origin; Int32 currentBestDistance = -1; Coords currentBest = new Coords(); // Lame. BitArray[] rangeMap = range.CurrentRangeMap; for (int i = 0; i < rangeMap.Length; ++i) { for (int j = 0; j < rangeMap[i].Count; ++j) { Coords currentCoords = new Coords(i, j); Int32 currentDistance = goal.DistanceTo(currentCoords); if (rangeMap[i][j] && (currentDistance < currentBestDistance || currentBestDistance == -1)) { currentBestDistance = currentDistance; currentBest = currentCoords; } } } return(currentBest); }
private Coords RandomAccessibleHex(MoveRangeCalculator range) { List <Coords> possibleMoves = new List <Coords>(); BitArray[] rangeMap = range.CurrentRangeMap; for (int i = 0; i < rangeMap.Length; ++i) { for (int j = 0; j < rangeMap[i].Count; ++j) { if (rangeMap[i][j]) { possibleMoves.Add(new Coords(i, j)); } } } RandomStuff randomator = _owner.MapGeneral.Randomator; return(possibleMoves[(Int32)(randomator.NSidedDice((UInt16)possibleMoves.Count, 1) - 1)]); }