Beispiel #1
0
        private bool Ydirect(Grid start, Grid end, LinkedList path)
        {
            if (start.GetXpos() != end.GetXpos())
            {
                return false;
            }
            int direct = 1;
            if (start.GetYpos() > end.GetYpos())
            {
                direct = -1;
            }
            path.Clear();
            for (int y = start.GetYpos() + direct; y != end.GetYpos() && y < yBound
                    && y >= 0; y += direct)
            {
                if (grid[y][start.GetXpos()].IsVisible())
                {
                    return false;
                }
                path.Add(grid[y][start.GetXpos()]);
            }

            path.Add(end);
            return true;
        }
Beispiel #2
0
        private bool Xdirect(Grid start, Grid end, LinkedList path)
        {
            if (start.GetYpos() != end.GetYpos())
                return false;
            int direct = 1;
            if (start.GetXpos() > end.GetXpos())
            {
                direct = -1;
            }
            path.Clear();
            for (int x = start.GetXpos() + direct; x != end.GetXpos() && x < xBound
                    && x >= 0; x += direct)
            {
                if (grid[start.GetYpos()][x].IsVisible())
                {
                    return false;
                }
                path.Add(grid[start.GetYpos()][x]);
            }

            path.Add(end);
            return true;
        }