Beispiel #1
0
        public IEnumerable <IGameMapMovementRoute> GetAllRoutesForUnit(IGameUnit unit)
        {
            // Create our return list
            var routesFound = new Dictionary <int, IGameMapMovementRoute>();

            if (!unit.HasRemainingMovement())
            {
                return(Enumerable.Empty <IGameMapMovementRoute>());
            }

            // Pull our relevant stats from our unit
            var mapX = unit.MapX;
            var mapY = unit.MapY;
            var availableMovement = unit.RemainingMovement;

            // Create an origin route that we'll extend from here
            var originRoute = new GameMapMovementRoute(mapX, mapY);

            GetRoutesForLocationBreadthSearch(routesFound, originRoute, unit, availableMovement);

            // Now that we found our routes filter out the routes that the user can't end on and return them
            return(routesFound.Values.Where(x => x.CanStopHere).ToList());
        }