Пример #1
0
        private static List <int> GetBoxesToExit(INavigator navigator, SokobanPathItem entryPoint)
        {
            var boxes = new List <int>();

            //var areasToBoxTouchPoints = GetAreasToBoxesTouchPoints(navigator);
            //var keeperPos = navigator.GetKeeperPosition();
            //var keeperArea = areasToBoxTouchPoints.Where(x => x.Value.Positions.Contains(keeperPos)).First();

            navigator.Foreach(new[] { Sokoban.BOX_ON_LOCATION }, (box) =>
            {
                var keeperPos    = navigator.GetKeeperPosition();
                var keeperTarget = navigator.GetPosition(navigator.GetOppositeKey(entryPoint.Key), keeperPos);
                var targetBoxPos = entryPoint.Position;

                if (navigator.CanDrag(keeperPos, box, keeperTarget.Value, targetBoxPos))
                {
                    boxes.Add(box);
                }

                //var keeperToBoxTouchPoints = keeperArea.Value.EntryPoints.Where(ep => navigator.GetPosition(ep.Key, ep.Position).Value == box).ToList();

                //var isKeeperCanTouchBox = keeperToBoxTouchPoints.Count > 0;

                //if (isKeeperCanTouchBox && CanDrag(box, navigator, entryPoint, keeperToBoxTouchPoints))
                //{
                //    boxes.Add(box);
                //}
            });

            return(boxes);
        }