Beispiel #1
0
        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);
        }